Re: More on strings
| From: | Mick Lloyd | Date: | Tue, 20 Mar 2001 15:36:43 +0000 |
| Subject: | Re: More on strings | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7649@lists.php.net to get a copy of this message | ||
Darryl
Thanks for the reply. I tried the variable route but again failed. I think
from your suggested line of code you may have misunderstood the problem. The
LIKE option works fine without having to put it into a variable.
$sql = "select Primaryid from primarycodes where Code =
'$row[Primaryexpertise]'";
print $sql."<BR>\n";
\\Prints: select Primaryid from primarycodes where Code = 'Biology' \\which
seems OK
$resultp = mysql_query($sql) or die ("Failed"); \\This seems to work
$pcodeid = mysql_fetch_array($resultp) or die("No pcodeid");
\\Prints: No pcodeid \\ie failed
Regards
Mick Lloyd
mjl@consultingrooms.com
Tel: +44 (0)1684 560224
----- Original Message -----
From: Darryl Friesen <Darryl.Friesen@usask.ca>
To: Database Help PHP <php-db@lists.php.net>
Sent: Tuesday, March 20, 2001 1:41 PM
Subject: Re: [PHP-DB] More on strings
> > $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 Darryl.Friesen@usask.ca
> 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: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>