避免出现"Notice: Use of undefined constant......"警告
来源:互联网 发布:淘宝旺铺首页全屏装修 编辑:程序博客网 时间:2024/05/22 13:28
刚开始学习php,写了一段测试程序,如下:
<?php
$username = $_POST[username];//从html表单获取数据;
$password = $_POST[password];
$link = mysql_connect('localhost','root','123') or die('could not connect:'.mysql_error()) ;
$select = mysql_select_db('blksun',$link) or die('could not select database') ;
$query = 'select * from userlist where userName="'.$username.'"';
$result = mysql_query($query) or die('query failed:'.mysql_error()) ;
echo "<table border=1>" ;
echo "<tr><td>id</td><td>username</td><td>userpwd</td></tr>" ;
while ($array = mysql_fetch_assoc($result))
{
printf("<tr><td>%d</td><td>%s</td><td>%s</td></tr>",$array[Id],$array[userName],$array[userPwd]);
}
echo "</table>" ;
// 释放结果集
mysql_free_result($result);
// 关闭连接
mysql_close($link);
?>
以上程序运行时就会出现诸如:“Notice: Use of undefined constant username - assumed 'username' inD:/wwwroot/userreg.php on line 2”
的提示,但是结果也能显示出来。要想不显示“notice”,就得将上面程序中红色的变量,加上引号。
另外:$array[Id],$array[userName],$array[userPwd] 必须大小写区分。
转自:http://hi.baidu.com/liheng_2009/item/6eca8c7000dd423f6e29f694
- 避免出现"Notice: Use of undefined constant......"警告
- 避免出现"Notice: Use of undefined constant......"警告
- PHP出现Notice警告 : Use of undefined constant的解决方法
- 修改php.ini屏蔽警告Notice: Use of undefined constant ;
- Notice: Use of undefined constant
- PHP 出现Notice: Use of undefined constant 的解决方案
- PHP 出现Notice: Use of undefined constant 的解决方案
- PHP 出现Notice: Use of undefined constant 的解决方案
- PHP运行出现Notice : Use of undefined constant 的解决办法
- PHP运行出现Notice : Use of undefined constant 的解决办法
- PHP运行出现Notice : Use of undefined constant 的解决办法
- PHP运行出现Notice : Use of undefined constant 的解决办法
- PHP运行出现Notice : Use of undefined constant 的解决办法
- PHP运行出现Notice : Use of undefined constant 的解决方法
- PHP运行出现Notice : Use of undefined constant 的解决办法
- PHP运行出现Notice : Use of undefined constant 完美解决方案
- PHP Notice: Use of undefined constant
- PHP “Notice: Use of undefined constant ”
- 简略的帧动画
- MFC中添加的菜单项为什么始终是灰色的
- ADC左对齐与右对齐的数据读取问题
- Nexus
- jquery 复选框以及批量删除
- 避免出现"Notice: Use of undefined constant......"警告
- iOS开发-文件管理
- 查看手机所有信息
- Linux 标准目录结构
- S3C2440上LCD驱动(FrameBuffer)实例开发详解
- 第1次实验——NPC问题(回溯算法、聚类分析)
- Linux 目录结构
- 再论java中的深复制与浅复制
- php 解析xml 的四种方法(转)