PLEASE VERIFY MySQL SYNTAX

Codes here !

Moderators: egami, macek, gesf

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

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: 979
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

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
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests