I have the following code which works:
$date1 = mysql_query("SELECT date1 FROM Users WHERE username='".$_SESSION['username']."'")
or die(mysql_error());
while($row = mysql_fetch_array($date1)){
$lastViewedDate = $row[0];
}
But when I try to use mysql_fetch_object I get an Internal Server Error 500.
$date1 = mysql_query("SELECT date1 FROM Users WHERE username='".$_SESSION['username']."'")
or die(mysql_error());
while($row = mysql_fetch_object($date1)){
$lastViewedDate = $row["date1"];
}
I would prefer to use the objects in the future but I don't understand why they aren't working. Any help would be appreciated.
mysql_*
functions to write new code. They are no longer maintained and the community has begun deprecation process. See the red box? Instead you should learn about prepared statements and use either PDO or MySQLi. If you can't decide which, this article will help you. If you pick PDO, here is good tutorial. – Second Rikudo Sep 14 '12 at 18:28mysqli
or PDO. – tadman Sep 14 '12 at 18:29