mikhl Posted December 12, 2010 Share Posted December 12, 2010 Hi, I'm having trouble adding data to the database (test) that i created. I just can't see where I'm going wrong. need some other peoples opinions. I have tried taking the id out of the SQL statement completely as it is an auto increment, but that doesn't seem to work either. Thanks in advance... <?php $fname = $_POST['fname']; $sname = $_POST['sname']; $email = $_POST['email']; $pword = $_POST['password']; $gender = $_POST['gender']; $user_name = "root"; $password = ""; $database = "test"; $server = "127.0.0.1"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO members (id, fname, sname, email, password, gender) VALUES (NULL, $fname, $sname, $email, $pword, $gender);"; $result = mysql_query($SQL); mysql_close($db_handle); print "Thanks for joining us ".$fname."."; print "<br /><br />"; print $fname . "<br />"; print $sname . "<br />"; print $email . "<br />"; print $pword . "<br />"; print $gender . "<br />"; } else { print "Database NOT Found"; mysql_close($db_handle); } ?> Quote Link to comment Share on other sites More sharing options...
Anti-Moronic Posted December 12, 2010 Share Posted December 12, 2010 How are you having trouble? Are you receiving any errors? One thing, don't use the id in the query if it is auto-incremented. And, server is usually 'localhost' not your local ip address. Can you connect to the database? Have you got anything similar working? We need to know exactly what you see - turn on error reporting to full. <?php error_reporting(-1); ?> and see if any errors come up. Quote Link to comment Share on other sites More sharing options...
mikhl Posted December 12, 2010 Author Share Posted December 12, 2010 How are you having trouble? Are you receiving any errors? One thing, don't use the id in the query if it is auto-incremented. And, server is usually 'localhost' not your local ip address. Can you connect to the database? Have you got anything similar working? We need to know exactly what you see - turn on error reporting to full. <?php error_reporting(-1); ?> and see if any errors come up. Done the error reporting and made no difference. I can connect to the database and have a script that displays all the contents of the members table (which is the table that i am trying to enter data into), I entered this data through PHP My Admin GUI. I'm not recieving any errors, its displaying the 'well done your entered into the database' type message from the success part of the IF statement, but not actually doing it. 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.