Script SQL query fails to execute

In the following string, an SQL query for data to the database returns an else condition.

 $sql = $db->select('table', array('special_url' => $_GET['table_name'], 'status' => 1));

Open in new window


This should return data to the index page, however it results in a 404 redirect by script
 
if ($sql->exists) {
	$name = $sql->fetch();
} else redirect("404.php");

Open in new window


So were getting a 404 even though we have data in the database where the status is equal to 1

some of the variable names have been changed, because of the nature of the data involved.

Any thoughts on what were missing here or a way to discover what is causing the else redirect condition
freejointventureAsked:
Who is Participating?
 
Ray PaseurCommented:
Any time you're unsure of what data exists in a variable, you can use var_dump() to print out the contents.  I would start in the first snippet and try this after the statement:

var_dump($sql);

The output from that function is usually easier to read if you use "view source."

Since the second snippet makes a decision based on the properties of the $sql variable set in the first snippet, you will at least be able to see what is in the $sql object.
0
 
freejointventureAuthor Commented:
Thank you ) that is perfect.
0
 
freejointventureAuthor Commented:
Excellent answer thank you.
0
 
Ray PaseurCommented:
Glad to help -- thanks for the points and thanks for using E-E, ~Ray
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.