Updating date won't work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Updating date won't work

Post 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);

?>
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post 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.
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you aren't using $date anywhere in your code.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Where is $prefix defined?
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post 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:
Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Post 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
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post 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. :?
Post Reply