Common MySQL Error List -
Blacklite - 31.05.2009
Hi
After trying to find out how to fix the error my SA:MP MySQL server, I saw that there are heaps of people asking the same questions over and over again, but with slightly different errors.
Firstly, all logged MySQL errors will have "Error in mysql_query:" and then the error, like this:
Код:
[13:37:11] Error in mysql_query: Column count doesn't match value count at row 1
Thanks to [NL]WackoX.
Here are the common errors:
_________________________________________________
No database selected
In MySQL, you can have heaps and heaps of databases. If you don't specify a MySQL database, it will not know which one to use.
Solution:
Put this after you use samp_mysql_connect():
Код:
samp_mysql_select_db("database_name");
_________________________________________________
MySQL server has gone away
This means that MySQL can't connect to the database.
Solution:
Check that the IP, username, and password in your samp_mysql_connect() function are all correct. Try to connect with the same credentials using a local database program, like MySQL Administrator.
_________________________________________________
Column count doesn't match value count at row *
Your "INSERT" statement's syntax is incorrect. For example, this will not work:
Код:
INSERT INTO `table_name` (`column1`, `column2`) values('value 1')
Notice that I have specified 2 columns, but have only entered one value.
Solution:
Make sure that the amount of values and columns are the same.
_________________________________________________
Unknown column '*' in 'field list'
Somewhere in your SQL statement, you have referenced a column that doesn't exist.
Solution:
Check for spelling mistakes or inexistent columns in column names.
_________________________________________________
Table '*.*' doesn't exist
Somewhere in your SQL statement, you have referenced a table that doesn't exist.
Solution:
Check for spelling mistakes or inexistent tables in table names.
_________________________________________________
Commands out of sync; you can't run this command now
You have tried to execute an SQL command before freeing the last result.
Solution:
Somewhere in your script, you need to add a samp_mysql_free_result() before samp_mysql_query(). Alternatively, you could upgrade to the latest version of the SA:MP MySQL plug-in.
_________________________________________________
Error in mysql_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 '*' at line *
You have used incorrect syntax in your SQL statement.
Solution:
See
http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html
_________________________________________________
samp-server.exe crashes and gives an error report (also in linux)
You are trying to execute a query before MySQL has connected to a database.
Solution:
Connect MySQL to a database before executing a query using samp_mysql_connect();.
If you have any more trouble with errors, post them in this thread and i'll add explanations and solutions for them.
Thanks
Re: Common MySQL Error List -
Dj_maryo1993 - 30.08.2009
http://forum.sa-mp.com/index.php?topic=119329.0 I will really apreciate if you help me here
Re: Common MySQL Error List -
Andom - 30.08.2009
Another:
samp-server.exe crashes and gives an error report (also in linux)
Problem:
You are trying to execute a query before MySQL has been connected.
Solution:
Connect MySQL before it'll execute a query.