Re: A very simple MySQL + PHP error
| From: | Hugh Bothwell | Date: | Sun, 08 Jul 2001 19:26:59 +0000 |
| Subject: | Re: A very simple MySQL + PHP error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-10153@lists.php.net to get a copy of this message | ||
"Brad Lipovsky" <syzme@home.com> wrote in message
news:20010708182828.84349.qmail@pb1.pair.com...
> I get the following error:
>
> $Query = "SELECT * from $TableName WHERE title LIKE "%$title%")";
If you tried 'echo $Query' right here, you wouldn't see anything.
Try 'echo "305" % "300";'
You begin to see the problem, right? You used double quotes within your
string without escaping them (ie \") - so PHP treated it as the end of the
string. You would have gotten an error message, except that % is PHP's
modular division operator - so it tried to convert the strings to numbers
and do modular division on them.
How 'bout
$query = "SELECT * FROM $table WHERE title LIKE '%$title%' ";