Mysql refuses to create table
#1

pawn Код:
public OnPlayerConnect(playerid)
{
    new string[128];
    format(string, sizeof(string), "CREATE TABLE IF NOT EXISTS TABLENAME `terma`");
    mysql_query(string);
    return 1;
}
I have nothing but this code, I use BlueG's mysql server plugin r5 windows version
checked phpmyadmin a thousand times but table cant be created
could the plugin be causing this
and theres nothing in the logs
Reply
#2

Quote:
Originally Posted by iFiras
Посмотреть сообщение
pawn Код:
public OnPlayerConnect(playerid)
{
    new string[128];
    format(string, sizeof(string), "CREATE TABLE IF NOT EXISTS TABLENAME `terma`");
    mysql_query(string);
    return 1;
}
I have nothing but this code, I use BlueG's mysql server plugin r5 windows version
checked phpmyadmin a thousand times but table cant be created
could the plugin be causing this
and theres nothing in the logs
try.
PHP код:
format(stringsizeof(string), "CREATE TABLE IF NOT EXISTS terma"); 
Reply
#3

Still doesnt work
Reply
#4

Are you sure the database connection is being established correctly?
Reply
#5

Quote:
Originally Posted by MEW273
Посмотреть сообщение
Are you sure the database connection is being established correctly?
Logs tell me the connection to the database is successful
Reply
#6

You need to add the columns to your CREATE TABLE query, see example below:
Код:
CREATE TABLE IF NOT EXISTS `terma`(`ID`int AUTO_INCREMENT PRIMARY KEY)
Do you have debug enabled? If not you should enable and then check your MySQL log. As you're using a very outdated version of the MySQL plugin I'm not familiar with the functions but try this:
Код:
mysql_debug(1);
Place it before your connection code.

Also generally speaking I don't think it's worth the effort trying to create tables in Pawn, would it not be easier to simply create the table in phpMyAdmin?
Reply
#7

Tried the first code, still didn't work
Enabled debug, didn't get anything
It always says connection to the database is successful
And I don't get how I should create the table manually, say I have a registration system, am I supposed to be creating a table for each player that registers manually?
Reply
#8

You should only need to create the table once, you then add a new row when a player registers by using an INSERT query.

Even with debug enabled there is no log referencing this particular query? Could you post a copy of your MySQL log here please.
Reply
#9

There is one log I found
pawn Код:
[12:03:40] [ERROR] mysql_connect: invalid option id '3306'
[12:04:24] [ERROR] mysql_connect: invalid option id '3306'
[12:04:55] [ERROR] mysql_connect: invalid option id '3306'
[12:07:17] [ERROR] mysql_connect: invalid option id '3306'
[12:08:18] [ERROR] mysql_connect: invalid option id '3306'
[12:09:34] [ERROR] mysql_connect: invalid option id '3306'
[12:18:01] [ERROR] mysql_connect: invalid option id '3306'
[12:23:39] [ERROR] mysql_connect: handle error: no database specified
[12:27:58] [ERROR] CConnection::CConnection - establishing connection to MySQL database failed: #1045 'Accиs refusй pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI)'
[12:27:58] [ERROR] CConnection::CConnection - establishing connection to MySQL database failed: #1045 'Accиs refusй pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI)'
[12:27:58] [ERROR] CConnection::CConnection - establishing connection to MySQL database failed: #1045 'Accиs refusй pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI)'
[12:27:58] [ERROR] CConnection::CConnection - establishing connection to MySQL database failed: #1045 'Accиs refusй pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI)'
But it doesn't seem that I got this now, in the time it says 12 pm but in my country its 2 pm now
and translation for the last lines, it says access refused to root@localhost (password: yes)
though it says connection to the database is successful in the samp-server log
Reply
#10

Stop your server then delete (or move to another folder) the log file completely, then start the server again, it will create a new log file and show only current errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)