Php 未定义ID为$\u GET的索引
那么,又出现了一个未定义的索引: 我正试图更改数据库中的select行,但到目前为止,它似乎不起作用,我只得到Php 未定义ID为$\u GET的索引,php,undefined-index,Php,Undefined Index,那么,又出现了一个未定义的索引: 我正试图更改数据库中的select行,但到目前为止,它似乎不起作用,我只得到 注意:第19行的C:\WampServer\www\Hundeklubben\ChangeO.php中的未定义索引:EierID。 我尝试了一些修复方法,但没有一种有效 <?php require_once('Connections/hundeklubb.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 T
注意:第19行的C:\WampServer\www\Hundeklubben\ChangeO.php中的未定义索引:EierID。
我尝试了一些修复方法,但没有一种有效
<?php require_once('Connections/hundeklubb.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Endring av eier</title>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<?php
if(isset($_GET['EierID'])){ $name = $_GET['EierID']; }
//Tried with both $_GET and $_POST
?>
<?php
$UID = (int)$_GET['EierID'];
$query = mysql_query("SELECT * FROM eiere WHERE EierID = '$UID'") or die(mysql_error());
if(mysql_num_rows($query)>=1){
while($row = mysql_fetch_array($query)) {
$navn = $row['Navn'];
$bosted = $row['Bosted'];
}
?>
<form name="form1" action="update.php" method="POST" id="form1">
<input type="hidden" name="ID" value="<?=$UID;?>">
Navn: <input type="text" name="ud_navn" value="<?=$navn?>"><br>
Bosted: <input type="text" name="ud_bosted" value="<?=$bosted?>"><br>
<input type="Submit" value="Oppdater">
</form>
<?php
}else{
echo 'No entry found. <a href="javascript:history.back()">Go back</a>';
}
?>
<?php var_dump($UID); ?>
</body>
</html>
这是因为未设置
$\u GET['EierID']
试试这个:
$UID = isset($_GET['EierID'])?$_GET['EierID']:"";
在update.php中也执行相同的操作:
ud\u ID=isset($\u POST[“ID”])?$\u POST[“ID”]:“”代码>这是因为未设置$\u GET['EierID']
试试这个:
$UID = isset($_GET['EierID'])?$_GET['EierID']:"";
在update.php中也执行相同的操作:ud\u ID=isset($\u POST[“ID”])?$\u POST[“ID”]:“”代码>如果您的变量不存在,您将在尝试转换该int时出错
<?php
if(isset($_GET['EierID'])){
$name = $_GET['EierID'];
$UID = (int)$_GET['EierID'];
}else{
//set to 0 or any default value you want to set when EierID doesn't exists
$UID = 0;
}
?>
如果您的变量不存在,您将在尝试转换该int时出错
<?php
if(isset($_GET['EierID'])){
$name = $_GET['EierID'];
$UID = (int)$_GET['EierID'];
}else{
//set to 0 or any default value you want to set when EierID doesn't exists
$UID = 0;
}
?>
该通知不能作为更新不起作用的原因。尝试将update.php中的查询回显或打印到浏览器中。然后在PHPMyAdmin这样的程序中运行这个查询,看看到底哪里出了问题。您正在使用并且应该使用。为什么我们每天都会收到10次这个问题?请先阅读错误消息。太好了,XSS和SQL同时注入=/很抱歉,但是我已经阅读了错误消息,我试图修复它,这只会导致更多的错误,这就是为什么你一天内会收到这么多错误,Daist这个通知不可能是你的更新不起作用的原因。尝试将update.php中的查询回显或打印到浏览器中。然后在PHPMyAdmin这样的程序中运行这个查询,看看到底哪里出了问题。您正在使用并且应该使用。为什么我们每天都会收到10次这个问题?首先阅读错误消息。太好了,XSS和SQL同时注入=/很抱歉,但是我已经阅读了错误消息,我试图修复它,这只会导致更多的错误,这就是为什么一天中会出现这么多错误,Dainis