Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using "if" and "strlen()" or "empty()" in PHP

Posted on 2009-07-07
3
Medium Priority
?
904 Views
Last Modified: 2013-12-13
this should be simple, i think.

i need to determine if $sDancers does not contain data and not execute an email. if $sDancers does have data, then send the email.

this is what i have right now, which doesn't work.

could i use empty() instead?
$Zval  = 0;
	
	if (!strlen($sDancers) <> $Zval) {
		mail ($tomb, $subject1, $body1, $header); //email to mario
		}

Open in new window

0
Comment
Question by:ironpen45
  • 2
3 Comments
 

Expert Comment

by:mpete510
ID: 24797704
I believe removing the ! from the if statement should fix your problem.
$Zval  = 0;
        
        if (strlen($sDancers) <> $Zval) {
                mail ($tomb, $subject1, $body1, $header); //email to mario
                }

Open in new window

0
 

Accepted Solution

by:
mpete510 earned 500 total points
ID: 24797712
Also, inequality in PHP is done with !=, not <>.
if (strlen($sDancers) != $Zval)

Open in new window

0
 

Author Closing Comment

by:ironpen45
ID: 31600771
that did it! thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question