Page 1 of 1

Updating date won't work

Posted: Wed Oct 19, 2005 7:03 pm
by Cateyes
Hi guys I am having a problem with my date updating everything else works in the code but my date shows up all as zero's here is the code:

Code: Select all

<?php

##Include configurations
include("config.php");
$message = $_GET['message'];
$userID = $_GET['userID'];
$threadID = $_GET['threadID'];
$connection = dbConnect();
$date = date('Y-m-d h:i:s');
mysql_query("INSERT INTO " . $prefix . "posts(dateposted, threadID, msg_body, userID, poster_ip) VALUES (NOW(), '$threadID', '$message', '$userID', '$REMOTE_ADDR')", $connection);

mysql_query("UPDATE " . $prefix . "threads SET reply_num=reply_num+1 WHERE threadID = '$threadID'", $connection);
mysql_query("UPDATE " . $prefix . "threads SET last_msg='date' WHERE threadID = '$threadID'", $connection);
mysql_query("UPDATE " . $prefix . "users SET postcount=postcount+1 WHERE userID = '$userID'");

echo "result=Okay";

mysql_close($connection);

?>

Posted: Wed Oct 19, 2005 8:19 pm
by anthony88guy
I dont know the answer to your problem, but your trusting the users input ($_GET) which can be very bad. You should "clean" the $_GET info before using it.

Thats my newbie wisedom.

Posted: Wed Oct 19, 2005 8:49 pm
by Cateyes
well if I echo the $date it works it just doesnt update the database properly for example it echos 2005-10-19 7:49:38
but updates with 0000-00-00 00:00:00

Posted: Wed Oct 19, 2005 9:06 pm
by feyd
you aren't using $date anywhere in your code.

Posted: Wed Oct 19, 2005 9:09 pm
by Jenk
Where is $prefix defined?

Posted: Wed Oct 19, 2005 9:18 pm
by Cateyes
$prefix is in the included config.php and Feyd was right I was using 'date' instead of $date what I don't understand is how I could make such a mistake. :oops:

Posted: Wed Oct 19, 2005 9:19 pm
by Dm7
Cateyes wrote:$prefix is in the included config.php and Feyd was right I was using 'date' instead of $date what I don't understand is how I could make such a mistake. :oops:
:oops: I know that feeling.. lol

Posted: Wed Oct 19, 2005 10:33 pm
by Cateyes
Yeah I am rewriting some code for a flash forum it hasnt been done since 2002 and am making it compatible with PHP5 and MySQL 5 as well as still work on the older systems one major bug I fixed was to get admin rights all you had to get right was the admin user name the person that programmed syill let it retrieve the info even if the pw didnt match major hole and still more to find. :) If anyone want to see what it looks like here is the testing address http://cov.clan-web.com/flashbb/Forum4.html the original was at the same site but decided i didnt want the database erased. :?