PHP MYSQL WHERE statement help

Chris S

Retired
Messages
2,055
Reaction score
1
Points
38
I need help with a little statement that I am working, I just cannot seem to get it to verify both values.

PHP:
$select = "SELECT * FROM `serverstatus` WHERE `ip` = '$serverip' AND`command` = '$key'";

I have that code and what it is supposed to do is look into my database and grab the one corresponding row that has the corresponding IP and command name.

It anybody could help me that would be great.
 

Salvatos

Member
Prime Account
Messages
562
Reaction score
1
Points
18
Try this:
Code:
$select = "SELECT * FROM serverstatus WHERE ip = '$serverip' AND command = '$key'";
The single quotes around table names are not necessary and I added a missing space after the "AND".
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
PROTIP; when in doubt:
*echo the SQL
*Drop it into phpMyAdmin's SQL tool
*Find error quicker :)
 

Chris S

Retired
Messages
2,055
Reaction score
1
Points
38
//rant ...but protip....seriously im currently coding a backend administration panel for managing servers on a network...thanks for the tip.
//end rant

Turns out what it was, i declared the table column command wrong, I had int and was trying to stick characters into it, so it was basically coming back blank so mysql took it upon itself to make it 0. The statement itself worked when I fixed the problem
 
Last edited:
Top