[ERROR]MySQL: mysql_num_rows

Started by !, Mar 14, 2017, 09:27 AM

Previous topic - Next topic

!

function PWebStats( player )
{
local myquery = mysql_query( MyDB,"SELECT Name FROM Account WHERE Name='"+player.Name+"'");
if ( mysql_num_rows( myquery ) == 0 )
{
mysql_query( MyDB, "INSERT INTO Account( *** ) VALUES( *** )" );
print("inserted");
}
else if ( mysql_num_rows( myquery ) > 0 )
{
mysql_query( MyDB, "UPDATE Account SET( *** ) VALUES( *** );
print("Updated");
}
mysql_free_result( myquery );
}

By using this function it works first time but next time it throw an error

[spoiler]AN ERROR HAS OCCURED [Error in 'mysql_num_rows': Wrong number of arguments or invalid argument type]

CALLSTACK
*FUNCTION [PWebStats()] scripts/Functions.nut line [9]

LOCALS
[myquery] false
[sqlquery] USERPOINTER
[player] INSTANCE
[this] TABLE
[r] USERPOINTER
[e] USERPOINTER
[w] USERPOINTER
[q] USERPOINTER
[player] INSTANCE
[this] TABLE
[det] 439300
[cash] 439400
[amount] 100
[player] INSTANCE
[this] TABLE
[reason] 70
[player] INSTANCE
[this] TABLE
[/spoiler]

The mysql query is false.
Is this because of poor connection or something else.

Discord: zeus#5155

Cool

Line 9 == ?
  mysql_query( MyDB, "INSERT INTO Account( *** ) VALUES( *** )" ); what is this? only *** Does Account have colum Named ***

!

Quote from: happymint2 on Mar 14, 2017, 10:00 AMLine 9 == ?
  mysql_query( MyDB, "INSERT INTO Account( *** ) VALUES( *** )" ); what is this? only *** Does Account have colum Named ***

It means other shits
Name, User, Kills, Deaths
ets
And in values their values

Discord: zeus#5155

Thijn

Why not use else? It's not going to be less then zero, so if it's not exactly zero it's automatically bigger then that.

!

Quote from: Thijn on Mar 14, 2017, 04:47 PMWhy not use else? It's not going to be less then zero, so if it's not exactly zero it's automatically bigger then that.
Ok but what about error on line 4
if ( mysql_num_rows( myquery ) == 0 )

Discord: zeus#5155

EK.IceFlake

If a MySQL query returns false, there is an error with it. You can use my plugin to detect MySQL errors.

KAKAN

there is a sqlquery in your locals too :D
oh no

!

#7
Quote from: EK.IceFlake on Mar 14, 2017, 05:30 PMIf a MySQL query returns false, there is an error with it. You can use my plugin to detect MySQL errors.
I'll try.

Quote from: KAKAN on Mar 15, 2017, 02:44 AMthere is a sqlquery in your locals too :D
Yup, Locals :D

Discord: zeus#5155

!

Bump
Is there any method to find error why query is false
In official mysql plugin.
Anyone

Discord: zeus#5155

EK.IceFlake

#9
print(mysql_error(mysql instance));
This is how my plugin's MySQL error reporting works.
        local r = ::mysql_query(inst, q), err = ::mysql_error(inst);
        if (::mysql_error(inst) != "") throw err;
By the way, I just noticed that I don't need that variable there.