Solved

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

Posted on 2009-07-07
3
893 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 125 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
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 …

821 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