Sorry guys, I have tried all the suggestions so far with no luck.....Mark - After the mysql_query($query); line.... add the following line
Regards, Mark
try to include field name: $query = "INSERT INTO contacts(first,$last,phone,mobile,fax,email,web) VALUES ('$first','$last','$phone','$mobile','$fax','$email','$web')"; mysql_query($query); _______________________________ rgds [xm]
I am following the tutorial at http://www.freewebmasterhelp.com/tutorials/phpmysql/
The source code is on the website on the left hand side http://www.freewebmasterhelp.com/static/tutorials/phpmysql/example.zip
My software: PHP version 4.3.4 on Windows 2000 MYSQL version 4.0.16 on Windows 2000 Apache version 1.3.29 on Windows 2000
The problem is I cannot get the database to add a new records aside from the auto-increment field. All the other fields are left blank when the add.html is subitted.
I have the add.html with the following code exactly the same as the source code.
<form action="insert.php" method="post"> First Name: <input type="text" name="first"><br> Last Name: <input type="text" name="last"><br> Phone: <input type="text" name="phone"><br> Mobile: <input type="text" name="mobile"><br> Fax: <input type="text" name="fax"><br> E-mail: <input type="text" name="email"><br> Web: <input type="text" name="web"><br> <input type="Submit"> </form>
The insert.php
<?
include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO contacts VALUES ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);
mysql_close(); ?>
Any help would be much appreciated.
Regards,
Mark
echo mysql_error();
run the script and try to add something again, if there is an error, it will tell you via mysql_error(); echo it out to the browser, and get back to me :)
Rolf Brusletto http://www.phpExamples.net
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php