I made a script the other day just for a quick thing, and when doing that, I just echoed everything from the file and included an external mysql connect file.

Today, I decided I'd make the script more independent and better, so I rewrote a few things and made a new mysql connect file. Except, now, I have a problem: Clicking submit loads a blank, white page.

Here is my old code, which worked just fine:

<?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, it includes a config file in a different directory and just echoes all the information.

So I changed a few things:

<?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");
?>

As you can see there, I have a different config file, now in the local directory, and instead of echoing from the file, I make it a variable and include layout.php to add the layout, and echo the information.

These are the only changes I did: move config file, change "echo" to "$output", echo the $output in layout.php

Now, with these changes, the script doesn't work. Nothing uploads, all that happens is when you click the submit button, you see a blank, white page.

I know the database works fine, though, as I have another file that includes the same config file + the same layout file, and it retrieves information already in the database like it should.

Help greatly appreciated.

Thanks.

    Either check your error log or turn on display_errors. Also make sure error_reporting is set to E_ALL.

      Errors are on. The config.php file has this at the top:

      error_reporting("E_ALL");

      the error log is empty.

        Try echo'ing out some things then. If they don't appear, then you've got some sort of fatal/parse error somewhere.

        Also note that if it's a parse error, then setting error_reporting via the function won't work - you'd have to set it either through a .htaccess file or in php.ini.

          I found out my problem, but for some reason it wasn't displaying an error.

          See the if(runQuery...)

          Yeah, well when I updated my code, I forgot to define the runQuery function.

            Like I said, it sounded like you had either a parse error or a fatal error somewhere.

            Don't forget to mark this thread resolved (if it is).

              Write a Reply...