Re: SOLVED - [PHP] php-mySQL insert problem
| From: | Adi Zebic | Date: | Tue, 02 Aug 2005 00:27:10 +0000 |
| Subject: | Re: SOLVED - [PHP] php-mySQL insert problem | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-219803@lists.php.net to get a copy of this message | ||
Jack Scott a écrit :
Try this: $insertQuery = "Insert into TABLE ( col_one, col_two )values ( '" . $this -> firstName . "', '" . $this-> lastName . "' )"; $db =& new DB; $res = $db->query($insertQuery); if(DB::isError($res)){Yess! That's the right one :-)exit("Insert query failed: ".__FUNCTION__."() <br>in file".__FILE__."<br>on line ".__LINE__."<br>".$res->getDebugInfo()); }else{return;} you need to have quotes arround your varchar items and you should also specify which column you want the values to go into.
It is also good practice to check if there is an error and try to get the most information available."DB" class do the right thing with try/catch. THANK YOU VERY VERY MUCH Jack Scott! ADI