duanliao2310 2014-01-01 08:10 采纳率: 100%
浏览 81
已采纳

提交POST数据时的PHP白屏

I am writing a php script which does the following:

  • Accepts incoming POST data from an article editing page.
  • Checks if the dropdown list on the previous page was set to "Create New Folder".
  • If so it checks if something is in the textbox named foldercreate.
  • Inserts this into the database if it is.
  • If not it creates a Miscellaneous folder in the database and uses that in the insert.

The trouble is I keep getting a white screen when I hit the form submit button on the previous page. It shows savearticle.php in the address bar but nothing else. It won't even print out error messages. I must have rewritten this about three times now so forgive any logic errors in the code but it should be working as far as I can see. I just want to make sure it's working in its present form before going any further.

The echo statements throughout the code are something I found useful for debugging in the past but it doesn't display a single one.

In the functions.php include I am just using the database connection information as I use this across multiple pages without issue.

Any help would be appreciated as this is getting pretty frustrating.

<?php
echo "start of file";
include_once 'functions.php';
echo "after include";
$title          = $_POST[ 'title' ];
$body           = $_POST[ 'body' ];
$folderselect   = $_POST[ 'folderselect' ];
$foldercreate   = $_POST[ 'foldercreate' ];
$newfolderflag  = 99;
echo "after variables";
if ($folderselect === "Create New Folder") {
    $folder = $foldercreate;
    $newfolderflag = 0; 
    } else if ($foldercreate == NULL && $folderselect === "Create New Folder"){
    $folder = "misc";
    echo "Nothing selected. Putting in Miscellaneous folder.

";
    $newfolderflag = 0;
    } else {
        $folder = $folderselect;
        }

if ($newfolderflag === 0) {
    $query = "INSERT INTO folder ('name') VALUES ('$folder');";
    if (mysqli_query($db, $query) == TRUE) { echo "New folder created successfully!

"};
}
echo "after if statements";
$query = "SELECT 'folderID' FROM folder WHERE name = $folder;";
$result = mysqli_query($db, $query);
$row = array();
$row = mysqli_fetch_array($result);
$folder = $row['0'];

$query  = "INSERT INTO article ( title, body, folderID, userID ) VALUES ('$title', '$body', '$folder', '$user');";
if (mysqli_query($db, $query) === TRUE) {
    echo "Article Saved!";
    echo "<a href="write.php">Back</a>";
    }
echo "after database stuff";

?>

展开全部

  • 写回答

3条回答 默认 最新

  • dongshenling6585 2014-01-01 09:28
    关注

    You need to change your select in order to surround $folder with quotes:

    $query = "SELECT 'folderID' FROM folder WHERE name = '$folder';";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部