duanliao2310 2014-01-01 16: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 17:28
    关注

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

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

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭