duanmoen784988 2013-09-04 18:31
浏览 62

更新php表中的数据时出现空白屏幕

I have been working on a project and i am at the final stages of the project. My problem is whenever i try to update data in my database table into returns a blank screen with no error messages. Please find the php script and html form (the form responsible for updating the database table) below, i have divided it into about four sections:

Thanks in advance

Update Form:

<a name="inventoryEditForm" id="inventoryEditForm"></a>
<h3>&darr;Add New Question Form&darr;</h3>  
<form action="inventory_edit.php" enctype="multipart/from-data" name="myForm" id="myForm" method="post">
    <table width="80%" border="0" cellspacing="3" cellpadding="7">
        <tr>
            <td width="20%">&nbsp;</td>
            <td width="80%">&nbsp;</td>
        </tr>
        <tr>
            <td>Question</td>
            <td><textarea rows="" name="question" cols=""><?php echo $question; ?></textarea></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>Venue</td>
            <td><input type="text" name="venue" maxlength="50" value="<?php echo $venue; ?>"></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>Date</td>
            <td><input type="date" name="questiondate" value="<?php echo $date; ?>"></td>
        </tr>
    </table>
    <br>
    <input name="thisID" type="hidden" value="<?php echo $targetID; ?>"/>
    <input type="submit" name="submit" value="Update Question">
    <input type="reset" name="clear" value="Clear Form">
</form>

PHP Script:

<?php

//Error reporting due to long script
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php

error_reporting(E_PARSE);
//Update question table
If (isset($_POST['question'])) {
    $id = mysqli_real_escape_string($link, $_POST['thisID']);
    $question = mysqli_real_escape_string($link, $_POST['question']);
    $venue = mysqli_real_escape_string($link, $_POST['venue']);
    $date = mysqli_real_escape_string($link, $_POST['questiondate']);
    //Update question in the table
    $sql = mysqli_query($link, "UPDATE DebateQuestion SET question='$question',venue='$venue',date='$date' WHERE qQuestionNo='$id'LIMIT 1") or die(mysql_error());
    header("location: inventory.php");
    exit();
}
?>
<?php

error_reporting(E_PARSE);
//Gather this questions full information and insert automatically into the edit form
if (isset($_GET['qid'])) {
    $targetID = $_GET['qid'];
    $sql = mysqli_query($link, "SELECT * FROM DebateQuestion WHERE qQuestionNo='$targetID'LIMIT 1") or die(mysql_error());
    $questionCount = mysqli_num_rows($sql); // count the output amount

    if ($questionCount > 0) {
        while ($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)) {
            $id = $row["qQuestionNo"];
            $question = $row["qQuestion"];
            $venue = $row["qDebateVenue"];
            $date = strftime("%b %d, %Y", strtotime($row["qDate"]));
        }
    } else {
        echo "Oops, no questions like that exists. Check <a href='inventory.php'>inventory</a>again";
        exit();
    }
}
?>
  • 写回答

3条回答

  • douba1498 2013-09-04 18:37
    关注

    In your update query you have the data column without using ` back ticks , date is also a mysql's function try to wrap up your column names with back ticks if you are not sure whether they conflict with mysql's reserved keywords

    $sql = mysqli_query($link,"UPDATE DebateQuestion SET 
    `question`='$question',`venue`='$venue',`date`='$date' 
     WHERE qQuestionNo='$id'LIMIT 1")
    
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?