I have a script where I am just trying to return information when I send in an id via ajax to a php script, query the DB and return the name associated with the id.
Here is the php:
$userId = $_REQUEST['id'];
// Make a MySQL Connection
require('/php/dbconnect.php');
$sql="SELECT * FROM member WHERE id='".$userId."'";
$result = mysql_query($sql) or die(mysql_error());
$returnJson = '{';
while ($row = mysql_fetch_array($result)) {
$returnJson .= 'userName: "' . $row['userName'] . '"';
}
$returnJson .= '}';
echo $returnJson;
I have 2 records in the member table. The primary id's are 1 and 2. When I request this page via ajax and pass in either 1 or 2 as parameter "id" I don't get the name back.
All that is returned is "{}";
I know that everything is working on the front-end because I get atleast get "{}" back.
I have checked that there is a column named "userName" in the DB. I also know that my connection to the DB works as no mysql errors return, and (using the same db connect script) I can write to the member table just fine.
Any ideas why this is not returning anything.