Page 1 of 1

Syntax Error

Posted: Thu May 19, 2011 1:57 pm
by bluestar
i have a little syntax problem in php mysql, and i cant figure it out, hoping that u guys can help me out....mysql error and code are below

Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='4', Room='3', ab='1', ' at line 1

note: realescpaestring -- do stripslash function and $_session['cemailid'] is a variable
and be carefull between single quote and double quote(actually its nt cleared here thats why im telling) "--> is double quote and '--> is single quote

code:

Code: Select all

$table1="xyz";
$query1 = 'UPDATE '.$table1. "SET 
Building= ' ". $this->realescapestring($_GET['Building']) . " ',
Room= ' ". $this->realescapestring($_GET['Room']) . " ',        
ab= ' ". $this->realescapestring($_GET['abs']) ." ',
Hospite= ' " . $this->realescapestring($_GET['Hospite']) . " ',
Tolet=' " . $this->realescapestring($_GET['Tolet']) . " ',
ground=' " . $this->realescapestring($_GET['ground']) . " ',
No1=' " . $this->realescapestring($_GET['Pts1']) . " ',
Policy=' " . $this->realescapestring($_GET['Policy']) . " ', 
Class=' " . $this->realescapestring($_GET['Pts2']) . " ',
trail=' " . $this->realescapestring($_GET['Admini']) . " ',
Magnet=' " . $this->realescapestring($_GET['Magnet']) . " ', 
Procedure=' " . $this->realescapestring($_GET['Selection_Procedure']) .  " ',
Experience=' " . $this->realescapestring($_GET['Experience']) .  " ',
System= ' " . $this->realescapestring($_GET['Pedagogic-System']) . " ', 
Qua=' " . $this->realescapestring($_GET['Faculty-Qua']) . " ',
Internet=' " . $this->realescapestring($_GET['Internet']) . " ',
Water-Supply=' " . $this->realescapestring($_GET['Water-Supply']) . " ', 
Electricity=' " . $this->realescapestring($_GET['Electricity']) . " ',
Food=' " . $this->realescapestring($_GET['Food']) . " ',
Cleanness=' " . $this->realescapestring($_GET['Cleanness']) . " ', 
Medical= ' " . $this->realescapestring($_GET['Medical']) . " '
WHERE EMAIL=' ".$_SESSION['cemailid']." ' ";


Re: Syntax Error

Posted: Thu May 19, 2011 2:30 pm
by McInfo
In the query string, there are spaces where there shouldn't be spaces, and spaces missing where there should be spaces. For example, the table name probably is not "xyzSET". Try echoing the query.