更新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();
    }
}
?>
duandun2136
duandun2136 乍一看,看起来您的代码应该正确解析,但请记住,如果您的php.ini(或.htaccess)未配置为执行此操作,则不会报告解析错误。如果存在解析错误,只需在代码中设置错误报告行为即可。
大约 7 年之前 回复

3个回答



在您的更新查询中,您有数据列而不使用`back ticks,date也是一个mysql的函数尝试包装您的列名 如果您不确定它们是否与mysql的保留关键字冲突,请使用后退滴答</ p>

  $ sql = mysqli_query($ link,“UPDATE DebateQuestion SET 
question ='$ question ',venue ='$ venue',date ='$ date'
WHERE qQuestionNo ='$ id'LIMIT 1“)
</ code> </ pre>
</ div>

展开原文

原文

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

duanjue6575
duanjue6575 首先检查它是否进入,如果检查或不使用die(),并回显您的查询“UPDATE DebateQuestion SET question ='$ question',venue ='$ venue',date ='$ date'WHER qQuestionNo ='$ id'LIMIT 1并直接在phpmyadmin中运行以查看是否有任何错误
大约 7 年之前 回复
douluoyou9876
douluoyou9876 此外,我不确定是否所有数据都从表单传递到数据库表
大约 7 年之前 回复
dtftao7249656
dtftao7249656 我尝试添加后面的刻度,但白色屏幕仍然弹出。 我觉得这个问题来自我的UPDATE语句
大约 7 年之前 回复
duanjiancong4860
duanjiancong4860 date不是mysql中的保留字,仍然可以使用反引号。
大约 7 年之前 回复



 “SELECT * FROM DebateQuestion WHERE qQuestionNo ='$ targetID'LIMIT 1”
</ code> </ pre>

这里是qQuestionNo列的字符串类型?如果不删除 $ targetID </ code>周围的引号。</ p>
</ div>

展开原文

原文

"SELECT * FROM DebateQuestion WHERE qQuestionNo='$targetID'LIMIT 1"

Here is qQuestionNo column a string type?if not remove quotes around $targetID.

dro80463
dro80463 谢谢伙计我怀疑的问题来自表格。 表单操作最初被发送到同一页面(inventory_edit.php),但它意味着被发送到一个不同的页面,问题ID正在从该页面传递(即inventory.php)我做了这个改变,它显然工作
大约 7 年之前 回复



注意:我没有测试过代码 - 只需在屏幕上阅读。</ p>

我 之前从未见过IF语句大写:</ p>

  If(isset($ _ POST ['question'])){
</ code> </ pre>
\ n

我猜这会有所不同。</ p>

你的文件中还有很多其他奇怪的东西,但没有一个可以给你白屏。 首先在if语句中尝试使用小写的“I”。</ p>

另外 - re:UPDATE语句,你在$ id和LIMIT之间缺少一个空格:</ p>
\ n

  ** qQuestionNo ='$ id'LIMIT 1 ** 
</ code> </ pre>
</ div>

展开原文

原文

Note : I have not tested the code - just read it on screen.

I've never seen an IF statement capitalized before :

If (isset($_POST['question'])) {

I'd guess this makes a difference however.

There's lots of other weird things going on in your files, but none that should give you white screen. Try lowercase 'I' in your if statement first.

ALSO - re: the UPDATE statement, you are missing a space between the $id and the LIMIT :

**qQuestionNo='$id'LIMIT 1**

dqyat62284
dqyat62284 谢谢伙计我怀疑的问题来自表格。 表单操作最初被发送到同一页面(inventory_edit.php),但它意味着被发送到一个不同的页面,问题ID正在从该页面传递(即inventory.php)我做了这个改变,它显然工作
大约 7 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐