Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
"Else" and "if" function help!
Old 05-28-2005, 02:11 PM "Else" and "if" function help!
Junior Talker

Posts: 3
Trades: 0
Hello,
I have created an area on my site where people can tell a friend about the site. The script worked fine, but you could leave all the fields blank and no error message would appear, so it was pretty basic. I have tried to add an If and Else function, but keep getting an error: "Parse error: parse error, unexpected T_BOOLEAN_OR, expecting ')' in /home/randomsh/public_html/Tell-done.php on line 605"

This is the section of the script with the problem:

if (empty($friendemail || friendname || yourmessage || yourname));
echo "Please pretty back and make sure you fill in all the fields";

else {mail($to, $sub, $mes, $headers);
echo "<center>Thank you $yourname,<br>Your message has been sent to your friend $friendname</center>"; }

Anyone got an ideas?
Many thanks
Chris Harris
harrishcris is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-28-2005, 02:28 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you're missing the $ on your variable names
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-28-2005, 03:44 PM
Marvin Le Rouge's Avatar
Skilled Talker

Posts: 52
Trades: 0
Hi,

To be more precise, you're missing $ in your condition, AND you got a ; which shouldn't be there :
Code:
if (empty($friendemail || friendname || yourmessage || yourname));
should be written
Code:
if (empty($friendemail || $friendname || $yourmessage || $yourname))
The ; ends the instruction, so the condition will do ";", that is to say "nothing", and the next line will always be executed, since it doesn't depend on the condition.
A contional statement should be written
Code:
if (a) b;
or
Code:
if (a) {multiple instructions}
Marvin Le Rouge is offline
Reply With Quote
View Public Profile
 
Old 05-28-2005, 04:00 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
There are a number of errors in your code. Try this:
PHP Code:
if (empty($friendemail) || empty($friendname) || empty($yourmessage) || empty($yourname)) {
    echo 
"Please pretty back and make sure you fill in all the fields";

} else {
    
mail($to$sub$mes$headers);
    echo 
"<center>Thank you $yourname,<br>Your message has been sent to your friend $friendname</center>"

Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 05-29-2005, 10:39 AM
Junior Talker

Posts: 3
Trades: 0
It works now, thank you very much.
harrishcris is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to "Else" and "if" function help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21615 seconds with 12 queries