Re: Parse Error on SQL Insert

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mi vote goes to the curly braces

The error is given by php, not by SQL

When exploding variables within double quotes it is hard for php to distinguish when a variable end unless it is a simple variable like $foo. When it is an array element and even worst, when it is an element of a multidimensional array, php cannot assert when it is over (really, it is not a bug, try to figure out how to do it and you'll see it is not easy) so you tell php by enclosing the whole variable in curly braces.

Which it says so in the manual

Satyam
----- Original Message ----- From: "Chrome" <admin@xxxxxxxxxxxx> To: "'Joe Henry'" <jhenry@xxxxxxxxxxxxxxxxxxx>; <php-general@xxxxxxxxxxxxx>; <tom@xxxxxxxxxxxxxx>
Sent: Friday, April 07, 2006 9:56 PM
Subject: RE:  Parse Error on SQL Insert


Backticks (`) encapsulate table or database names

I was thinking maybe if the array references were encapsulated in curly
braces {}:

$_POST['model'] to {$_POST['model']}

Of course if the field in the DB isn't numeric this would be
'{$_POST['model']}'

Dan

-------------------
http://chrome.me.uk


-----Original Message-----
From: Joe Henry [mailto:jhenry@xxxxxxxxxxxxxxxxxxx]
Sent: 07 April 2006 20:53
To: php-general@xxxxxxxxxxxxx; tom@xxxxxxxxxxxxxx
Subject: Re:  Parse Error on SQL Insert

On Friday 07 April 2006 1:37 pm, Tom Chubb wrote:
$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,

Not sure if this is your problem, but those look like backticks around year
instead of single quotes. Should there even be quotes there?

HTH
--
Joe Henry
www.celebrityaccess.com
jhenry@xxxxxxxxxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


__________ NOD32 1.1475 (20060406) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux