您好,欢迎访问一九零五行业门户网

php接收地址栏上的id,该怎么解决

php接收地址栏上的id
php code
文件命名为test.php,编辑环境为editplus,按ctrl+b,在页面上弹出
html codenotice: undefined index: id in d:\server\apache\www\test.php on line 2参数有误
于是我便在地址栏上输入
html codehttp://localhost/test.php[color=#ff0000]?id=2[/color]
可是这次显示的错更多
html codewarning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 in d:\server\apache\www\test.php on line 7warning: mysql_connect() [function.mysql-connect]: [2002] php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 (trying to connect via tcp://loaclhost:3306) in d:\server\apache\www\test.php on line 7warning: mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 in d:\server\apache\www\test.php on line 7warning: mysql_query() expects parameter 2 to be resource, boolean given in d:\server\apache\www\test.php on line 9warning: mysql_query() expects parameter 2 to be resource, boolean given in d:\server\apache\www\test.php on line 11warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in d:\server\apache\www\test.php on line 12鍙傛暟鏈夎
我查找原因好久,实在没招了,哪位大大能帮忙分析原因,感激不尽!!!!!
------解决方案--------------------
mysql_connect(), 数据库连接错误
php code$conn = mysql_connect('loaclhost','root','123456') or die(can not connect mysql server);mysql_select_db(数据库名,$conn);//你的数据库名叫 use msg ?$sql = select * from denglu where id = $id;$var = mysql_query($sql);
------解决方案--------------------
if(isset($_request['id'])){
$id = $_request['id'];
if($id == 0){
exit(the parameter is wrong!);
}
}
echo $id;
@ $conn = mysql_connect('localost', 'root', '123456') or die(connection failure: .mysql_errno());
mysql_select_db('msg', $conn);
mysql_query(set names ''utf8);
$sql = select * from denglu where id = $id;
$result = mysql_query($sql);
while($rs = mysql_fetch_assoc($result)){
var_dump($rs);
}
输入url: localhost/index.php?id=2即可获取到id
------解决方案--------------------
$id=isset($_get[id])?$_get[id]:0;

其它类似信息

推荐信息