very basic script no longer working


#1

I have been using this script for several months now with no issues. I am trying to switch servers and the code is simply not working on the new one.

The code generates a form, which uses a function to decide who to send the form to, based on a variable passed from the address. I used a case switch function rather than nested if’s, and it passes the result to 3 places in the form.

This function will not work on the new space … nothing gets passed to the form, and therefore the form can’t tell the mail script who to send the email to. This is a major part of the automation of my site, and I am just lost trying to figure it out :confused:

I have been told that the PHP version is very up-to-date on the new server, and it’s obviously enabled since the form does get displayed. It’s just the function that seems to be having issues. Any suggestions or insights would be helpful … note tho that this exact code works fine elsewhere :confused:

[code]function subject($group){
switch ($group){
case 1: $subject = ‘Guild Master and the Assistant GMs’;
break;

    case 2: $subject = 'Senior Officers';
    break;

    case 3: $subject = 'Officers';
    break;

    case 4: $subject = 'Valor Guard';
    break;

    case 5: $subject = 'Admissions Team';
    break;

    case 6: $subject = 'Webmaster';
    break;
}
return $subject;

}[/code]


#2

What is the error message? What is it doing or not doing?


#3
This function will not work on the new space ... nothing gets passed to the form

There’s not an error code per se … either the variable is not passing into the function, or the function is not passing it to the form.

Even a pointer towards a debugger would be helpful … I have the basics down, but this is just stumping me. It’s probably something simple that I’m just overlooking :confused:


#4

look in “The Occasional Tutorial” forum and you will find a debugging thread with many good tips and tricks. Make sure you read the whole thread to get the most out of it.


#5

Could it be because you haven`t declared $subject as a global variable within your function? I assume you are using $_POST to access the variable?

function subject($group){

    global $subject; 

    switch ($group){ 
        case 1: $subject = 'Guild Master and the Assistant GMs'; 
        break; 

        case 2: $subject = 'Senior Officers'; 
        break; 

        case 3: $subject = 'Officers'; 
        break; 

        case 4: $subject = 'Valor Guard'; 
        break; 

        case 5: $subject = 'Admissions Team'; 
        break; 

        case 6: $subject = 'Webmaster'; 
        break; 
    } 
    return $subject; 
}
:)

#6

Not using $_post … here’s a snippet of the code where the function is called … group is passed in from the address: groupmail.php?group=##.

[php]$form .=’

[/php]

Did try declaring the global variable tho … didn’t fix it :confused:


#7

ok I tried some basic debugging stuff … obviously php is working because print $form; prints out the mail form, all correctly formatted etc.

However, print $group; doesn’t print anything out. So my conclusion is that $group is not being passed in from the address to the script.

Is there anyway to track down and fix that or should I just look for an alternate way to address the mail, maybe using a drop-box in the form?


#8

Try retrieving your Posted variables using the super globals

$_POST[‘VarName’]

[php]
$form .=’

[/php]