Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT variable error

Status
Not open for further replies.

akaballa123

Technical User
Apr 29, 2008
46
US
Hi I am trying to create a specifice sql statement and keep on receiving this error:


Parse error: syntax error, unexpected T_VARIABLE



Code:
$orgName = $row['orgName'];
           $content3 .= '<tr><td align="center">' . $orgName ;
           $trainingOrg = @mysql_query('SELECT trainingName FROM addtrainingtbl WHERE organization = '$orgName'');

It seems there is something wrong with my sql variable. Thanks!
 
Not sure this is a MySQL problem you might do better to post in the appropriate forum for the programming language -is it perl?
My guess is that the problem comes from
'$orgName''
and how this gets interpreted by the programming language
Try
Code:
$qry='SELECT trainingName FROM addtrainingtbl WHERE organization = '$orgName'';
print $qry;
$trainingOrg = @mysql_query($qry);
I think you will need to escape the quotes
\'$orgName\'
 
Its a PHP issue. you can't have single quotes inside single quotes and expect it to work, try either back ticks or double quotes there.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Ye, I included the escape characters, and it worked. Thanks Guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top