Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-11-2009, 10:31 PM   PM User | #1
thepocketgeek
New Coder

 
Join Date: Jun 2005
Location: Florida
Posts: 73
Thanks: 11
Thanked 0 Times in 0 Posts
thepocketgeek is an unknown quantity at this point
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 10:38 PM..
thepocketgeek is offline   Reply With Quote
Old 05-11-2009, 10:35 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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); 
__________________
Fumigator is offline   Reply With Quote
Old 05-11-2009, 10:38 PM   PM User | #3
thepocketgeek
New Coder

 
Join Date: Jun 2005
Location: Florida
Posts: 73
Thanks: 11
Thanked 0 Times in 0 Posts
thepocketgeek is an unknown quantity at this point
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
thepocketgeek is offline   Reply With Quote
Old 05-11-2009, 10:39 PM   PM User | #4
thepocketgeek
New Coder

 
Join Date: Jun 2005
Location: Florida
Posts: 73
Thanks: 11
Thanked 0 Times in 0 Posts
thepocketgeek is an unknown quantity at this point
I just needed to check my variables a little more closely. Thanks for commenting.
thepocketgeek is offline   Reply With Quote
Old 05-11-2009, 10:44 PM   PM User | #5
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Ahhh yep I missed that too!
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:18 AM.


Advertisement
Log in to turn off these ads.