Mysql help.
#1

First of all just excuse me if i'm doing a mess or an illogical thing or smthin.
I'm making on phpmyadmin a databse, with table users and when a player is connecting i'm trying to put the name in the table users in the case "Name" but it is not inserting, and the compiler is having no-erros. What is wrong with what i've done here?

CODE:

Top of the script
Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
#include <a_mysql>

new SQL = -1;
new gQuery[256];
#if defined FILTERSCRIPT
On player connect

Код:
public OnPlayerConnect(playerid)
{
	gQuery[0] = EOS;
	new GetName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, GetName, sizeof(GetName));
	mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `accounts` (`Name`) VALUES  ('%s')", GetName);
	return 1;
}
Photo with php my admin
Reply
#2

1.Are you connected to MySQL?

2.Use
mysql_tquery(SQL, gQuery);
.. https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_format
Reply
#3

Mysql plugin provides a log system for errors and warnings. The problem is that that Password and Gender (assuming ID is set as auto increment) do not have a default value so it throws an error.

Please take a look at existing register/login systems to get an idea. Executing an INSERT query every time a player connects will give you duplicates which is wrong. You need to check if player is not registered first.
Reply
#4

mysql_format only formats a String. You have to use mysql_query, mysql_tquery, or mysql_pquery to execute the query. If you are doing that as well, show us the MySQL Log.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)