Hey guys, I'm trying to use a php variable in a mysql statement, but I can't get it to work. What I want to do is something like:

    
$IDQuery = mysql_query("SELECT * FROM Player_Info WHERE WholeName = '$WholeName'"); $IDQueryResult = mysql_fetch_assoc($IDQuery); $PlayerID = $IDQueryResult['PlayerID'];

I want sql to return the row that matches my variable, $WholeName, which is defined earlier (the vaule for that is pulled from the Player_Info table so it should always work). I then want to take the info from the PlayerID column (should be only 1 row and 1 column returned) and save it as a variable $PlayerID.

I've tried everything but I cant get it to work. Does anyone see something wrong??

    Originally posted by AllOrN0thin
    Does anyone see something wrong??

    Um, no, because we're not sitting at your computer. Why don't you tell us what it's doing wrong and maybe we can tell you why it's doing it and how to fix it?

      right after that statement i echo the value of $PlayerInfo and its blank.

      I tried hardcoding in an exact value for the WHERE command, and it returned the correct PlayerID and echo'd it. So I'm pretty sure theres something wrong with how im trying to search a column in mysql with a variable.

        I found I was making it much harder than it had to be, I got it working.

          Write a Reply...