<?php
$id=$_GET['id'];
if ($id!=''){
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("Exam", $con);$result = mysql_query("SELECT * FROM myexam WHERE myExamID='$id'");
while($row = mysql_fetch_array($result))
{
echo $row['myExamCnt'] . " " . $row['myExamDaRight'];
}
}
else{
echo "什么都没有";
}
?>
现出这个的错误:
Notice: Undefined index: id in D:\PHPnow\htdocs\exam\111.php on line 24
什么都没有
$id=$_GET['id'];
if ($id!=''){
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("Exam", $con);$result = mysql_query("SELECT * FROM myexam WHERE myExamID='$id'");
while($row = mysql_fetch_array($result))
{
echo $row['myExamCnt'] . " " . $row['myExamDaRight'];
}
}
else{
echo "什么都没有";
}
?>
现出这个的错误:
Notice: Undefined index: id in D:\PHPnow\htdocs\exam\111.php on line 24
什么都没有
2 if(isset($_GET['id']) && $_GET['id'] != "")
{
}
{
....
id=request.querystring("id")
if id<>"" Then
...如果id不存在,不会出错,默认接收到空字符值在php中,千万不要用这种逻辑也先来个$id=$_GET['id'],要直接放入if中分析。