...

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



thepocketgeek
05-11-2009, 10: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.



set_time_limit(300);


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

Fumigator
05-11-2009, 10: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);

thepocketgeek
05-11-2009, 10: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

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum