<br /><b>注意</b>:<b>7</b>行<b>C:\xampp\htdocs\form2\edit.php</b>中的未定义变量:user_name <br

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36788379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:56:18  来源:igfitidea点击:

<br /><b>Notice</b>: Undefined variable: user_name in <b>C:\xampp\htdocs\form2\edit.php</b> on line <b>7</b><br />

php

提问by rakesh suryan

<!doctype html>
<html>
<head>
<title></title></head>
<body>
<form action="#" method="POST" enctype="multipart/form-data">
<input type="text" name="usname" value = "<?=$user_name;?>"/>
<input type="password" name="psd" value = "<?=$pass_word;?>" />
<input type="textarea" name="addrs" value = "<?=$address;?>">
<input type="hidden" name="id" value = "<?=$id?>"/>
<input type="submit" name="submit" value="submit"/>
</form>
<?php
if(isset($_POST['submit'])){

    $sql= "Update form set user_name='".$_POST['usname']."',
                         pass_word='".$_POST['psd']."',
                         address='".$_POST['addrs']."'
 where id='".$_GET['id']."'
 ";

 $result=mysql_query($sql);
if($result)
{
    echo"data is succesfully data insert";
header("location:login.php");
}else
{echo"";}
}
$id='';
$user_name='';
$pass_word='';
$address='';
$host="localhost";
$username="root";
$password="";
$db="form2";
$con=mysql_connect($host,$username,$password);

if(isset($_GET['id']))
{
 echo $query = "select id,user_name,pass_word,address from form where id=".$_GET['id'];
mysql_select_db($db,$con);

 echo $result=mysql_query($query);
if($result){
    while($row= mysql_fetch_array($result))
     $id=$row['id'];
     $user_name=$row['user_name'];
     $pass_word=$row['pass_word'];
    $address=$row['address'];

    }
}
?>

</body>
</html>


Notice: Undefined variable: user_name in C:\xampp\htdocs\form2\edit.phpon line 7


注意:未定义变量:user_name in C:\xampp\htdocs\form2\edit.php7

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????

?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ???????????????


Notice: Undefined variable: address in C:\xampp\htdocs\form2\edit.phpon line 9
submit


注意:未定义变量:地址在C:\xampp\htdocs\form2\edit.php9
提交

i am create a edit.php and update the values

我正在创建一个 edit.php 并更新值

I'm running a PHP script, and maintain getting errors like:

我正在运行一个 PHP 脚本,并保持收到如下错误:

回答by Brijal Savaliya

If you are using some variable then please check if its set or not

如果您正在使用某个变量,请检查它是否已设置

<?=$user_name;?> you need to chnage to <?=(isset($user_name)?$user_name:""?> and same for others.