Strings
| From: | Mick Lloyd | Date: | Sun, 18 Mar 2001 11:51:57 +0000 |
| Subject: | Strings | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-7574@lists.php.net to get a copy of this message | ||
Can anyone advise on how to surround a string variable in a query. I select
a string code from a column using:
$result = mysql_query("SELECT * FROM $TA WHERE Profileid = '$profileid'");
$row = mysql_fetch_array($result);
I then want to extract from a second table an id that relates to the code
from the first query. I've tried various combinations of:
$result = mysql_query("select Primaryid from primarycodes where Code =
'$row[Primaryexpertise]'")
with =, ==, ===, ', \", but always get a syntax error. I can get it to
work with LIKE as follows:
$result = mysql_query("select Primaryid from primarycodes where Code like
'%$row[Primaryexpertise]%'")
but I need greater accuracy because some codes contain similar data. String
manipulation has me baffled most of the time!
Thanks.
Mick Lloyd
mjl@consultingrooms.com
Tel: +44 (0)1684 560224