RE: [PHP-DB] mysql Insert

From: Date: Wed, 07 Nov 2001 14:32:20 +0000
Subject: RE: [PHP-DB] mysql Insert
Groups: php.db 
Request: Send a blank email to php-db+get-14096@lists.php.net to get a copy of this message
yep, it's always a good idea if you're having problems to print the query to the browser, then see exactly what your code is trying to do to the database! -----Original Message----- From: Rick Emery [mailto:remery@excel.com] Sent: 07 November 2001 14:31 To: 'Brad Harriger'; 'php-db@lists.php.net' Subject: RE: [PHP-DB] mysql Insert 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 -- 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 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.291 / Virus Database: 156 - Release Date: 25/10/01 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.291 / Virus Database: 156 - Release Date: 25/10/01

« previous php.db (#14096) next »