Heyo.. I'm having a bit of trouble using mysql_query... I'm not getting an error, its just giving me the die message. Here is the piece of code that i think is the problem:
<?php
mysql_query("INSERT INTO test (username, password, email, rank) VALUES ('$username', '$password', '$email', '$rank') WHERE id='$id'", $link) or die("Could not write information");
?>
Im trying to write the information into the row which has the id number of the account i was modifying, so i put WHERE id='$id' to tell it where to place it. Im not sure if im misusing it or not, but id appeciate it if someone could fix this.
mysql_query("INSERT INTO test (username, password, email, rank) VALUES ('".$username."', '".$password."', '".$email."', '".$rank."') WHERE id='$id'", $link) or die("Could not write information");
Basically use this syntax: '".$username."' instead of '$username'.
Where does the $id variable comes from? If this is sent from a link at the page before the script, you must retrieve the information with $_GET['id'] if your global variables are turned off.
If this doesn't solve you problem, please post some of the code from the document before this script.
+ in the your die sentence you can input mysql_error(). This will output more detailed info about whats wrong to the browser.
You have an error in your SQL syntax near 'WHERE (id='14')' at line 1
This is what its giving me now, i know the ID is passing because its displaying the number.... I specifically need that part so it knows which row to modify, because without it, it just creates a new account.. Do you think it would just be simpler to delete the old row and remake it as a new one? Yea.. im going to try that..
It looks like you're trying to update an existing record. The INSERT command will try to insert a new row into the table. Try using the UPDATE command instead. For example:
mysql_query("UPDATE test SET username='$username', password='$password', email='$email', rank='$rank' WHERE id='$id'", $link) or die("Could not write information");