Forum Moderators: coopster

Message Too Old, No Replies

Can Someone explain what this small piece of code means?

Does the "!" mean not equal?

         

capulet_x

9:21 pm on Apr 28, 2007 (gmt 0)

10+ Year Member



function mirrorfile($url) {

global $sendfile;

if (!$sendfile['local']) $sendfile['local'] = basename($url);

// $log = "<p class=\"info\">Mirroring file <b>$url</b> ...</p>";

print $log;

$msg = 'An Error Occured';

henry0

9:25 pm on Apr 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look here [w3schools.com]

capulet_x

9:43 pm on Apr 28, 2007 (gmt 0)

10+ Year Member



Thanks, Henry...
I thought that was correct. Which means something else is wrong with my script.

eelixduppy

9:53 pm on Apr 28, 2007 (gmt 0)



Something is wrong with your script? Are you getting an error message? If so, which line is it?

>> Does the "!" mean not equal?

!=
means "not equal to". The
!
before the variable means "not". So if you have something like
if(!isset($var))...
you are saying that if isset returns false or, if the isset does NOT return true, proceed with the condition. Your example is similar. If the variable is null/empty/false/zero, do something...

capulet_x

10:48 pm on Apr 28, 2007 (gmt 0)

10+ Year Member



Really weird stuff...
I went over it again and again. Luckily, I made a backup of the script when it was working. I compared the two . The most obvious difference was that one had an error message and one did not so I changed the above to this:

function mirrorfile($url) {
global $sendfile;

if (!$sendfile['local']) $sendfile['local'] = basename($url);

// $log = "<p class=\"info\">Mirroring file <b>$url</b> ...</p>";

print $log;

$msg = '';

I'm glad it works but not so glad that I don't understand why it could make a difference. Truthfully, that's the only thing I changed.

capulet_x

10:55 pm on Apr 28, 2007 (gmt 0)

10+ Year Member



Okay, I wasn't totally forthcoming...
The original Error Message said this:

An Error Occured<a href="http://www.example.com/Uploadform.html">&nbsp;<--TRY AGAIN</a><br>Or Use Your Personal Email.

I truncated it above for simplicity. Could including a link in my error message cause my script to go awry?

eelixduppy

10:56 pm on Apr 28, 2007 (gmt 0)



>> Could including a link in my error message cause my script to go awry?

Well, if you do not properly escape the quotes correctly then yes, it can.

[edited by: eelixduppy at 11:00 pm (utc) on April 28, 2007]

capulet_x

11:00 pm on Apr 28, 2007 (gmt 0)

10+ Year Member



Could printing the message somehow conflict with the email being sent? Some sort of header conflict as I am using the PHP mail function?

I know a lot more could be concluded if I just posted the entire script here but it is so long and I would have to clean it up alot before I could post it.

capulet_x

11:05 pm on Apr 28, 2007 (gmt 0)

10+ Year Member



I had to use single quotes so as not to conflict with the quotes around the href URL. I tried encapsulating the entir thig in quotes but that wasn't working.

'An Error Occured<a href="http://www.example.com/uploadform.html">&nbsp;<--TRY AGAIN</a><br>Or Use Your Personal Email.';

eelixduppy

11:46 pm on Apr 28, 2007 (gmt 0)



If you are not getting any errors from this script, then it must be due to a logical error somewhere that is preventing the email from being sent correctly. If the email is working in your backup version, then I would use that one and go from there since you didn't change much since that save.

Echoing something to the browser will not affect the mail headers. However, if your mail headers aren't correct, then that may result in failure to send the email.

I'd revert back to the backup that you have if that works as you want.

henry0

11:35 am on Apr 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In similar case
I will over simplifiy my script then add a bit of code a litle at a time (or remove) till I find what is wrong, adding email, double quotes and other in email could be very frustrating if the syntax is not correct