Page 1 of 1

header link problem

Posted: Fri Apr 01, 2011 12:01 pm
by bella1010
hi, php beginner here.
problem: below coding only linkable to header('Location:dr_fatimah_3111.php'); but can't link to -- header('Location:dr_fatimah_4303.php');.
why? whr the problem?
looking for someone who know the problem resolution to help me solve the problem.
thanks.


<?php

include 'Connections/myConnection.php';
mysql_select_db($database_myConnection, $myConnection)
or die("Unable to connect to MySQL");


$query = "SELECT code, name FROM dr_fatimah";
$result = mysql_query($query);

//text field
if(mysql_num_rows($result)) {
$result = mysql_query("SELECT name FROM dr_fatimah WHERE code='SMM3111' AND name='Multimedia Programming' ");
header('Location:dr_fatimah_3111.php');

}

else header('Location:dr_fatimah_4303.php');
?>

Re: header link problem

Posted: Fri Apr 01, 2011 12:46 pm
by greyhoundcode

Code: Select all

// The following condition is presumably evaluating as true
if(mysql_num_rows($result)) 
{
 	// I'm not too sure what purpose this next line serves...
	$result = mysql_query(
		"SELECT name FROM dr_fatimah WHERE code='SMM3111' AND name='Multimedia Programming' ");

	// ... as you are then redirecting, regardless of the outcome
	header('Location:dr_fatimah_3111.php');
}

// This is the other half of your if/else logic. It will not execute if
// the initial if (...) condition has been met
else 
	header('Location:dr_fatimah_4303.php');

Re: header link problem

Posted: Fri Apr 01, 2011 1:03 pm
by bella1010
$result (variable) to get the selected data -->(code='SMM3111' AND name='Multimedia Programming') from (dr_fatimah) table

Re: header link problem

Posted: Sat Apr 02, 2011 9:02 am
by Bill H
When you say it "can't link to..." what do you mean? What happens? What is not happening? Is the script merely linking to the one location all the time and never going to the other? Maybe it's because the "if" clause is always evaluating as FALSE?

You are not giving us enough information, and this question should be in the "Code" forum anyway, not here in the forum that says "not for posting programming related questions."

Re: header link problem

Posted: Sun Apr 03, 2011 4:54 pm
by greyhoundcode
Ahhh ... I get it now. It was posted on 1 April. :roll:

Just kidding. What Bill H said.