mysql_fetch_assoc not echoing date value
Posted: Thu Apr 16, 2009 10:28 am
Trying to grab information for a profile page. For some reason the registration date does not get echoed even though the other values all do:
$regdate appears fine in the MySQl table. In the registration form, it's defined as:
Could that be part of the problem, or is it something simpler like a typo somewhere?
Code: Select all
<?php
include 'db.php';
$uname = $_SESSION['uname'];
$sql = "SELECT * FROM logintest WHERE uname='$uname'";
$result = mysql_query($sql) or die (mysql_error());
$num_rows = mysql_num_rows($result);
if ($result) {
$data = mysql_fetch_assoc($result);
$userid = $data['userid'];
$email = $data['email'];
$regdate = $data['regdate'];
}
else {
error('A database error occured');
}
?>
<center>
<table border="1">
<tr><td colspan="2" width="600"><font size="4"><? print $uname ?></font></td></tr>
<tr><td><b>User ID #</b></td><td><? print $userid ?></td></tr>
<tr><td><b>E-mail adddress</b></td><td><? print $email ?> <a href="changeemail.htm">(Change)</a></td></tr>
<tr><td><b>Registration date</b></td><td><? print $regdate ?></td></tr>
<tr><td colspan="2"><a href="changepass.htm">Change Password</a></td><td></td></tr>
</table>
Code: Select all
$date = date("F d, Y");
$time = date("H:i");
$timediff = date("O");
$regdate = $date . ", " . $time . " (GMT" . $timediff . ")";