Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2005
    Location
    Florida
    Posts
    73
    Thanks
    11
    Thanked 0 Times in 0 Posts

    SQL code runs in PHPMyAdmin but not in PHP...

    I have a SQL statement that runs just fine when I echo the statement itself to the page and run it directly through PHPMyAdmin.

    Here is the code I am using to run the SQL statement:

    PHP Code:
    $result mysql_query($sql);
    $row mysql_fetch_row($sql); 
    I've never had this problem before. The SQL statement is pretty complex. It pulls from 5 or 6 different tables so I've considered the possibility that it is timing out. I tried to add the set_time_limit() function to increase the timeout to 300 seconds. Didn't work.

    PHP Code:
    set_time_limit(300); 
    So is there something that I have missed? What else should I look for?
    Last edited by thepocketgeek; 05-11-2009 at 11:38 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    For starters you could show us the query

    Also you don't seem to be checking the results of your query, which is a critical part of determining what the problem is.

    PHP Code:
    $result mysql_query($sql);
    if (!
    $result) {
        die(
    "Query Error! Query text: $sql<br>Error: ".mysql_error());
    }
    $row mysql_fetch_row($sql); 

  • #3
    New Coder
    Join Date
    Jun 2005
    Location
    Florida
    Posts
    73
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Okay. I had a major brain fart...

    This is the code:

    PHP Code:
    $result mysql_query($sql);
    $row mysql_fetch_row($result); 
    I screwed up the value I was checking for in $row = mysql_fetch_row().

    I need to lay off the green M&M's

  • #4
    New Coder
    Join Date
    Jun 2005
    Location
    Florida
    Posts
    73
    Thanks
    11
    Thanked 0 Times in 0 Posts
    I just needed to check my variables a little more closely. Thanks for commenting.

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Ahhh yep I missed that too!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •