syntax?

From: Date: Thu, 13 Sep 2001 07:58:38 +0000
Subject: syntax?
Groups: php.general 
Request: Send a blank email to php-general+get-67159@lists.php.net to get a copy of this message
HI, I am new to this PHP thing. I was working out of my PHP book and website and I noticed some discrepancies in inputting data into the MySQL database. I followed the example from my book and I noticed that the syntax for putting data into a mysql database from PHP was like this: $sql = "INSERT INTO news VALUES (NULL,'$heading','$body','$date','$auth','$auth_email')"; However I read some information on the website and I noticed that they added the field names right after the name of the table like this: mysql_query ("INSERT INTO tablename (first_name, last_name) VALUES ('$first_name', '$last_name') "); I have two questions: In the first example what is the meaning of putting the "NULL" before the variables? I was successful in entering data from my first example without declaring field names, so why did they declare in field names in the second example? If anyone can shed some light on this question, I would be most grateful. Thanks. Peter

« previous php.general (#67159) next »