ShootingBlanks Posted September 28, 2007 Share Posted September 28, 2007 Hello. I'm going to start off making this question very vague and general (as to not over-clutter it with needless info), but if you want more details I can provide them... Basically, I have a PHP page (that serves to update a table on a SQL database) that works fine locally. But when posted online, the page doesn't even show up. There's no error or anything - the page is just blank (white). It displays this way both on IE and Firefox... It is one of many pages in the site. The site itself has the user log in, and then they can post a new record to the database, delete a record, or update/edit a current record. All other pages are working/displaying fine, but it's just that "update/edit" page that comes up blank (and again - it works fine locally, just not online)... Any ideas? Need any more details/info? Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/71032-page-coming-up-blankwhite-online-but-works-fine-locally/ Share on other sites More sharing options...
dingus Posted September 28, 2007 Share Posted September 28, 2007 well depending on how the code is set out there may be an error that is not showing and that is causing the rest of the code to die if you would like to post the offending code (inside the code tags) it would be a lot easer to work out the problem Quote Link to comment https://forums.phpfreaks.com/topic/71032-page-coming-up-blankwhite-online-but-works-fine-locally/#findComment-357197 Share on other sites More sharing options...
ShootingBlanks Posted September 28, 2007 Author Share Posted September 28, 2007 there may be an error that is not showing and that is causing the rest of the code to die Wouldn't that also cause the code to die when running locally though too? Or am I wrong to say that?... if you would like to post the offending code (inside the code tags) it would be a lot easer to work out the problem Here's the entire page's code. I understand that it may be overkill, but I figured I'd post it all. Please let me know if you have any questions... <?php require_once('../Connections/SalesRepository.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "y,n"; $MM_donotCheckaccess = "false"; $lastDocsListed = $_SESSION['lastDocsListed']; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "loginfail.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } $MM_flag="MM_update"; if (isset($_POST[$MM_flag])) { if (empty($_POST['title_full']) || empty($_POST['title_short']) || empty($_POST['what_is']) || empty($_POST['why_use']) || empty($_POST['not_followed']) || empty($_POST['doc_content']) || !isset($_POST['categories'])) { $error = 'You must fill in all fields and select at least one category before updating the document'; } } if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""){ $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $stmt = $conn->stmt_init(); mysql_select_db($database_SalesRepository, $SalesRepository); $query_getValidUsers = "SELECT doc_user_lookup.user_id, doc_user_lookup.doc_id FROM doc_user_lookup WHERE doc_user_lookup.doc_id = ".$_GET['doc_id']." AND doc_user_lookup.user_id = ".$_SESSION['user_id']; $getValidUsers = mysql_query($query_getValidUsers, $SalesRepository) or die(mysql_error()); $row_getValidUsers = mysql_fetch_row($getValidUsers); $totalRows_getValidUsers = mysql_num_rows($getValidUsers); mysql_select_db($database_SalesRepository, $SalesRepository); $query_getFullAdmins = "SELECT users.admin_priv, users.user_id FROM users WHERE users.user_id = ".$_SESSION['user_id']; $getFullAdmins = mysql_query($query_getFullAdmins, $SalesRepository) or die(mysql_error()); $row_getFullAdmins = mysql_fetch_row($getFullAdmins); $totalRows_getFullAdmins = mysql_num_rows($getFullAdmins); $_SESSION['variable_set'] = $row_getValidUsers[0]; if ($row_getValidUsers[0] == $_SESSION['user_id'] || $row_getFullAdmins[0] == 'y') { $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } $colname_getDocument = "-1"; if (isset($_GET['doc_id'])) { $colname_getDocument = $_GET['doc_id']; } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { if (!isset($error)) { $title_full = trim($_POST['title_full']); $title_short = trim($_POST['title_short']); $what_is = trim($_POST['what_is']); $why_use = trim($_POST['why_use']); $not_followed = trim($_POST['not_followed']); $doc_content = trim($_POST['doc_content']); $live_doc = trim($_POST['live_doc']); $stmt = $conn->stmt_init(); $updateSQL = sprintf("UPDATE documents SET title_full=%s, title_short=%s, what_is=%s, why_use=%s, not_followed=%s, doc_content=%s, live_doc=%s, updated=%s, updated_by=%s WHERE doc_id=%s", GetSQLValueString($_POST['title_full'], "text"), GetSQLValueString($_POST['title_short'], "text"), GetSQLValueString($_POST['what_is'], "text"), GetSQLValueString($_POST['why_use'], "text"), GetSQLValueString($_POST['not_followed'], "text"), GetSQLValueString($_POST['doc_content'], "text"), GetSQLValueString($_POST['live_doc'], "text"), $_POST['updated'], GetSQLValueString($_SESSION['user_id'], "int"), GetSQLValueString($_POST['doc_id'], "int")); mysql_select_db($database_SalesRepository, $SalesRepository); $Result1 = mysql_query($updateSQL, $SalesRepository) or die(mysql_error()); $doc_id = $_GET['doc_id']; // initialize an array for categories to be inserted in the lookup table $categories = array(); // loop through the selected categories to build values string for INSERT query if (isset($_POST['categories'])) { foreach ($_POST['categories'] as $cat_id) { if (is_numeric($cat_id)) { $categories[] = "($doc_id, $cat_id)"; } } } // join values as a comma-separated string if (!empty($categories)) { $categories = implode(',', $categories); $noCats = false; } else { $noCats = true; } // delete existing references to the image in the lookup table $deleteCats = "DELETE FROM doc_cat_lookup WHERE doc_id = $doc_id"; $conn->query($deleteCats); // if catagories have been selected, insert the new values in the lookup table if (!$noCats) { $updateCats = "INSERT INTO doc_cat_lookup (doc_id, cat_id) VALUES $categories"; $conn->query($updateCats); } if (!isset($uzerz)) { // get details of the users the document is associated with in the lookup table $user_query = "SELECT * FROM doc_user_lookup WHERE doc_id = $colname_getDocument"; $result = $conn->query($user_query); // initialize an array to store the categories from the lookup table $uzerz = array(); // loop through the result of the lookup table query to populate the array while ($row = $result->fetch_assoc()) { $uzerz[] = $row['user_id']; } $result->free_result(); } // initialize an array for users to be inserted in the lookup table $users = array(); // loop through the selected users to build values string for INSERT query if ($_SESSION['admin'] == "n") { foreach ($uzerz as $user_id) { if (is_numeric($user_id)) { $users[] = "($doc_id, $user_id)"; } } } elseif (isset($_POST['users'])) { foreach ($_POST['users'] as $user_id) { if (is_numeric($user_id)) { $users[] = "($doc_id, $user_id)"; } } } // join values as a comma-separated string if (!empty($users)) { $users = implode(',', $users); $noUsers = false; } else { $noUsers = true; } // delete existing references to the image in the lookup table $deleteUsers = "DELETE FROM doc_user_lookup WHERE doc_id = $doc_id"; $conn->query($deleteUsers); // if catagories have been selected, insert the new values in the lookup table if (!$noUsers) { $updateUsers = "INSERT INTO doc_user_lookup (doc_id, user_id) VALUES $users"; $conn->query($updateUsers); } $updateGoTo = $lastDocsListed; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } // if the record has been inserted, clear the POST array $_POST = array(); } mysql_select_db($database_SalesRepository, $SalesRepository); $query_getDocument = sprintf("SELECT * FROM documents WHERE doc_id = %s", GetSQLValueString($colname_getDocument, "int")); $getDocument = mysql_query($query_getDocument, $SalesRepository) or die(mysql_error()); $row_getDocument = mysql_fetch_assoc($getDocument); $totalRows_getDocument = mysql_num_rows($getDocument); mysql_select_db($database_SalesRepository, $SalesRepository); $query_getCategories = "SELECT * FROM categories"; $getCategories = mysql_query($query_getCategories, $SalesRepository) or die(mysql_error()); //$row_getCategories = mysql_fetch_assoc($getCategories); $totalRows_getCategories = mysql_num_rows($getCategories); // get details of the categories the document is associated with in the lookup table $cat_query = "SELECT * FROM doc_cat_lookup WHERE doc_id = $colname_getDocument"; $result = $conn->query($cat_query); // initialize an array to store the categories from the lookup table $cats = array(); // loop through the result of the lookup table query to populate the array while ($row = $result->fetch_assoc()) { $cats[] = $row['cat_id']; } $result->free_result(); // get details of the users the document is associated with in the lookup table $user_query = "SELECT * FROM doc_user_lookup WHERE doc_id = $colname_getDocument"; $result = $conn->query($user_query); // initialize an array to store the categories from the lookup table $uzerz = array(); // loop through the result of the lookup table query to populate the array while ($row = $result->fetch_assoc()) { $uzerz[] = $row['user_id']; } $result->free_result(); mysql_select_db($database_SalesRepository, $SalesRepository); $query_getUsers = "SELECT users.user_id, CONCAT(users.last_name,', ', users.first_name) AS fullname FROM users ORDER BY users.last_name"; $getUsers = mysql_query($query_getUsers, $SalesRepository) or die(mysql_error()); $totalRows_getUsers = mysql_num_rows($getUsers); } else { header('Location: loginfail.php'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Update Document</title> <script src="../includes/textEditor.js"></script> <link href="../includes/admin.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>Update document</h1> <?php if (isset($error)) { ?> <p class="warning"><?php echo $error; ?></p> <?php } ?> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table> <tr valign="baseline"> <td width="157" align="right" nowrap>Full Title (100 chars max):</td> <td colspan="3"><input class="title" type="text" name="title_full" value="<?php echo $row_getDocument['title_full']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Short Title (40 chars max):</td> <td colspan="3"><input class="title" type="text" name="title_short" value="<?php echo $row_getDocument['title_short']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right" valign="top">Categories:</td> <td width="176"><select name="categories[]" size="11" multiple="multiple" id="categories"> <?php // build multiple choice list with contents of categories table while($row = mysql_fetch_assoc($getCategories)) { echo '<option value="'.$row['cat_id'].'"'; if (in_array($row['cat_id'], $cats)) { echo ' selected="selected"'; } echo '>'.$row['cat_name'].'</option>'; } ?> </select> </td> <td nowrap="nowrap" align="right" valign="top">Users:</td> <td><select name="users[]" size="11" multiple="multiple" id="users"> <?php // build multiple choice list with contents of categories table while($row = mysql_fetch_assoc($getUsers)) { echo '<option value="'.$row['user_id'].'"'; if (in_array($row['user_id'], $uzerz)) { echo ' selected="selected"'; } echo '>'.$row['fullname'].'</option>'; } ?> </select></td> </tr> <?php if ($_SESSION['admin'] == "y") { ?> <?php } ?> <tr valign="baseline"> <td nowrap align="right" valign="top">What is it?:</td> <td colspan="3"><textarea class="short" name="what_is" cols="50" rows="5"><?php echo $row_getDocument['what_is']; ?></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="right" valign="top">Why use it?:</td> <td colspan="3"><textarea class="short" name="why_use" cols="50" rows="5"><?php echo $row_getDocument['why_use']; ?></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="right" valign="top">If procedure is not followed?:</td> <td colspan="3"><textarea class="short" name="not_followed" cols="50" rows="5"><?php echo $row_getDocument['not_followed']; ?></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="right" valign="top">Information:</td> <td colspan="3"><textarea name="doc_content" cols="50" rows="5"><?php echo $row_getDocument['doc_content']; ?></textarea> <script type="text/javascript">edToolbar();</script> <script type="text/javascript">var edCanvas = document.getElementById('information');</script></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right" valign="top"> </td> <td colspan="3"> </td> </tr> <?php if ($_SESSION['admin'] == "y") { ?> <tr valign="baseline"> <td nowrap align="right" valign="top">Live:</td> <td colspan="3"> <input <?php if (!$_POST && !(strcmp($row_getDocument['live_doc'],"y"))) { echo "checked=\"checked\""; } elseif ($_POST && !(strcmp($_POST['live_doc'],"y"))) { echo "checked=\"checked\""; } ?> name="live_doc" type="radio" value="y" id="live" /> <label for="live">Yes</label> <input <?php if (!$_POST && !(strcmp($row_getDocument['live_doc'],"n"))) { echo "checked=\"checked\""; } elseif ($_POST && !(strcmp($_POST['live_doc'],"n"))) { echo "checked=\"checked\""; } ?> name="live_doc" type="radio" id="not_live" value="n" /> <label for="not_live">No</label> </td> </tr> <?php } ?> <tr valign="baseline"> <td nowrap align="right"> </td> <td colspan="3"><input type="submit" value="Update document"></td> </tr> </table> <input type="hidden" name="updated" value="NOW()"> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="doc_id" value="<?php echo $row_getDocument['doc_id']; ?>"> <?php if ($_SESSION['admin'] == "n") { ?> <input type="hidden" name="live_doc" value="<?php echo $row_getDocument['live_doc']; ?>"> <?php } ?> </form> <p> <a href="<?php echo $lastDocsListed; ?>">Back to document list</a></p> </body> </html> <?php mysql_free_result($getDocument); mysql_free_result($getCategories); mysql_free_result($getUsers); ?> I can also set up a test/dummy login for you to actually go live onto the system that I made online to check it out. If that would help too, let me know and I'll set it up and post the un/pw here. Thanks!!!... Quote Link to comment https://forums.phpfreaks.com/topic/71032-page-coming-up-blankwhite-online-but-works-fine-locally/#findComment-357296 Share on other sites More sharing options...
ShootingBlanks Posted September 28, 2007 Author Share Posted September 28, 2007 I found where the problem is!!! I kept commenting out various sections, then saving and re-loading the file to the server. Here is where my problem code is (this is pulled out of the long code I posted above): // get details of the categories the document is associated with in the lookup table $cat_query = "SELECT * FROM doc_cat_lookup WHERE doc_id = $colname_getDocument"; $result = $conn->query($cat_query); // initialize an array to store the categories from the lookup table $cats = array(); // loop through the result of the lookup table query to populate the array while ($row = $result->fetch_assoc()) { $cats[] = $row['cat_id']; } $result->free_result(); // get details of the users the document is associated with in the lookup table $user_query = "SELECT * FROM doc_user_lookup WHERE doc_id = $colname_getDocument"; $result = $conn->query($user_query); // initialize an array to store the categories from the lookup table $uzerz = array(); // loop through the result of the lookup table query to populate the array while ($row = $result->fetch_assoc()) { $uzerz[] = $row['user_id']; } $result->free_result(); So, can anyone help? I'm thinking that maybe that particular code isn't compatible with the verison of PHP or MySQL that is on my server, but it IS compatible with the version that is on my local computer? Is that a possiblity? If that IS a possible reason, what are my options for a solution? Thanks!... Quote Link to comment https://forums.phpfreaks.com/topic/71032-page-coming-up-blankwhite-online-but-works-fine-locally/#findComment-357400 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.