Mysql help. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql help. (
/showthread.php?tid=661451)
Mysql help. -
Fabyx15 - 04.12.2018
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
Re: Mysql help. -
xRadical3 - 04.12.2018
1.Are you connected to MySQL?
2.Use
mysql_tquery(SQL, gQuery);
..
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_format
Re: Mysql help. -
Calisthenics - 05.12.2018
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.
Re: Mysql help. -
GTLS - 06.12.2018
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.