gpt4 book ai didi

PHP:空白页上显示未定义

转载 作者:行者123 更新时间:2023-11-30 23:08:15 26 4
gpt4 key购买 nike

我正在尝试打印/回显以前文件中的值,但是没有显示错误,而是在空白页上显示的所有内容都是“未定义”。我已经研究并尝试了几种方法,但没有任何效果。请帮忙。

<?PHP
$user_name = "root";
$password = "";
$database = "leadership_program";
$server = "localhost";

$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

if (isset($_POST['survey_id'])) {
$survey_id = $_POST['survey_id'];
echo $survey_id;
}

if (isset($_POST['marks'])) {
foreach ($_POST['marks'] as $value) {
echo"$value";
}
}

if (isset($_POST['id'])) {
$id = $_POST['id'];
echo $id;
}

// $SQL2 = "UPDATE answer_table SET marks='$value' WHERE survey_id= '$survey_id' AND student_id= '$id'";

//$result2 = mysql_query($SQL2);

//mysql_close($db_handle);


} else {

print "Database NOT Found ";
mysql_close($db_handle);
// header("Location: surveyView.php");
}
?>

这里是displayresult.php

<form action="student_mark_save.php" method="POST"> //<?php...more codes here

if ($strucrow["qns$i"] === 'radio' || $strucrow["qns$i"] === 'checkbox') {

foreach ($arr as $b) {

echo "<br/>";

if (strpos($b, '%#%') !== false) {
$c = substr($b, 3, -2);
//echo $c;
$d = str_replace("$arr[0] :-", ':', $c);
echo $d, "<br/>";
echo "<br/>";

echo "<tr> Marks : <input type=\"text\" name=\"marks[]\"></tr><br />";

//echo $b;
} else {
echo $b;
// echo "is not with comment qns";
}
}
} else if ($strucrow["qns$i"] === 'comment') {

foreach ($arr as $b) {

echo $b;

echo "<tr> Marks : <input type=\"text\" name=\"marks[]\"></tr><br />";
// echo "is not with comment qns";
}

} else {

}
echo "<p/>";
}

$marksquery = sprintf(
"SELECT marks FROM answer_table WHERE survey_id = '%d' AND student_id = '$studentid' ", mysql_real_escape_string($survey_id)
);
$marksQuer = mysql_query($marksquery) or die(mysql_error());

$marksrow = mysql_fetch_assoc($marksQuer);

echo "<td><input type=\"hidden\" value= \"$survey_id\" name=\"survey_id\"></td><br />" ;
echo "<td><input type=\"hidden\" value= \"$studentid\" name=\"id\"></td><br />" ;

echo "<p><input type=\"submit\" value=\"Update\"></p>";
?>


</form>

最佳答案

对于未定义的意思,全局$_POST[]中不存在某些东西检查尝试在您的第一个 if 语句中打印 $_POST 为:

if ($db_found) {

print_r($_POST);
exit();

if (isset($_POST['survey_id'])) {
$survey_id = $_POST['survey_id'];
echo $survey_id;
}

现在看看你在$_POST中有什么,它可能对你有帮助...谢谢

关于PHP:空白页上显示未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20922957/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com