Jump to content

[SOLVED] Mysql Not Submitting Anything


imdead

Recommended Posts

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();

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Ok thanks for such quick help guys :D

 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.