Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am annoyingly confused here. I have been trying to solve this issue, but oddly enough I realize it was not under a single directory, it is actually my entire web server that faces this problem. I cannot in any way get, insert, or update more than one value at a time on any NEW document I create, which confuses me why it still works on old ones, but not on new ones. I have even copied the old ones to the new document and done nothing but alter the table it inserts into (with all the same values) and it produces a simple error stating '
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 'Key='AB123', IGN='test' WHERE Name='testuser'' at line 1
'.

The entire code is below:
PHP
session_start();
$name = $_POST['name'];
    $appkey = $_POST['appkey'];
    $usrname = $_POST['username'];
    $birthday = $_POST['BirthMonth'] . "." . $_POST['birthday'] . "." . $_POST['birthyear'];
    $gender = $_POST['Gender'];
    $skype = $_POST['phone'];
    $exp = $_POST['exp'];
    $why = $_POST['why'];
    include('db.php');
    mysql_query("INSERT INTO query (Name, Key, IGN) VALUES ('$name', '$appkey', '$usrname')") or die(mysql_error());


(Yes, it is all in the proper tags. )

There is no answer I can find online, and everything I try to fix it does nothing. I do not want to have a long string Inserting the values.

EDIT: I have echoed the string and it results as the entire 'INSERT INTO query (Name, Key, IGN) VALUES ('$name', '$appkey', '$usrname')' string, with no problem.

Solution: I did not realize that the tag 'query' & 'Name' are protected, so finally after a few minutes with my IT teacher she help me into the right direction.
Posted
Updated 1-Oct-13 9:47am
v3
Comments
ZurdoDev 30-Sep-13 17:11pm    
The error says the syntax is wrong. I don't do MySql but I see 2 ' at the end.
Trennon Dunn 30-Sep-13 17:18pm    
thats actually from the error. it quoted what was wrong, so really it was Key='AB123', IGN='test' WHERE Name='testuser'
ZurdoDev 30-Sep-13 20:33pm    
Then I would look at the whole statement. It says near Key... which may mean before it.
enhzflep 30-Sep-13 17:36pm    
That error message doesn't appear to match the posted code to me.
The error message contains the WHERE keyword, yet your sql does not.

A good exercise can be to echo the sql query string to the screen before running it, so that you can copy/paste the generated query string into myPhpAdmin for debugging purposes.

An even better exercise is to look into PDO or MySqli (PDO is the better option)
http://net.tutsplus.com/tutorials/php/pdo-vs-mysqli-which-should-you-use/
Trennon Dunn 30-Sep-13 18:13pm    
did that. echos what it should but still provides an error

1 solution

Edition of the OP with solution copied here to avoid having the question as unanswered
Solution: I did not realize that the tag 'query' & 'Name' are protected, so finally after a few minutes with my IT teacher she help me into the right direction.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900