Mencarta Posted February 3, 2010 Share Posted February 3, 2010 When I use "exit;" inside a php script that is inside the middle of the page php doesn't display the rest of the page! Any alternative?Sample: <body><?php$a = 1if ($a != 2) { exit; }?>Hia!</body> Sample Output(Source Code): <body> Link to comment Share on other sites More sharing options...
Ingolme Posted February 3, 2010 Share Posted February 3, 2010 That's precisely what "exit" is for. It terminates the script. What are you trying to do? Link to comment Share on other sites More sharing options...
Mencarta Posted February 3, 2010 Author Share Posted February 3, 2010 Validate my page, lol. Link to comment Share on other sites More sharing options...
Ingolme Posted February 3, 2010 Share Posted February 3, 2010 Well, don't use an exit statement.Why do you need it? Link to comment Share on other sites More sharing options...
Mencarta Posted February 3, 2010 Author Share Posted February 3, 2010 So my script doesn't load non-existent items from the database. Link to comment Share on other sites More sharing options...
Ingolme Posted February 3, 2010 Share Posted February 3, 2010 You can check if mysql_num_rows() is 0 and then print something else if it is: if(mysql_num_rows($query)) { // Show the database information} else { echo "There are no database entries.";} Link to comment Share on other sites More sharing options...
Mencarta Posted February 3, 2010 Author Share Posted February 3, 2010 OMG! You stole my idea! lol Link to comment Share on other sites More sharing options...
Ingolme Posted February 3, 2010 Share Posted February 3, 2010 Are you trying to waste my time? Link to comment Share on other sites More sharing options...
Mencarta Posted February 3, 2010 Author Share Posted February 3, 2010 My code still doesn't work...listcast.php <?php require_once("dbconnect.php"); $updates = array(); $sql = "SELECT * FROM cast"; $result = mysql_query($sql); if (mysql_num_rows($result) == 0) { echo "No Cast..."; exit; } else { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $updates[] = $row["person"]; } sort($updates); echo "<table border=\"0px\">"; foreach ($updates as &$id) { echo "<tr>"; $select = "SELECT * FROM meets WHERE id='$id'"; $result = mysql_query($select); $row = mysql_fetch_array($result); echo "<td>".$row["character"]."</td><td>".$row["person"]."</td>"; echo "</tr>"; } echo "</table>"; }?> Link to comment Share on other sites More sharing options...
Mencarta Posted February 3, 2010 Author Share Posted February 3, 2010 Nevermind, forgot to take out the exit statement. Silly me. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.