1

I seem to not be inserting data into fields properly. The fields and tables all exists and I'm positive that I'm connecting to the database correctly. The fields all remain empty :(

  $query = ("INSERT INTO 'users' (phone) VALUES ('$phone') WHERE username='$userid'");
  mysql_query($query);
1
  • 1
    if that is the exact query you are sending try to replace the single quotes around the table name with a ` like so: `users` Commented May 30, 2011 at 15:26

3 Answers 3

4

INSERT doesn't have a WHERE in it's syntax:

http://dev.mysql.com/doc/refman/5.5/en/insert.html

Sign up to request clarification or add additional context in comments.

Comments

3

You should use update query :

  $query="UPDATE users
    SET phone='$phone'
    WHERE username='$userid'";

1 Comment

+1 It definitely looks like the OP is mistaking an INSERT for an UPDATE.
0

You should be using update....

mysql_select_db("my_db", $con);

mysql_query("UPDATE Persons SET Age = '36'
WHERE FirstName = 'Peter' AND LastName = 'Griffin'");

mysql_close($con);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.