Jump to content


Photo

Line breaks in if statements


  • Please log in to reply
1 reply to this topic

#1 gerkintrigg

gerkintrigg
  • Members
  • PipPipPip
  • Magician
  • 828 posts
  • LocationBristol, UK
  • Age:37

Posted 27 October 2006 - 10:43 PM

Hello
How do i check if a variable has a line break in an if statement? I've broken a database field (address) into variables for each line and i noticed that if I left the line blank (with only a line break in it) it acts all goofy...

Can anyone help?
I tried this:
<?php 
			if (($_REQUEST['e']==y)&&(($city=='')||(nl2br($city)=='<br />'))){
				echo 'bgcolor="#FF9999"';
			}
			else{
				echo'bgcolor="#FFFFFF"';
			}
			?>

Neil Trigger - http://www.ghostlypublishing.co.uk - Ghostly Publishing - Children's Fantasy Books

#2 Skatecrazy1

Skatecrazy1
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts
  • LocationSouthern California

Posted 27 October 2006 - 10:48 PM

try
<?php 
			if (($_REQUEST['e'] == "y") && (($city == null) || ( nl2br( $city ) == "<br />"))){
				echo "bgcolor=\"#FF9999\"";
			} else {
				echo "bgcolor=\"#FFFFFF\"";
			}
?>

fuck it or fight it




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users