Re: Inserting a variable into a mysql_query() statement
| From: | Jason Wong | Date: | Tue, 15 Oct 2002 09:02:33 +0000 |
| Subject: | Re: Inserting a variable into a mysql_query() statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-119995@lists.php.net to get a copy of this message | ||
On Tuesday 15 October 2002 12:54, Phil Clark wrote:
> I'm trying to insert the variable $hidden_manuf_id into a mysql_query()
> statement.
>
> If i do this:
> mysql_query("DELETE FROM product WHERE manufacturer=$hidden_manuf_id",$bb)
> or die(mysql_error());
That should work iff manufacturer is a number. Otherwise you need
single-quotes:
"DELETE FROM product WHERE manufacturer='$hidden_manuf_id'"
> PHP server doesn't see the variable because it is inside the string
> quotes"".
Actually you DO need the double-quotes in order for PHP interpret
$hidden_manuf_id as a variable.
What you really should do is split the above into two steps:
$query = "DELETE FROM product WHERE manufacturer=$hidden_manuf_id";
mysql_query($query, $bb) or die("Error in $query :: " . mysql_error());
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Check me if I'm wrong, Sandy, but if I kill all the golfers...
they're gonna lock me up and throw away the key!
*/