I am currently working on a bit of code to retrieve information from a mysql server through php to be used in an android application using JSON. Unfortunately it appears i am running into errors within my PHP script`
<?php
mysql_connect("xxx","xxx","xxx"); // edited out details
mysql_select_db("a2275354_gtchose");
$sql=mysql_query("select FName,LName from TEST where UserId=‘".$_REQUEST['userId']."‘");
while($row=mysql_fetch_assoc($sql)) $output[]=$row;
print(json_encode($output));
mysql_close();
?>`
The request for the userId is supplied by a NameValuePairs variable.
the error im recieving is:
System.out(331): Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a2275354/public_html/test.php on line 4
Anyone know what the problem is?
First of all you are open to SQL injection, it would be wise to learn about escaping your variables in SQL queries
mysql_escape_string()will probably help you here.And to the main issue:
Original:
Correct:
Notice the differences in the characters enveloping the
".$_REQUEST['userId']."It seems you copied the query from an RTF document of sorts so instead of
'you wrote‘