Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

PLEASE VERIFY MySQL SYNTAX

Codes here !

Moderators: macek, egami, gesf

PLEASE VERIFY MySQL SYNTAX

Postby 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']'";
kelvin24
New php-forum User
New php-forum User
 
Posts: 12
Joined: Mon Aug 13, 2012 5:11 pm

Re: PLEASE VERIFY MySQL SYNTAX

Postby 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'] . "'";
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.