imdead Posted April 25, 2008 Share Posted April 25, 2008 Hey Guys, Im Working on a script for a client although i'm stuck i cant find the error i even tried echo'ing out the INSERT values to see if they were the problem but there not Please Help Thanks Signup <form action="tregister.php" method="post"> <p>First Name: <input type="text" name="first" size="10"></p> <p>Username: <input type="text" name="username" size="10"></p> <p>Password: <input type="password" name="password" size="10"></p> <p>Second Name: <input type="text" name="second" size="10"></p> <p>Address: <input type="text" name="address" size="20"></p> <p>Email: <input type="text" name="email" size="20"></p> <p>What Is Your Current Job? <input type="text" name="job" size="15"></p> <p>Current Salary? <input type="text" name="salary" size="10"></p> <p>What Would You Like To Do? <input type="text" name="like" size="10"></p> <p>Salary Expectations? <input type="text" name="salarye" size="10"></p> <p>Do You Have Your Own Transport? <input type="text" name="transport" size="10"></p> <p>Contact Number: <input type="text" name="contact" size="15"></p> <p><input type="submit" value="Submit" name="submit"></p> </form> Takesignup $id = mysql_insert_id(); $first = $_POST["first"]; $username = $_POST["username"]; $password = $_POST["password"]; $second = $_POST["second"]; $address = $_POST["address"]; $email = $_POST["email"]; $job = $_POST["job"]; $salary = $_POST["salary"]; $like = $_POST["like"]; $salarye = $_POST["salarye"]; $transport = $_POST["transport"]; $contact = $_POST["contact"]; //insert the values $result = @mysql_query("INSERT INTO users (id, first, username, password, second, address, email, job, salary, like, salarye, transport, contact) VALUES ($id, $first, $username, $password, $second, $address, $email, $job, $salary, $like, $salarye, $transport, $contact)"); if (mysql_affected_rows() == 1) print "You have successfully registered and may now login"; else print mysql_error(); Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/ Share on other sites More sharing options...
MadTechie Posted April 25, 2008 Share Posted April 25, 2008 change $result = @mysql_query("INSERT INTO users (id, first, username, password, second, address, email, job, salary, like, salarye, transport, contact) VALUES ($id, $first, $username, $password, $second, $address, $email, $job, $salary, $like, $salarye, $transport, $contact)"); to $result = mysql_query("INSERT INTO users (id, first, username, password, second, address, email, job, salary, like, salarye, transport, contact) VALUES ($id, '$first', '$username', '$password', '$second', '$address', '$email', '$job', '$salary', '$like', '$salarye', '$transport', '$contact')") or die(mysql_error()); Should reveal the error (or more info atleast) EDIT: also added the quotes Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527247 Share on other sites More sharing options...
dptr1988 Posted April 25, 2008 Share Posted April 25, 2008 Have your tried echoing the query and checking if it's correct? Example: <?php $query = "INSERT INTO users (id, first, username, password, second, address, email, job, salary, like, salarye, transport, contact) VALUES ($id, $first, $username, $password, $second, $address, $email, $job, $salary, $like, $salarye, $transport, $contact)"; echo $query; $result =mysql_query($query); ?> Also, why are you suppressing errors on the mysql_query() function? What error messages are you getting? Do you even have a mysql connection? Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527249 Share on other sites More sharing options...
imdead Posted April 25, 2008 Author Share Posted April 25, 2008 Ok thanks i now get the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like, salarye, transport, contact) VALUES (0, Kevin, kevski, PASSSSWORDD, LASTNAME,' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527260 Share on other sites More sharing options...
dptr1988 Posted April 25, 2008 Share Posted April 25, 2008 the word 'like' is a mysql keyword You need to quote that column name in backticks(`) Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527264 Share on other sites More sharing options...
MadTechie Posted April 25, 2008 Share Posted April 25, 2008 also you need to quotes your values! Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527265 Share on other sites More sharing options...
imdead Posted April 25, 2008 Author Share Posted April 25, 2008 Ok thanks for such quick help guys i've changed the code to $result = mysql_query("INSERT INTO users (id, first, username, password, second, address, email, job, salary, like, salarye, transport, contact) VALUES (`$id`, `$first`, `$username`, `$password`, `$second`, `$address`, `$email`, `$job`, `$salary`, `$like`, `$salarye`, `$transport`, `$contact`)") or die(mysql_error()); if (mysql_affected_rows() == 1) print "You have successfully registered and may now login"; else print mysql_error(); And now im recieving this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like, salarye, transport, contact) VALUES (`0`, `Kevin`, `kevski`, `PASSsWORD`, ' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527289 Share on other sites More sharing options...
dptr1988 Posted April 25, 2008 Share Posted April 25, 2008 the field name 'like' is still not quoted. It should be like this <?php $result = mysql_query("INSERT INTO users (id, first, username, password, second, address, email, job, salary, `like`, salarye, transport, contact) VALUES (`$id`, `$first`, `$username`, `$password`, `$second`, `$address`, `$email`, `$job`, `$salary`, `$like`, `$salarye`, `$transport`, `$contact`)") or die(mysql_error()); ?> It would be even better if you could rename the field 'like' to some other name. It is not a good idea to use mysql reserved words for field names Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527292 Share on other sites More sharing options...
imdead Posted April 25, 2008 Author Share Posted April 25, 2008 ah ok i changed it to the code above and now the error is Unknown column '0' in 'field list' Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527296 Share on other sites More sharing options...
dptr1988 Posted April 25, 2008 Share Posted April 25, 2008 Have you tried looking at the echoed query as described in this message: http://www.phpfreaks.com/forums/index.php/topic,194387.msg875311.html#msg875311 Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527298 Share on other sites More sharing options...
MadTechie Posted April 25, 2008 Share Posted April 25, 2008 the field name 'like' is still not quoted. It should be like this <?php $result = mysql_query("INSERT INTO users (id, first, username, password, second, address, email, job, salary, `like`, salarye, transport, contact) VALUES (`$id`, `$first`, `$username`, `$password`, `$second`, `$address`, `$email`, `$job`, `$salary`, `$like`, `$salarye`, `$transport`, `$contact`)") or die(mysql_error()); ?> No it should be like this $result = mysql_query("INSERT INTO `users` (`id`, `first`, `username`, `password`, `second`, `address`, `email`, `job`, `salary`, `like`, `salarye`, `transport`, `contact`) VALUES ('$id', '$first', '$username', '$password', '$second', '$address', '$email', '$job', '$salary', '$like', '$salarye', '$transport', '$contact')") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527302 Share on other sites More sharing options...
imdead Posted April 25, 2008 Author Share Posted April 25, 2008 Fixed it Thanks alot guys! Quote Link to comment https://forums.phpfreaks.com/topic/102928-solved-mysql-not-submitting-anything/#findComment-527304 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.