I'm having a problem with the following code. It is supposed to update a database and no matter what I try, the database table never changes. Not sure what's wrong with it. Help would be appreciated. Thanks. (I've been trying a few things, hence the commented out parts...whatever, I can't tell anymore what's right or not.)
Here is the code:
global $user, $sitename;
cookiedecode($user);
$username = $cookie[1];
$htime = date(h);
$mtime = date(i);
$ntime = date(a);
$mtime = "$htime:$mtime $ntime";
$mdate = date(m);
$ddate = date(d);
$ydate = date(Y);
$ndate = "$mdate-$ddate-$ydate";
$pdate = $ndate;
$ptime = $mtime;
$ptime = ml_ftime(_TIMEBRIEF, (GetUserTime(time())));
if ($debug == "true") :
echo ("UserName:$username<br>SiteName: $sitename");
endif;
startjournal($sitename,$user);
echo ("<h3 align=center>Journal Entry Added!</h3>");
echo ("<div align=center> [ <a href=\"modules.php?op=modload&name=Journal&file=edit\">Return to your journal</a> ]</div>");
$db = mysql_connect("$dbhost","$dbuname","$dbpass");
mysql_select_db("$dbname", $db);
$sql="INSERT INTO nuke_journal (jid,aid,title,bodytext,mood,pdate,ptime,status,mtime,mdate) VALUES ('','$username','$title','$bodytext','$mood','$pdate','$ptime','$status','$mtime','$ndate')";
mysql_query($sql);
//$sql = "SELECT FROM nuke_journal_stats WHERE joid = '$username'";
$result = mysql_query("SELECT FROM nuke_journal_stats WHERE joid = '$username'",$db);
//$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 0)
{
//$row_count = mysql_num_rows($result);
//if ($row_count == 0):
$query = "INSERT INTO nuke_journal_stats (id,joid,nop,ldp,ltp,micro) VALUES ('','$username','1',now(),'$mtime',now())";
mysql_query($query);
}
if (mysql_num_rows($result) != 0)
{
$row = mysql_fetch_array($result);
$nnop = $row[nop];
$nnnop = ($nnop + 1);
$micro = date(U);
$query = "UPDATE nuke_journal_stats SET id='', joid='$username', nop='$nnnop', ldp='$ndate', ltp='$mtime' micro='$micro' WHERE joid='$username'";
mysql_query($query);
}
journalfoot();
include ("footer.php");
?>