For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > June 2006 > Re: [PHP-DB] Inserting Data into MySQL database









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Inserting Data into MySQL database
dpgirago@mdanderson.org

2006-06-17, 8:04 am


> 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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com