header link problem

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
bella1010
Forum Newbie
Posts: 12
Joined: Fri Apr 01, 2011 11:03 am

header link problem

Post 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');
?>
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: header link problem

Post 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');
bella1010
Forum Newbie
Posts: 12
Joined: Fri Apr 01, 2011 11:03 am

Re: header link problem

Post by bella1010 »

$result (variable) to get the selected data -->(code='SMM3111' AND name='Multimedia Programming') from (dr_fatimah) table
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: header link problem

Post 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."
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: header link problem

Post by greyhoundcode »

Ahhh ... I get it now. It was posted on 1 April. :roll:

Just kidding. What Bill H said.
Post Reply