troubleshooting Question

How to exit just this php statement if it evaluates to true but, continue running other php scripts after it's closing tag?

Avatar of evibesmusic
evibesmusicFlag for United States of America asked on
PHP
3 Comments1 Solution1892 ViewsLast Modified:
Hello,

I think that I have a simple request...If the query below evaluates to true, I would like to exit the rest of php statement and then run the rest of the php statements on the page.

If it evaluates to true, I don't want to print any errors, no messages, I just want the page to act like the script was not even there.  Is that possible?

So basically, according to the script, if the sub_parentcat = '$parent1' AND the 'sub_catname' = '' or is empty, exit the script.  If the contents of 'sub_catname' equal anything else then blank or emply, continue with the script...then move on.

EVibesMusic
<?
		include('scripts/includes.php');
		include('scripts/dbconnect.php');
		$parent1 = "Art & Style";
			//When the category name 'cat_name' and the sub-category parent 'sub_parentcat' are equal pull the info from the db 
			$data2 = @mysql_query("SELECT * FROM sub_categories WHERE sub_parentcat='".$parent1."' AND sub_catname='' "); 
			//If there is an error return the error message.
			if ($data2) 
			{ 
			 // DONT SHOW ANYTHING JUST EXIT THIS STATEMENT AND CONTINUE TO EVALUATE THE REST OF THE PHP STATEMENTS ON THE PAGE
			}
			echo '<div class="glossymenu"><a class="menuitem submenuheader" href="#" >'.$parent1.'</a><div class="submenu">';
			//If no error store the information from the db in the variable '$getinfo2' and create the sub-categories
			while ($getinfo2 = mysql_fetch_array($data2))
			{
			echo '
			<ul>
			<li style="background-image:url($page_home/scripts/images/arrowbullet.png); background-position:left; background-repeat:no-repeat; padding-left:10px; margin-left:5px;">
			<a href="../test/ask.php?cat='.$parent1.'&amp;sub_cat='.$getinfo2['sub_catname'].'" title="'.$getinfo2['sub_catname'].'"">
			'.$getinfo2['sub_catname'].'
			</a>
			</li>
			</ul>
			';
}
			echo '</div></div>';
?>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros