PDA

View Full Version : MySQL problem


C5Perfect
15/03/2018, 03:31 AM
SELECT * FROM `BanData` WHERE `Expires On` > NOW() AND `User`='Alex' OR `IP Address`='127.0.0.1'

Resulting in 0 rows but there are.. however, if I remove " OR `IP Address`='127.0.0.1' " it works fine..

help?

DobbysGamertag
15/03/2018, 06:15 AM
Why have you got spaces in your column names?

C5Perfect
15/03/2018, 07:04 AM
Why have you got spaces in your column names?

Why would that matter?

FailerZ
15/03/2018, 07:22 AM
Have you check your logs folder? It might be outputting something

C5Perfect
15/03/2018, 08:21 AM
[09:11:33] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('0')
[09:11:33] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('1')
[09:11:33] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('2')
[09:11:33] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('3')
[09:11:33] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('4')
[09:11:33] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('5')
[09:11:33] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('6')
[09:11:33] [WARNING] CMySQLResult::GetRowData - invalid row ('1') or field index ('7')


The problem is that even if the ban expired, It will still show me that I'm banned, unlike when I remove OR `IP Address`='127.0.0.1'

And when I remove it, i don't get these errors
Also, when I manually use that query in phpmyadmin, it's resulting in 0 rows, unlike when I remove " OR `IP Address`='127.0.0.1' " as I said

iKarim
15/03/2018, 08:33 AM
Remove the spaces from field names, also show the full mysql log where the query actually executes.

C5Perfect
16/03/2018, 03:55 PM
mysql_format(Database, query, sizeof(query), "SELECT * FROM `BanData` WHERE `ExpiresOn` > NOW() AND `User`='%s' OR `IPAddress`='%s'", GetName(playerid), Player_IP[playerid]);
mysql_tquery(Database, query, "OnAccountBanCheck", "d", playerid);

I removed the spaces.
Even if the ban has expired, it's resulting in 1 row..
ExpiresOn is DATETIME
I'll repeat, if I remove OR `IPAddress`='%s', everything works fine..

kovac
18/03/2018, 09:48 AM
bump!

kovac
19/03/2018, 09:32 PM
bump

Jefff
20/03/2018, 01:11 AM
"SELECT * FROM `BanData` WHERE `ExpiresOn` > NOW() AND (`User`='%s' OR `IPAddress`='%s')"
?

kovac
20/03/2018, 12:30 PM
"SELECT * FROM `BanData` WHERE `ExpiresOn` > NOW() AND (`User`='%s' OR `IPAddress`='%s')"
?

It works now, thank you and thanks everyone for the help! +rep