ShadeSlayer Posted June 29, 2009 Share Posted June 29, 2009 Alright, so I had the code for something I've been doing, and I revised it because it was just feeding off of a different websites database. What happens now, as opposed to what happened before is huge: Before, it would enter the content to the database. Now, it sends me to a white screen. All I did were a few minor changes to make the script independent. Here is my old code: <?php include("../common.php"); // 3.0.0 (recent add: db upload) echo "<b>Glitch Editor</b><br /> Enter the game title in the title box, and paste the glitch code in the glitch box. **have all code in HTML<br /><br /> <form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\"> <table width=\"100%\"> <tr> <td width=\"100%\"> <b>Title:</b> <input type=\"text\" name=\"title\" value=\"\" /><br /> <b>Content:</b><textarea style=\"width: 100%; height: 100px;\" name=\"string\"></textarea> </td> </tr> <tr><td> <input type=\"hidden\" name=\"action\" value=\"output\" /> <input type=\"submit\" /> </td></tr> </table> </form>"; if ($_POST['action'] == "output") { $title = $_POST['title']; //, $string $content = $_POST['string']; $sql = "INSERT INTO pxb_glitches (date, title, content) VALUES (".date("U").", '".addslashes($title)."', '".nl2br(addslashes($content))."');"; if($exe = runQuery($sql)){ echo "Query Complete"; }else{ echo "Error entering values."; } } ?> As you can see there, the script got the database connection from a file in a different directory, and it just straight echo'd all the content. Here is the updated code: <?php include("config.php"); $pagetitle = "Add Glitches"; $output = "<b>Glitch Editor</b><br /> Enter the game title in the title box, and paste the glitch code in the glitch box. **have all code in HTML<br /><br /> <form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\"> <table width=\"100%\"> <tr> <td width=\"100%\"> <b>Title:</b> <input type=\"text\" name=\"title\" value=\"\" /><br /> <b>Content:</b><textarea style=\"width: 100%; height: 100px;\" name=\"string\"></textarea> </td> </tr> <tr><td> <input type=\"hidden\" name=\"action\" value=\"output\" /> <input type=\"submit\" /> </td></tr> </table> </form>"; if ($_POST['action'] == "output") { $title = $_POST['title']; //, $string $content = $_POST['string']; $sql = "INSERT INTO pxb_glitches (date, title, content) VALUES (".date("U").", '".addslashes($title)."', '".nl2br(addslashes($content))."');"; if($exe = runQuery($sql)){ $output = "Query Complete"; }else{ $output = "Error entering values."; } } $pagecontents = $output; include("layout.php"); ?> Here, I changed the location of the SQL connect file. All I did to the connect file was rename it, and move it to the local directory. Then I changed all the echo tags to $output so they could be echoed in an external file (which is included at the bottom). So at the very bottom, I include the layout file for the stuff to echo the content. My only problems with my scripts are submitting forms. I have a different page that displays the stuff in the database, and it displays the database info like it should. So I don't see how a few minor changes like this can screw up a whole script, and I can't find anything that could be causing this problem. Thanks a bunch for your help. Quote Link to comment https://forums.phpfreaks.com/topic/164029-solved-submit-button-loads-a-white-page-after-a-few-minor-changes/ Share on other sites More sharing options...
ShadeSlayer Posted June 29, 2009 Author Share Posted June 29, 2009 I just updated my config file, took out a bunch of useless stuff. <?php /* Configuration Page * Script by Alex Crooks Webdesign * Copyright 2009, protected under Creative Commons Licence */ include("settings.php"); error_reporting("E_ALL"); // Define Table Names define("table_achievements", $global['prefix']."_achievements"); define("table_cheats", $global['prefix']."_cheats"); define("table_comments", $global['prefix']."_comments"); define("table_glitches", $global['prefix']."_glitches"); define("table_proreviews", $global['prefix']."_proreviews"); define("table_reviews", $global['prefix']."_reviews"); define("table_unlockables", $global['prefix']."_unlockables"); define("table_walkthroughs", $global['prefix']."_walkthroughs"); // Connect to the database if($mysql['conn'] = mysql_connect($global['host'], $global['username'], $global['password'])) { $mysql['select'] = mysql_select_db($global['database'], $mysql['conn']); if(!$mysql['select']) { echo "<b>Error:</b> Failed connection to database.<br /><br />".mysql_error(); } } else { echo "<b>Error:</b> Failed connection to server.<br /><br />".mysql_error(); } // Retrieve Site Settings //$setting = "SELECT * FROM ".TABLE_SETTINGS; //$settings = mysql_fetch_array(mysql_query($setting)); // Retrieve Functions File //include($row['functions']); ?> The settings file consists of 5 things: database name, "localhost", username, password, and prefix. They all work fine (since the pages that retrieve database info work just fine). Quote Link to comment https://forums.phpfreaks.com/topic/164029-solved-submit-button-loads-a-white-page-after-a-few-minor-changes/#findComment-865313 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.