From my C backbround I can tell this is a type of branch. Your code continues execution with the supplied function and arguments.
However this is not absolute. It cought me off guard today when these lines were totally ignored and program execution continued to flow through my if statements.
Here's my sample:
Code:
function insertStudent($name, $nukeid, $cid, $status){
global $prefix, $db;
$name=filter_text($name, "nohtml");
$nukeid=intval($nukeid); // Make sure it's an intiger
$username = isSiteMember($nukeid);
if($username == NULL) {
$msg = _STUDENT_NOTFOUND; // Nuke id does not exist
header("Location: admin.php?op=addStudent&msg=$msg");
}
$sid = isStudent($nukeid);
if ($sid) {
$msg = _STUDENT_ALREADY_IN; // Student is already in university - cant add again
header("Location: admin.php?op=addStudent&msg=$msg");
}
Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
Posted:
Wed Feb 18, 2004 3:48 pm
Kinda-sorta. It actually writes an HTTP header and as such, no code can be written to the browser before it or you will receive the 'headers already sent' message unless output_buffering is on.
I'm not sure exactly where your code fails, but I would rewrite this statement
Thanks for the tip, I rewrote it to if (is_null($username)).
I've been trying to figure this out now for over 7 hours. Something isent right with this, or with my understanding of it.
The code isent exactly failing. I use the two if statements to return an error message to the addStudent function so that the user can give it antoher shot.
They are both actually working. I've put echo statements on every single line and watched my data as I step thru it. I'm droping into the if statements and upon exit of this function I'm going to the appropriate spot..
The problem is that the insert command runs no matter what I do.
If I'm error trapping I don't want the insert command to run on bad data. What am I missing?
I don't believe those header statements are right...
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum