Re: sql syntax error
| From: | 1LT John W. Holmes | Date: | Wed, 29 Jan 2003 11:24:46 +0000 |
| Subject: | Re: sql syntax error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25224@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Addison Ellis" <addison@bellsouth.net>
To: <php-db@lists.php.net>
Sent: Tuesday, January 28, 2003 10:46 PM
Subject: [PHP-DB] sql syntax error
> hello,
> i can not pinpoint this. your time and help is very much
> appreciated. best, addison
>
> Error:
> id=, HTTP_POST_VARS=Array, key=, value=, category=, subcategory=,
> logname=addison@bellsouth.net
> Error in query: insert into ads values
>
(year,make,model,color,mileage,condition,price,other,contact,next_,,created)
> values ('',,NOW()),Error:You have an error in your SQL syntax near
> 'created) values ('',,NOW())' at line 1
>
> Code:
> else
> {
> foreach($HTTP_POST_VARS as $column_name => $column_value)
>
> $column_names .= $column_name . ',';
> $column_values .= "'$column_values',";
>
> $query = "insert into ads values ($column_names,created)
> values ($column_values,NOW())";
> $result = mysql_query($query)
> or die ("Error in query: $query,Error:"
.mysql_error());
> }
Try this:
foreach($HTTP_POST_VARS as $column_name => $column_value)
{
$column_names .= $column_name . ',';
$column_values .= "'$column_value',";
}
$query = "insert into ads values ($column_names created)
values ($column_values NOW())";
$result = mysql_query($query)
or die ("Error in query: $query,Error:"
.mysql_error());
I still don't think it's going to work for you. do you really have a column
called 'next_' in your table? It's probably the button you pressed to submit
the form, which is in HTTP_POST_VARS, but I don't see a reason it would be
in your table...
---John Holmes...