Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-28-2004, 01:08 PM   #1 (permalink)
spinhead
Registered User
 
Join Date: Mar 2004
Posts: 1
spinhead is on a distinguished road
'OR' statement

Any idea why this statement evaluates to TRUE when $_POST[DisplayPhone] is 9876543210 ?

if (($_POST[DisplayPhone] == 0) OR ($_POST[DisplayPhone] == "") OR is_null($_POST[DisplayPhone]))

thanks

spinhead
spinhead is offline   Reply With Quote
Old 03-28-2004, 01:54 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
it must be the form you are sending it from. show us the code you are using to send it.

i re-created it here: http://codenewbie.com/test.php

Here is the code:
PHP Code:
<?
$_POST
[DisplayPhone] = "9876543210";

if((
$_POST[DisplayPhone] == 0) OR ($_POST[DisplayPhone] == "") OR is_null($_POST[DisplayPhone]))
{
  echo 
"true";
}
else
{
  echo 
"false";
}
?>
__________________
Mike
sde is offline   Reply With Quote
Old 03-28-2004, 09:26 PM   #3 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,713
redhead is on a distinguished road
hmmm... maybe you could try:
PHP Code:
 <? 
$_POST
[DisplayPhone] = "9876543210"

if((
$_POST[DisplayPhone] == 0) || ($_POST[DisplayPhone] == "") || is_null($_POST[DisplayPhone])) 

  echo 
"true"

else 

  echo 
"false"

?>
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 03-28-2004, 10:43 PM   #4 (permalink)
Epsilon
Regular Contributor
 
Epsilon's Avatar
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 127
Epsilon is on a distinguished road
If I'm not mistaken, couldn't it be simplified to this?
Code:
if(!$_POST[DisplayPhone]){...}
This will evaluate to true if $_POST[DisplayPhone] is 0 or an empty string, and false otherwise.
__________________
--Epsilon--
Epsilon is offline   Reply With Quote
Old 03-28-2004, 10:47 PM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
there are probably more efficient ways for him to test for 0, "" or null, .. but it seems as though he should be worrying (sp?) about this after he figures out why his form isn't submitting the DisplayPhone var correctly.

i got opposite results from him with his exact code.
__________________
Mike
sde is offline   Reply With Quote
Old 03-29-2004, 06:18 AM   #6 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Actually, empty() will test for all three.
bdl is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using ORDER BY in a select statement Epsilon PHP 3 08-22-2004 02:28 PM
mixing AND & OR in an sql statement sde PHP 1 03-15-2003 01:01 AM
How to add an error statement w00t Standard C, C++ 4 08-13-2002 10:54 PM


All times are GMT -8. The time now is 04:33 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting