PHP string no longer recognized after upgrading PHP version

the mail() function

Moderators: egami, macek, gesf

Post Reply
dlc3172
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Nov 09, 2017 12:29 pm

Thu Nov 09, 2017 12:43 pm

Hello-

This is a novice question which should be easily answered by the pros on this board.

My server was using PHP version 5.2, and today I upgraded it to 5.4. After the upgrade, I discovered a problem with my code.

I have a registration form that sends the submitted data to my email address. My code was putting the e-mail address of the person submitting the form into the subject line of the e-mail that was being delivered to me. Here is the code that generated the subject line:

Code: Select all

$from = "00-00-00 $email" ;
The 00-00-00 part is just a date that I manually change in my code from time to time.

After upgrading to PHP 5.4 today, the email string is no longer appearing in the subject of the email. Now, it just appears as "00-00-00 $email"

Is there something simple that I need to change here to make it work again? Thanks for any help that can be offered!

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 525
Joined: Mon Feb 22, 2016 5:52 pm

Thu Nov 09, 2017 1:37 pm

There's nothing wrong with the line that you have posted, try this line just before the line you posted:

Code: Select all

echo "E-mail address: $email <br>Can you see it?";
exit;
and see what is displayed, then backtrace it to the problem. But really you should be upgrading a an even more recent version of PHP as the version you have 'upgraded to' has reached its end of life.

dlc3172
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Nov 09, 2017 12:29 pm

Thu Nov 09, 2017 3:50 pm

I don't see the e-mail address appear when I add that bit of code. But I don't understand what I need to do to "backtrace" the problem. Before upgrading, the code worked just fine. I don't understand what the problem is. If nothing is wrong with the syntax (which I thought might have changed in the new PHP version), then what could be the problem?

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 525
Joined: Mon Feb 22, 2016 5:52 pm

Fri Nov 10, 2017 7:56 am

Something is changing the $email variable or putting it out of scope, you need to go back up through the listing to where it is first declared and see where the variable is changed, e.g.

Code: Select all

$email = 'dorris@summer.com';
echo $email, 'line 2<br>';

....

if ($email = 'fencepost@summer.com') { // line 437
  ......
}
.....
echo $email, 'line 624<br>';
So you find that $email is no longer "dorris@summer.com", and you go through the listing to find line 437 changes it.

Post Reply