[PHP-DB] More on strings

2001-03-20 Thread Mick Lloyd

I thought I had it but I didn't! I can only get LIKE to perform queries that
allow me use the result for a subsequent query but for accuracy, I need to
use actual values. The first statement below works OK (at least I get a
Resource id #) - courtesy of help received here - but will not return
$pcodeid from the third statement - it dies giving me "No pcodeid". Using
the LIKE version (second one below) works fine and I can use the $pcodeid
array elements as I like. Any thoughts gratefully received.

 $resultp = mysql_query("select Primaryid from primarycodes where Code =
'".$row['Primaryexpertise']."'") or die (mysql_error());

 $resultp = mysql_query("select Primaryid from primarycodes where Code like
'%$row[Primaryexpertise]%'") or die (mysql_error());

 $pcodeid = mysql_fetch_array($resultp) or die("No pcodeid");


Regards

Mick Lloyd
[EMAIL PROTECTED]
Tel: +44 (0)1684 560224


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] More on strings

2001-03-20 Thread Darryl Friesen

  $resultp = mysql_query("select Primaryid from primarycodes where Code =
 '".$row['Primaryexpertise']."'") or die (mysql_error());

  $resultp = mysql_query("select Primaryid from primarycodes where Code
like
 '%$row[Primaryexpertise]%'") or die (mysql_error());

  $pcodeid = mysql_fetch_array($resultp) or die("No pcodeid");

Two suggestions.:

First, stick the query into a variable instead of using it directly; that
way you can do some simple debugging (i.e. print the query to the page
instead of posting this email).  Second, take the array variable out of the
double quotes, like you did in the first line.

$sql = "select Primaryid from primarycodes where Code like'%" .
$row[Primaryexpertise] . "%'";
print $sql . "BR\n";
$resultp = mysql_query($sql) or die (mysql_error());


- Darryl

 --
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]