+ Reply to Thread
Results 1 to 4 of 4

Thread: PHP MYSQL WHERE statement help

  1. #1
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    PHP MYSQL WHERE statement help

    I need help with a little statement that I am working, I just cannot seem to get it to verify both values.

    PHP Code:
    $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.

    I would love to change the world, but they won't give me the source code

  2. #2
    Salvatos's Avatar
    Salvatos is offline x10 Lieutenant Salvatos is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    Québec, Canada
    Posts
    271

    Re: PHP MYSQL WHERE statement help

    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".

  3. #3
    xmakina's Avatar
    xmakina is offline x10 Lieutenant xmakina is an unknown quantity at this point
    Join Date
    May 2008
    Location
    England
    Posts
    265

    Re: PHP MYSQL WHERE statement help

    PROTIP; when in doubt:
    *echo the SQL
    *Drop it into phpMyAdmin's SQL tool
    *Find error quicker
    IF($this->$post.content() == "SEE SIG"){
    w3Schools and Google
    }

  4. #4
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: PHP MYSQL WHERE statement help

    //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 by Chris S; 10-23-2008 at 04:50 PM.

    I would love to change the world, but they won't give me the source code

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. Places to learn php
    By JaWasabi in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 01-13-2009, 02:03 AM
  3. Also got the PHP MySQL error
    By adfad666 in forum Free Hosting
    Replies: 1
    Last Post: 08-16-2008, 07:52 PM
  4. PHP MySQL Question..
    By anuj_web in forum Programming Help
    Replies: 7
    Last Post: 04-26-2008, 05:43 AM
  5. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers