el-sid Posted August 2, 2009 Share Posted August 2, 2009 hi all ive been trying to debug this script but am getting nowhere. when executed in apache, it shows a blank screen and nothing on page source. ive turned on error reporting to E_ALL but i get no output. any ideas <?php ini_set("display_errors",1); error_reporting(E_ALL); include 'db.inc'; include 'include.inc'; include 'error.inc'; set_error_handler("errorHandler"); if(empty($_GET["commission_code"])) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > <html> <head><title>Commission Codes</title></head> <body> <h3>Enter a commission code to edit</h3> <form method="get" action="salescom.search.php"> <table> <tr> <td>Commission Code:</td> <td><input type="text" name="commission_code" size="10"></td> </tr> <tr> <td></td> <td><input type= "submit" value= "Edit"></td> </tr> </table> </form> </body> </html> <?php } else { //connect to a session session_start(); $commission_code = trim(clean($_GET["commission_code"],10)); if (!($connection = @ mysql_connect($hostName, $username, $password))) die("Could not connect to database"); if (!mysql_select_db($databaseName, $connection)) showerror(); $searchQuery = "SELECT * FROM sales_comm_ref WHERE commission_code = '$commission_code'"; if (!($result = @ mysql_query ($searchQuery,$connection))) showerror(); if ($row = mysql_fetch_array($result)) { $formVars = array(); $formVars["commission_code"] = $row["commission_code"]; $formVars["retail"] = $row["retail"]; $formVars["wholesale"] = $row["wholesale"]; $_SESSION["formVars"] = $formVars; header("Location:salescom.edit.php"); exit(); } else { ?> <html> <head><title></title></head> <body bgcolor ="white"> <font color="red" size="4">Error:</font> <font size="4"> The commisson code does not<br> exist in the database</font><br><br> <a href="salescom.search.php">Back to Search</a><br> </body> </html> <?php } } ?> Link to comment https://forums.phpfreaks.com/topic/168560-solved-php-white-screen/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 2, 2009 Share Posted August 2, 2009 Probably because you are setting a custom error handler in the code and it is not handling errors correctly. Temporarily comment out the set_error_handler("errorHandler"); statement. Link to comment https://forums.phpfreaks.com/topic/168560-solved-php-white-screen/#findComment-889161 Share on other sites More sharing options...
el-sid Posted August 2, 2009 Author Share Posted August 2, 2009 thanks for the reply. ive tried that and am still getting the same results Link to comment https://forums.phpfreaks.com/topic/168560-solved-php-white-screen/#findComment-889163 Share on other sites More sharing options...
PFMaBiSmAd Posted August 2, 2009 Share Posted August 2, 2009 Blank php pages are usually due to fatal parse errors. The posted code did not produce a parse error but I also don't have the include files. You should set error_reporting to E_ALL and display_errors to ON in your php.ini (stop and start your web server to get any change made to php.ini to take effect) because setting those two values in the script won't have any effect for a parse error because the code is never executed to turn on the settings. Edit: Any chance one of the include files is modifying the error_reporting or display_errors settings? Link to comment https://forums.phpfreaks.com/topic/168560-solved-php-white-screen/#findComment-889169 Share on other sites More sharing options...
el-sid Posted August 3, 2009 Author Share Posted August 3, 2009 ok..ive tried the error reporting suggestions but nothing comes out of stdout. these are the include files db.inc <?php $hostName = "localhost"; $databaseName = "sps"; $username = "root"; $password = "pass"; ?> <?php // Trigger an error condition function showerror() { echo mysql_error(); if (mysql_errno() || mysql_error()) trigger_error("MySQL error: " . mysql_errno() . " : " . mysql_error(), E_USER_ERROR); else trigger_error("Could not connect to DBMS", E_USER_ERROR); } // Abort on error. Deletes session variables to leave // us in a clean state function errorHandler($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_USER_NOTICE: case E_USER_WARNING: case E_WARNING: case E_NOTICE: case E_CORE_WARNING: case E_CORE_NOTICE: case E_COMPILE_WARNING: break; case E_USER_ERROR: case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_COMPILE_ERROR: session_start(); if (isset($_SESSION["message"])) unset($_SESSION["message"]); if (isset($_SESSION["order_no"])) unset($_SESSION["order_no"]); $errorString = "Sales system error: $errstr (# $errno).<br>\n" . "Please report the following to the administrator:<br>\n" . "Error in line $errline of file $errfile.<br>\n"; // Send the error to the administrator by email // error_log($errorString, 1, "[email protected]"); ?> <h2>The sales information system is temporarily unavailable</h2> The following has been reported to the administrator: <br><b><font color="red"><?php echo $errorString; ?></b></font> <?php // Stop the system die(); default: break; } } ?> include.inc <?php ini_set("display_errors","1"); error_reporting("E_ALL"); // This file contains functions used in more than // one script in the cart module include 'db.inc'; include 'error.inc'; // Untaint user data function clean($input, $maxlength) { $input = substr($input, 0, $maxlength); $input = EscapeShellCmd($input); return ($input); } // Display any messages that are set, and then // clear the message function showMessage() { // Is there an error message to show the user? if (isset($_SESSION["message"])) { echo "<h3><font color=\"red\">{$_SESSION["message"]}</font></h3>"; // Clear the error message unset($_SESSION["message"]); } } // Show whether the user is logged in or not function showLogin() { // Is the user logged in? if (isset($_SESSION["loginUsername"])) echo "<p align=\"right\">You are currently logged in as <b>" . $_SESSION["loginUsername"]. "</b></p>\n"; else echo "<p align=\"right\">You are currently not logged in</p>\n"; } // Show the user a login or logout button. Also, show them membership // buttons as appropriate. function loginButtons() { if (isset($_SESSION["loginUsername"])) { echo "\n\t<td><input type=\"submit\" name=\"logout\" value=\"Logout\"></td>\n"; echo "\n\t<td><input type=\"submit\" name=\"account\" value=\"Change Details\"></td>\n"; } else { echo "\t<td><input type=\"submit\" name=\"login\" value=\"Login\"></td>\n"; echo "\n\t<td><input type=\"submit\" name=\"account\" value=\"Become a Member\"></td>\n"; } } // Get the cust_id using loginUsername function getCustomerID($email, $connection) { global $databaseName; global $username; global $password; global $hostName; $open = false; // If a connection parameter is not passed, then // use our own connection to avoid any locking problems if (!isset($connection)) { if (!($connection = @ mysql_connect($hostName, $username, $password))) showerror(); if (!mysql_select_db($databaseName, $connection)) showerror(); $open = true; } // We find the cust_id through the users table, using the // session variable holding their loginUsername. $query = "SELECT customer_code FROM customer WHERE email = \"$email\""; if (($result = @ mysql_query ($query, $connection))) $row = mysql_fetch_array($result); else showerror(); if ($open == true) @ mysql_close($connection); return($row["salesman_code"]); } function getSalesmanID($loginUsername, $connection) { global $databaseName; global $username; global $password; global $hostName; $open = false; // If a connection parameter is not passed, then // use our own connection to avoid any locking problems if (!isset($connection)) { if (!($connection = @ mysql_connect($hostName, $username, $password))) showerror(); if (!mysql_select_db($databaseName, $connection)) showerror(); $open = true; } // We find the cust_id through the users table, using the // session variable holding their loginUsername. $query = "SELECT salesman_code FROM login WHERE username = \"$loginUsername\""; if (($result = @ mysql_query ($query, $connection))) $row = mysql_fetch_array($result); else showerror(); if ($open == true) @ mysql_close($connection); return($row["salesman_code"]); } function getStockID($item_name, $connection) { global $databaseName; global $username; global $password; global $hostName; $open = false; // If a connection parameter is not passed, then // use our own connection to avoid any locking problems if (!isset($connection)) { if (!($connection = @ mysql_connect($hostName, $username, $password))) showerror(); if (!mysql_select_db($databaseName, $connection)) showerror(); $open = true; } // We find the cust_id through the users table, using the // session variable holding their loginUsername. $query = "SELECT stock_code FROM stock WHERE item_name = \"$item_name\""; if (($result = @ mysql_query ($query, $connection))) $row = mysql_fetch_array($result); else showerror(); if ($open == true) @ mysql_close($connection); return($row["stock_code"]); } function selectDistinct ($connection, $tableName, $columnName, $pulldownName, $additionalOption, $defaultValue) { $defaultWithinResultSet = FALSE; // Query to find distinct values of $columnName // in $tableName $distinctQuery = "SELECT DISTINCT $columnName FROM $tableName"; // Run the distinctQuery on the databaseName if (!($resultId = @ mysql_query ($distinctQuery, $connection))) showerror(); // Retrieve all distinct values $i = 0; while ($row = @ mysql_fetch_array($resultId)) $resultBuffer[$i++] = $row[$columnName]; // Start the select widget echo "\n<select name=\"$pulldownName\">"; // Is there an additional option? if (isset($additionalOption)) // Yes, but is it the default option? if ($defaultValue == $additionalOption) // Show the additional option as selected echo "\n\t<option selected>$additionalOption"; else // Just show the additional option echo "\n\t<option>$additionalOption"; // check for a default value if (isset($defaultValue)) { // Yes, there's a default value specified // Check if the defaultValue is in the // database values foreach ($resultBuffer as $result) if ($result == $defaultValue) // Yes, show as selected echo "\n\t<option selected>$result"; else // No, just show as an option echo "\n\t<option>$result"; } // end if defaultValue else { // No defaultValue // Show database values as options foreach ($resultBuffer as $result) echo "\n\t<option>$result"; } echo "\n</select>"; } // end of function ?> thanks again for the help Link to comment https://forums.phpfreaks.com/topic/168560-solved-php-white-screen/#findComment-889178 Share on other sites More sharing options...
el-sid Posted August 3, 2009 Author Share Posted August 3, 2009 sorry..didnt see your edited message there. i just commented out the error.inc file and the set_error_handler function and it gave me the desired output. still not quite sure how that worked out however its redirection leads..again..to a white screen of the same page according to the address bar Link to comment https://forums.phpfreaks.com/topic/168560-solved-php-white-screen/#findComment-889180 Share on other sites More sharing options...
el-sid Posted August 3, 2009 Author Share Posted August 3, 2009 it worked after clearing out some session variables and commenting out the error includes and functions. i still dont get quite how that worked but it did. thanks for the help PFMaBiSmAd Link to comment https://forums.phpfreaks.com/topic/168560-solved-php-white-screen/#findComment-889186 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.