nomadsoul Posted July 26, 2009 Share Posted July 26, 2009 I've been struggling with my insert.php script. It won't insert into the users table. However it will from the command line. Would anyone be kind enough to look at my insert statement in the insert.php script below? I've also included the submit form. I'm just trying to keep it simple for now. //This works: mysql> insert into users (first_name, last_name, email, registration_date)values ('krunk','krunk','krunk@krunk.com',NOW()); Query OK, 1 row affected (0.00 sec) //My insert.html <form action="insert.php" method="post"> <p>First Name: <input type="text" name="first_name" size="15" maxlength="20" > <p>Last Name: <input type="text" name="last_name" size="15" maxlength="40" > </p> <p>Email Address: <input type="text" name="email" size="20" maxlength="80" > </p> <p><input type="submit" name="submit" value="Register" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form> Here is the insert.php: <?php $con = mysql_connect("MySQL.host.com","myuname","mypword"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db-language", $con); //Is this correct? $sql="INSERT INTO users (first_name, last_name, email,registration_date) VALUES ('$_POST[first_name]','$_POST[last_name]','$_POST',NOW() )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
Coreye Posted July 26, 2009 Share Posted July 26, 2009 Hey, I just tested that script and it ran fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.