View Full Version : Resolved SQL code runs in PHPMyAdmin but not in PHP...

05-11-2009, 11:31 PM
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:

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


So is there something that I have missed? What else should I look for?

05-11-2009, 11:35 PM
For starters you could show us the query :thumbsup:

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

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

05-11-2009, 11:38 PM
Okay. I had a major brain fart...

This is the 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

05-11-2009, 11:39 PM
I just needed to check my variables a little more closely. Thanks for commenting.

05-11-2009, 11:44 PM
Ahhh yep I missed that too!