MySQL Error: #1064
#1

this is my code:
pawn Код:
stock WriteLog(sqlserver, const log[])
{
    new date[3], time[3], string[450];
    getdate(date[0], date[1], date[2]);
    gettime(time[0], time[1], time[2]);
    format(string, sizeof string, "CREATE TABLE IF NOT EXISTS `%02d/%02d/%04d` (`ID` INT(11) NOT NULL auto_increment, `text` varchar(255) NOT NULL default '', PRIMARY KEY (`ID`));", date[2], date[1], date[0]);
    format(string, sizeof string, "%s INSERT INTO `%02d/%02d/%04d` SET `text` = '[%02d:%02d:%02d] %s'", string, date[2], date[1], date[0], time[0], time[1], time[2], log);
    return print(string), mysql_tquery(sqlserver, string);
}
output:
pawn Код:
CREATE TABLE IF NOT EXISTS `06/02/2015` (`ID` INT(11) NOT NULL auto_increment, `text` varchar(255) NOT NULL default '', PRIMARY KEY (`ID`)); INSERT INTO `06/02/2015` SET `text` = '[23:57:55] sgs'
mysql log:
pawn Код:
[23:57:55] [ERROR] CMySQLQuery::Execute[] - (error #1064) Erreur de syntaxe prטs de 'INSERT INTO `06/02/2015` SET `text` = '[23:57:55] sgs'' א la ligne 1
but in phpMyAdmin it show me success
what's the problem?
Reply
#2

Help please?
Reply
#3

try to use strcat

pawn Код:
format(string,sizeof(string),"");
    strcat(string,"CREATE TABLE IF NOT EXISTS `%02d/%02d/%04d` (`ID` INT(11) NOT NULL auto_increment, `text` varchar(255) NOT NULL default '', PRIMARY KEY (`ID`)) ");
    strcat(string,"%s INSERT INTO `%02d/%02d/%04d` SET `text` = '[%02d:%02d:%02d] %s'", string);
    mysql_format(sqlserver, string, sizeof(string), string, date[2], date[1], date[0],date[2], date[1], date[0], time[0], time[1], time[2], log);
    return print(string), mysql_tquery(sqlserver, string);
im still not 100% sure if this works or not ! if you got errors post them here
Reply
#4

I'm having the same problem right now, and I am also trying to send two queries to the database at once. Try sending two separate queries, it solved my problem, but is not a complete solution.

If anyone could further explain why BlueG's plugin fails with multiple queries, please do so, as I cannot and am unable to find [in the documentation] that the plugin cannot do so in theory.

________________

If I have helped you, please rep++ to show your appreciation.
Reply
#5

Quote:
Originally Posted by Namer
Посмотреть сообщение
try to use strcat

pawn Код:
format(string,sizeof(string),"");
    strcat(string,"CREATE TABLE IF NOT EXISTS `%02d/%02d/%04d` (`ID` INT(11) NOT NULL auto_increment, `text` varchar(255) NOT NULL default '', PRIMARY KEY (`ID`)) ");
    strcat(string,"%s INSERT INTO `%02d/%02d/%04d` SET `text` = '[%02d:%02d:%02d] %s'", string);
    mysql_format(sqlserver, string, sizeof(string), string, date[2], date[1], date[0],date[2], date[1], date[0], time[0], time[1], time[2], log);
    return print(string), mysql_tquery(sqlserver, string);
im still not 100% sure if this works or not ! if you got errors post them here
same error
thanks for trying to help
Quote:
Originally Posted by EnforcerDon
Посмотреть сообщение
I'm having the same problem right now, and I am also trying to send two queries to the database at once. Try sending two separate queries, it solved my problem, but is not a complete solution.

If anyone could further explain why BlueG's plugin fails with multiple queries, please do so, as I cannot am unable to find [in the documentation] that the plugin cannot do so in theory.

________________

If I have helped you, please rep++ to show your appreciation.
Thanks!
this solved my problem (two queries):
pawn Код:
stock WriteLog(sqlserver, const log[])
{
    new date[3], time[3], string[450];
    getdate(date[0], date[1], date[2]);
    gettime(time[0], time[1], time[2]);
    format(string, sizeof string, "CREATE TABLE IF NOT EXISTS `%02d/%02d/%04d` (`ID` INT(11) NOT NULL auto_increment, `text` varchar(255) NOT NULL default '', PRIMARY KEY (`ID`));", date[2], date[1], date[0]);
    print(string), mysql_tquery(sqlserver, string);
    format(string, sizeof string, "INSERT INTO `%02d/%02d/%04d` SET `text` = '[%02d:%02d:%02d] %s'", date[2], date[1], date[0], time[0], time[1], time[2], log);
    return print(string), mysql_tquery(sqlserver, string);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)