Menu
Question 1. Any idea why this query wont work?
[code=php]
$linkid= mysql_connect(“localhost”, “”, “”)or die(mysql_error());
mysql_select_db(“”, $linkid);
$sql = ‘INSERT INTO `blog` ( `ID` , `timestamp` , `title` , `content` ) ‘
. ‘ VALUES ( ”, NOW( ) , $title, $content );’
. ‘ ‘;
$query=mysql_query($sql);
echo”Entry Added!”;
mysql_close($linkid);
Question 2.
How do i convert a timestamp like this 20040403173538 to a regualr date format
[code=php]
$currTime = time();
echo (date("m/d/y g:i a", $currTime));
[/code]
[code=php]
$linkid = mysql_connect("localhost", "", "") or die(mysql_error());
mysql_select_db("", $linkid);
[/code]
$sql = "INSERT INTO <span><code>blog</code></span> ( <span><code>ID</code></span> , <span><code>timestamp</code></span> , <span><code>title</code></span> , <span><code>content</code></span> ) "
. " VALUES ( \'\', NOW( ) , $title, $content )";
[code=php]
$query=mysql_query($sql);
if(!$query) die(mysql_error());
echo "Entry Added!";
mysql_close($linkid);
[/code]
[i]Originally posted by RefreshF5 [/i]
[B]any idea why right now is coming up as 01/18/38 10:14 pm [/B][/QUOTE]
[i]Originally posted by RefreshF5 [/i]
[B]Im trying a page like thishttp://ryanbrill.com/archives.php but without the year seperation. IS this hard to do? [/B][/QUOTE]
[code=php]
for ($y = 0; $y < $rows; $y++)
{
$ID = mysql_result($result, $y, 'ID');
$title = mysql_result($result, $y, 'title');
$content = mysql_result($result, $y, 'content');
$date = mysql_result($result, $y, 'date');
echo' <a href="entry.php?ID='.$ID.'">';
echo' '.$title;
echo' </a>';
}
[/code]
[i]Originally posted by RefreshF5 [/i]
[B]I realize that the comments table will have to be a seperate table from the blog table but how does it know which comments goes to which entry. ? [/B][/QUOTE]
[code=php]
$ID = $_GET['ID'];
$query = "SELECT * FROM blog WHERE ID='".$ID."'";
$result = mysql_query($query);
$id=mysql_result($result,0,'ID');
$title = mysql_result($result, 0, 'title');
$content = mysql_result($result, 0, 'content');
$date = mysql_result($result, 0, 'date');
[/code]
[code=php]
$query2 = "SELECT * FROM comments WHERE replyto='".$id."'";
$result2=mysql_query($query2);
$name= mysql_result($result2, 0, 'name');
$comment= mysql_result($result2, 0, 'comment');
[/code]
[code=php]
$id=$_POST['ID'];
[/code]
[code=php]
$query2 = "SELECT * FROM comments WHERE replyto='".$ID."'";
[/code]
[code=php]
<?
$un = "";
$pass = "";
$db = "";
$host = "localhost";
$sql = mysql_connect($host, $un, $pass) or die(mysql_error());
mysql_select_db($db, $sql) or die(mysql_error());
if (mysql_ping($sql))
{
$ID = $_GET['ID'];
$query = "SELECT * FROM blog WHERE ID='".$ID."'";
$result = mysql_query($query);
$id=mysql_result($result, 0, 'ID');
$title = mysql_result($result, 0, 'title');
$content = mysql_result($result, 0, 'content');
$date = mysql_result($result, 0, 'date');
mysql_free_result($result);
$query2 = "SELECT * FROM comments WHERE replyto='".$id."'";
$result2=mysql_query($query2);
$name= mysql_result($result2, 0, 'name');
$comment= mysql_result($result2, 0, 'comment');
mysql_free_result($result2);
}
?>
[/code]
[i]Originally posted by RefreshF5 [/i]
[B]Everytime they refresh it adds the comment over and over again anyway to fix this? [/B][/QUOTE]
[code=php]
$postlimit=$row['time'] - time();
$ip=$_SERVER['REMOTE_ADDR'];
if(($ip==$row['ip']) AND ($postlimit<=60))
{
echo"You must wait 60 seconds before posting again";
}
else
{
$query="INSERT INTO comments
( ID
, name
, comment
, replyto
, title
, date
, ip
, lastpost
) VALUES ('', '$user', '$comments', '$id' , '$title' , '$dat' , '$ip' , '$time');";
mysql_query($query);
}
[/code]
[code=php]
$query = "SELECT * FROM comments WHERE ip='".$_SERVER['REMOTE_ADDR']."LIMIT 1";
[/code]
[code=php]<?
$query3 = "SELECT * FROM comments WHERE ip='".$_SERVER['REMOTE_ADDR']."LIMIT 1";
$result3=mysql_query($query3);
while ($rows = mysql_fetch_row($result3))
{
$lastreply=$rows[8];
$ip_add=$rows[7];
echo $postlimit;
echo $ip_add;
}
[/code]
[code=php]
$query3 = "SELECT * FROM comments WHERE ip='".$_SERVER['REMOTE_ADDR']."LIMIT 1";
$result3=mysql_query($query3);
while ($rows = mysql_fetch_assoc($result3))
{
$lastreply=$rows['lastpost'];
$ip_add= $rows['ip'];
echo $postlimit;
echo $ip_add;
}
[/code]
[code=php]
$query3 = "SELECT * FROM comments WHERE ip='".$_SERVER['REMOTE_ADDR']."LIMIT 1";
$result3=mysql_query($query3);
if($result3){
while ($rows = mysql_fetch_assoc($result3))
{
$lastreply=$rows['lastpost'];
$ip_add= $rows['ip'];
echo $postlimit;
echo $ip_add;
}
}
[/code]
[code=php]
<?
$query3 = "SELECT * FROM comments WHERE ip='".$_SERVER['REMOTE_ADDR']."LIMIT 1";
$result3=mysql_query($query3);
if($result3){
while ($rows = mysql_fetch_assoc($result3))
{
$lastreply=$rows['lastpost'];
$ip_add= $rows['ip'];
echo $postlimit;
echo $ip_add;
}
}
$postlimit=$lastreply - time();
$ip=$_SERVER['REMOTE_ADDR'];
if(($ip==$ip_add]) AND ($postlimit<=60))
{
echo"You must wait 60 seconds before posting again";
}
else
{
$query4="INSERT INTO comments
( ID
, name
, comment
, replyto
, title
, date
, ip
, lastpost
) VALUES ('', '$user', '$comments', '$id' , '$titl' , '$dat' , '$ip' , '$time');";
mysql_query($query4);
}
?>
[/code]
[i]Originally posted by RefreshF5 [/i]
[B]nope still adding one on each refresh ?, i wonder how pyro does it on his site. [/B][/QUOTE]
[code=php]
$query = "SELECT last_post_time
FROM players
WHERE username
= '". $_SESSION["username"] ."'";
$result=mysql_query($query);
if(!$result){dispErrMsg("Database error: ".mysql_error());}
if(mysql_num_rows($result)==0){ $lastPostTime="never"; }
$row=mysql_fetch_assoc($result);
$lastPostTime=$row["last_post_time"];
if($lastPostTime > time()-60){
dispErrMsg("Flood Detected!");
}
[/code]
[code=php]
$query3 = "SELECT lastpost
FROM comments
WHERE ip
= '". $ip."'";
$result=mysql_query($query3);
if(!$result){echo"Database error";
}
if(mysql_num_rows($result)==0)
{
$lastPostTime="never";
}
$row=mysql_fetch_assoc($result);
$lastPostTime=$row["lastpost"];
if($lastPostTime > $time-60){
echo"You can only reply once every 60 seconds";
}
elseif(($comments != "") AND ($title != ""))
{
$query4="INSERT INTO comments
( ID
, name
, comment
, replyto
, title
, date
, ip
, lastpost
) VALUES ('', '$user', '$comments', '$id' , '$titl' , '$dat' , '$ip' , '$time');";
mysql_query($query4);
}
elseif(($comment=="") AND ($title==""))
{
echo"You must fill in all form fields";
}
echo"</div></form>";
include("footer.php");
?>
[/code]
[i]Originally posted by akadis [/i]
[B]ok stupid question, what does your script do? [/B][/QUOTE]
[i]Originally posted by RefreshF5 [/i]
[B]thanks again now i just need to write up some CSS for my blog and i can start my next project, a text based game that goes by user radio button choices [/B][/QUOTE]
[i]Originally posted by akadis [/i]
[B]thanks for the reply, its just as a begining programer i think its good to learn/read other's code as well [/B][/QUOTE]
0.1.9 — BETA 5.19