PLEASE VERIFY MySQL SYNTAX

Codes here !

Moderators: macek, egami, gesf

Post Reply
kelvin24
New php-forum User
New php-forum User
Posts: 12
Joined: Mon Aug 13, 2012 5:11 pm

PLEASE VERIFY MySQL SYNTAX

Post by kelvin24 » Thu Aug 23, 2012 6:55 am

What is wrong with this syntax?

Code: Select all

$log="UPDATE log SET logouttime='$time' WHERE username='$_SESSION['username']'";

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: PLEASE VERIFY MySQL SYNTAX

Post by Nullsig » Thu Aug 23, 2012 7:58 am

Really you should escape out of the string when dealing with PHP variables. In this case the single quotes in your session variable are ending the quote surrounding it prematurely.

Code: Select all

$log="UPDATE log SET logouttime='" . $time . "' WHERE username='" . $_SESSION['username'] . "'";

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests