RE: [PHP-DB] mysql Insert
| From: | Rick Emery | Date: | Wed, 07 Nov 2001 14:30:37 +0000 |
| Subject: | RE: [PHP-DB] mysql Insert | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-14094@lists.php.net to get a copy of this message | ||
That is, it will crash and burn if you do NOT use the quotes around $name.
-----Original Message-----
From: Rick Emery
Sent: Wednesday, November 07, 2001 8:27 AM
To: 'Brad Harriger'; php-db@lists.php.net
Subject: RE: [PHP-DB] mysql Insert
I'm going to assume that $name is text. If so, it must be enclosed in
quotes:
$result = mysql_db_query("MyDBTest","INSERT INTO Test
VALUES(\"$name\")");
I'd suggest:
$query = "INSERT INTO Test VALUES(\"$name\")";
print $query;
$result = mysql_db_query("MyDBTest", $query) or die("Error:
".mysql_error());
The print statement displays your query text. Copy/Paste it into the mysql
command line. It should crash and burn quite nicely.
-----Original Message-----
From: Brad Harriger [mailto:bradharriger@clarionhospital.org]
Sent: Wednesday, November 07, 2001 8:15 AM
To: php-db@lists.php.net
Subject: [PHP-DB] mysql Insert
When I execute the line
$result = mysql_db_query("MyDBTest","INSERT INTO Test VALUES($name)");
I receive the following error
Unknown column 'Jeff' in 'field list'
I'm not sure why I'm getting the error. I've verified that the
parameters in the mysql statement are correct. There is only one column
in the table. "Jeff" (without the quotes) is the value of $name when it
reaches the statement. Any help would be appreciated.
Thanks in advance,
Brad
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net