Re: [PHP-DB] Inserting Data into MySQL database
Am Donnerstag, 15. Juni 2006 22:42 schrieb Girish Agarwal: Hi All, I have a table in mySQL database 5.0 the structure of which is as follows ssno INT 9, lname VARCHAR(15) NOT NULL, fname VARCHAR(15) NOT NULL, I am inserting the values using $query = insert into student (ssno,lname,fname) VALUES ('.$student['ssno'].','.$student['lname'].','.$student['fname'].'); $query = INSERT INTO student (ssno,lname,fname) VALUES (12345,'',''); This Query is working Fine but the only Problem I have is that if the lname and fname values are NULL then how come it does not return an error but instead adds the record into the database. You pass emtpy strings. ('') Try this $query = INSERT INTO student (ssno,lname,fname) VALUES (12345,NULL,NULL); Best Regards, Oliver -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Inserting Data into MySQL database
Hi All, I have a table in MySQL database 5.0 the structure of which is as follows ssno INT 9, lname VARCHAR(15) NOT NULL, fname VARCHAR(15) NOT NULL, I am inserting the values using $query = insert into student (ssno,lname,fname) VALUES ('.$student['ssno'].','.$student['lname'].','.$student ['fname'].'); This Query is working Fine but the only Problem I have is that if the lname and fname values are NULL then how come it does not return an error but instead adds the record into the database. Is it because I am not passing the values properly. Please Help Thanks, Girish Try; show create table _tablename_; from inside the mysql client. It will display what values are being inserted as a default. Remember: null and an empty string are not the same thing. David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Inserting Data into MySQL database
Hi All, I have a table in MySQL database 5.0 the structure of which is as follows ssno INT 9, lname VARCHAR(15) NOT NULL, fname VARCHAR(15) NOT NULL, I am inserting the values using $query = insert into student (ssno,lname,fname) VALUES ('.$student['ssno'].','.$student['lname'].','.$student ['fname'].'); This Query is working Fine but the only Problem I have is that if the lname and fname values are NULL then how come it does not return an error but instead adds the record into the database. Is it because I am not passing the values properly. Please Help Thanks, Girish TYPOS, SORRY - DPG Try: mysql show create table _tablename_; from inside the mysql client. It will display what values are being inserted as a default. Remember: null and an empty string are not the same thing. David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Inserting data into MySQL
yes, or you need to use the 'INSERT INTO ([field1, field2...]) values (['val1', 'val2'...]) syntax. check the mysql insert syntax. http://www.mysql.com/doc/en/INSERT.html - john On Sat, Mar 15, 2003 at 06:37:54PM -0500, Louie Henry [EMAIL PROTECTED] wrote: Good Day All! I have been working a php/mysql and I have ran into a small problem. I have written an html form for inserting data, and it will not insert it. I am able to query the data from the data. I here is some of the code, maybe some one could point out the error. __ $query = INSERT into TBLutnsUser values ( .$fname., .$lname., .$email., .$phonenum., .$celnum., .$address., .$city., .$prov., .$postalcode.); __ There is one other field that is not in here, that is userIndex. and it is the indexing/primary key, and it is auto_increment. dose it need to be added in here too? Thank You -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php