Jump to content


Photo

IF(variable = NULL)


  • Please log in to reply
5 replies to this topic

#1 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 02 April 2006 - 01:40 AM

it wont work...heres the code

Code: 

if($first = NULL 
$last = NULL 
$gun = NULL 
$age = NULL 
$saying = NULL 
$email = NULL 
$phone = NULL 
$users = NULL 
$passs = NULL){ 
.........


how do i make it work?
"Syntax error" .. WHERE THE **** IS IT?!

#2 play_

play_
  • Staff Alumni
  • Advanced Member
  • 717 posts

Posted 02 April 2006 - 01:46 AM

Not sure what youre trying to do. Im assuming comare. so here it goes

if($first = NULL or
$last = NULL or
$gun = NULL or
$age = NULL or
$saying = NULL or
$email = NULL or
$phone = NULL or
$users = NULL or
$passs = NULL){


regex.kat.sh --- regex library
u.kat.sh ---- url shortener
tabbit.org ---- tabbed pastebin

#3 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 02 April 2006 - 02:07 AM

im validating a form....i want it so if 1 or more of them is null then not to send the form....i have the rest of the code...just cant get that part
"Syntax error" .. WHERE THE **** IS IT?!

#4 play_

play_
  • Staff Alumni
  • Advanced Member
  • 717 posts

Posted 02 April 2006 - 03:09 AM

Then that should work but its not a good method.

When the user presses submit, you should check like this.

if(empty($username)) {
echo "Must enter a username";
$username = false;
} else {
escape_data($username);
$username = TRUE;
}


regex.kat.sh --- regex library
u.kat.sh ---- url shortener
tabbit.org ---- tabbed pastebin

#5 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 02 April 2006 - 03:09 AM

use the is_null() function

if(is_null($var) || is_null($anotherVar))

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 April 2006 - 09:05 AM

You'll want to code your if statement like so:
if(is_null($first) || is_null($last) || is_null($gun) || is_null($age) || is_null($saying) || is_null($email) || is_null($phone) || is_null($users) || is_null($pass))
{
    echo "Please fill in all fields!";
}
else
{
    //process form data
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users