twilitegxa Posted August 25, 2008 Share Posted August 25, 2008 Trying to figure out why this code is generating a blank page with no errors instead of what is supposed to show up. Here is the code: <?php //connect to database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("smrpg",$conn) or die(mysql_error()); $display_block = "<h1>My Categories</h1> <p>elect a category to see its items.</p>"; //show categories first $get_cats = "select id, cat_title, cat_desc from store_categories order by cat_title"; $get_cats_res = mysql_query($get_cats) or die(mysql_error()); if (mysql_num_rows($get_cats_res) < 1) { $display_block = "<p><em>Sorry, no categories to browse.</em></p>"; } else { while ($cats = mysql_fetch_array($get_cats_res)) { $cat_id = $cats[id]; $cat_title = strtoupper(stripslashes($cats[cat_title])); $cat_desc = stripslashes($cats[cat_desc]); $display_block .= "<p><strong><a href=\"$_SERVER[php_SELF]?cat_id=$cat_id\">$cat_title</a></strong> <br />$cat_desc</p>"; if ($_GET[cat_id] == $cat_id) { //get items $get_items = "select id, item_title, item_price from store_items where cat_id = $cat_id order by item_title"; $get_items_res = mysql_query($get_items) or die(mysql_error()); if (mysql_num_rows($get_items_res) < 1) { $display_block = "<p><em>Sorry, no items in this category.</em></p>"; } else { $display_block .= "<ul>"; while ($items = mysql_fetch_array($get_items_res)) { $item_id = $items[id]; $item_title = stripslashes($items[item_title]); $item_price = $items[item_price]; $display_block .= "<li><a href=\"showitem.php?item_id=$item_id\">$item_title</a> </strong> (\$$item_price)"; } $display_block .= "</ul>"; } } } } ?> <html> <head> <title>My Categories</title> </head> <body> <? print $display_block; ?> </body> </html> Can anyone see what the problem is? I can't figure out what I'm missing or doing wrong? Link to comment https://forums.phpfreaks.com/topic/121322-solved-php-showing-blank-page/ Share on other sites More sharing options...
trq Posted August 25, 2008 Share Posted August 25, 2008 You might try changing.... <? print $display_block; ?> to.... <?php print $display_block; ?> Link to comment https://forums.phpfreaks.com/topic/121322-solved-php-showing-blank-page/#findComment-625497 Share on other sites More sharing options...
Xyphon Posted August 25, 2008 Share Posted August 25, 2008 Err... Get rid of the <? and put <?PHP. <? does not open PHP statements. Link to comment https://forums.phpfreaks.com/topic/121322-solved-php-showing-blank-page/#findComment-625505 Share on other sites More sharing options...
Ken2k7 Posted August 25, 2008 Share Posted August 25, 2008 Err... Get rid of the <? and put <?PHP. <? does not open PHP statements. I think it can. Link to comment https://forums.phpfreaks.com/topic/121322-solved-php-showing-blank-page/#findComment-625507 Share on other sites More sharing options...
twilitegxa Posted August 26, 2008 Author Share Posted August 26, 2008 I changed it from <? to <?php and it worked for this one. :-) Thanks! Link to comment https://forums.phpfreaks.com/topic/121322-solved-php-showing-blank-page/#findComment-625527 Share on other sites More sharing options...
PFMaBiSmAd Posted August 26, 2008 Share Posted August 26, 2008 Consistency counts in programming. Always use the full <?php tag. The full <?php tag will always work, while the short tag is dependent on server settings and you won't always be on a server where you can enable short tags. Link to comment https://forums.phpfreaks.com/topic/121322-solved-php-showing-blank-page/#findComment-625531 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.