Jump to content

Problem with searchstring in php


zulubanshee

Recommended Posts

I have a search string that keeps returning 1064 error. Here it is:

"SELECT link FROM links WHERE id_person_fk IN  (select id from person where name LIKE  '$personname'";

 

The $personname string is like this "firstname lastname"

id_person_fk is a foreign key, if that matters.

I can get this search to work if i type it in straight sql and fill in the personname explicitly, but I cannot get it to work in a php script with a variable. There are no extra space characters at the end or beginning of the string. 

I suspect the problem lies in the fact that there is a space in the person name, but I can't confirm. personname in the person table is a varchar data type, if that matters.

Link to comment
https://forums.phpfreaks.com/topic/220018-problem-with-searchstring-in-php/
Share on other sites

Have you echoed the query string to the browser to make sure it's formed as you'd expect it to be formed? Since the query executes when hard coded, this is unlikely to be a MySQL issue, so moving thread to PHP Help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.