troubleshooting Question

PHP Redirect based on an IF statement not working?

Avatar of akashj
akashj asked on
42 Comments2 Solutions743 ViewsLast Modified:
Hi all,

I've got 2 sections of a php file
section 1. Has header information for the redirect
section 2. Has a SQL Statement that gets a COMPLETED or RUNNING status back

The header is :
$a = "";  
$b = "";

if ($result = "COMPLETED1")
header("Location: $a");
header("Location: $b");

Sql is:


// create connection
$connection = odbc_connect("server","user","password");

// test connection
if (!$connection) {
echo "Couldn't make a connection!";
// create SQL statement


// prepare SQL statement
$sql_result = odbc_prepare($connection,$sql);

// execute SQL statement and get results

// format result in HTML table

// free resources and close connection


Problem is, it doesn't seem to redirect.  It's always going to $a which is Google.
I changed the = to == which then sends it to Yahoo ($b) regardless of the result.

Can anyone help me out in this?  Not sure if the order is is it trying to do the redirect before running the sql/getting the result?

Appreciate it.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 42 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 42 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros