SQL Query Help
#1

What's wrong with this query?

Код:
INSERT INTO 'acodes' ('thecode') VALUES ('a51G81baJ11a')
Basically all I want to do is insert the "a51G81baJ11a" into "thecode" field, on the acodes database, and I get this error:

Quote:

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 ''acodes' ('thecode') VALUES ('a51G81baJ11a')' at line 1

Can anyone help me out?


---------------------------- PROBLEM WAS FIXED! --------------
Reply
#2

Your syntax is a little strange, you don't need those quotes around the column name and you should use the other quotes around the table name, for example:

pawn Код:
"INSERT INTO `acodes` (thecode) VALUES ('a51G81baJ11a')"
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Your syntax is a little strange, you don't need those quotes around the column name and you should use the other quotes around the table name, for example:

pawn Код:
"INSERT INTO `acodes` (thecode) VALUES ('a51G81baJ11a')"
Okay that runs perfectly, however when I generate a random string and try to insert it via pawno like this:

pawn Код:
new query[195];
format(query, sizeof(query), "INSERT INTO 'acodes' (thecode) VALUES ('%s')", string);
mysql_query(string);
I get an error:

Quote:

Error (0): Failed to exeute query. 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 '9cSV395Y5AEw' at line 1

Reply
#4

Quote:
Originally Posted by Memoryz
Посмотреть сообщение
What's wrong with this query?

Код:
INSERT INTO 'acodes' ('thecode') VALUES ('a51G81baJ11a')
Basically all I want to do is insert the "a51G81baJ11a" into "thecode" field, on the acodes database, and I get this error:



Can anyone help me out?
you mean you want to insert into table 'acodes' which contain field 'thecode' and you are inserting value 'a51G81baJ11a' ? database is selected at the beginning..
Reply
#5

Quote:
Originally Posted by [Diablo]
Посмотреть сообщение
you mean you want to insert into table 'acodes' which contain field 'thecode' and you are inserting value 'a51G81baJ11a' ? database is selected at the beginning..
Yea, I am connected to all that, all my other SQL queries run perfectly.
Reply
#6

pawn Код:
new query[195];
format(query, sizeof(query), "INSERT INTO `acodes` (`thecode`) VALUES ('%s')", string);
mysql_query(string);
Reply
#7

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
pawn Код:
new query[195];
format(query, sizeof(query), "INSERT INTO `acodes` (`thecode`) VALUES ('%s')", string);
mysql_query(string);
Quote:

Error (0): Failed to exeute query. 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 '4PYBsw2z0B68' at line 1.

What I am thinking, is that there is a problem with this random string stock?

pawn Код:
stock randomString(strDest[], strLen = 10)
{
    while(strLen--)
        strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
Reply
#8

Quote:
Originally Posted by Memoryz
Посмотреть сообщение
Okay that runs perfectly, however when I generate a random string and try to insert it via pawno like this:

pawn Код:
new query[195];
format(query, sizeof(query), "INSERT INTO 'acodes' (thecode) VALUES ('%s')", string);
mysql_query(string); // maybe query ? xd
I get an error:
Try :P
Reply
#9

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Try :P
I have tried that already.
Reply
#10

Must be
pawn Код:
new query[195];
format(query, sizeof(query), "INSERT INTO `acodes` (`thecode`) VALUES ('%s')", string);
mysql_query(query);
` not ' at acodes and show string
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)