Re: Inserting Variables
| From: | Andrey Hristov | Date: | Tue, 09 Oct 2001 14:30:22 +0000 |
| Subject: | Re: Inserting Variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70490@lists.php.net to get a copy of this message | ||
The inserts works in this way because they are
mysql_query('INSERT .... ("$q1..... ');
the surounding ' says to php to not look at the string for variable
substitution. Try
mysql_query("INSERT .... ('$q1'.... ");
that will work as you wish
--
Andrey Hristov
Web Developer
IcyGEN Corporation
BALANCED SOLUTIONS
http://www.icygen.com
On Tuesday 09 October 2001 17:24, you wrote:
> Pardon me if your code was just shorthand but:
>
> When I set $sqlstatement = INSERT INTO tdefa8 VALUES ("$q1", "$q2",
> "2001-10-09")
> THEN it inserts "$q1" and "$q2" into the database - rather than their
> assigned values
>
> When I set $sqlstatement = INSERT INTO tdefa8 VALUES ($q1, $q2,
> "2001-10-09")
> THEN it doesn't insert ANYTHING
>
> FYI: I execute the statement like this:
> $query = "$sqlstatement";
> $result = MYSQL_QUERY($query);
>
> I even tried: $query = $sqlstatement;
>
> try:
>
> $sqlstatement = "INSERT INTO tdefa8 VALUES ('$q1', '$q2',
> '2001-10-09')";
>
> or
>
> $sqlstatement = "INSERT INTO tdefa8 VALUES (\"$q1\",\"$q2\",
> \"2001-10-09\")";
>
> both work for me.
>
> Thanks,
>
> Wade Berlin, Backstreet Production Group Inc.
>
> ----------------------------------------------
> Backstreet Production Group......www.bpweb.com
> 904.398.8730................(fax) 904.396.0335
> ----------------------------------------------