I am trying to do a full text search using PDO with a parameter.
If I use the sql query with a constant variable, the select works, and it returns the correct list from the MySQL database.
But the code I have to select on a parameter does not return anything.
Here is my code:
<?php
$conn = new PDO ("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$val = $_REQUEST['val'];
$sth = $conn ->prepare('SELECT UserID FROM Users WHERE MATCH (First, Last) AGAINST (:val IN BOOLEAN MODE');
$sth->execute(array(':val' => $val));
$friends = $sth->fetchAll(PDO::FETCH_ASSOC);
$json=json_encode($friends);
echo $json;
?>
From my app I call the above function as follows:
smUID = [NSString stringWithFormat:@"http://www.myServerName.co.uk/searchQuery.php?val=%@", searchString];
dataSMURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:smUID]];
smUIDResult = [[NSString alloc] initWithData:dataSMURL encoding:NSUTF8StringEncoding];
I don't think my PDO is right as it is not returning any values, but I can't see what is wrong or what else it needs.