php - 从数据库中检索一条记录

标签 php arrays error-handling record fetch

只是尝试显示数据库中的一条记录...但是收到错误(获取数组时)

$con=mysql_connect("localhost","root","");
mysql_select_db("school");
$iid=$_REQUEST['id2'];   //mysql_fetch_array(): supplied argument is not a valid

$d=mysql_query("select * from notification where noticeid=$iid");
$data=mysql_fetch_array( $d ); 

这是我的显示标准...
<tr> 
<td class=""><?php echo $data['noticeid'] ?></td>  
<td class=""><?php echo $data['notificationtitle'] ?></td>  
<td class=""><?php echo $data['notificationbody'] ?></td>  
</tr>

最佳答案

尝试以下方法:noticeid ='“。$ iid。” '

$d=mysql_query("select * from notification where noticeid='".$iid."' ");
$data=mysql_fetch_array( $d ); 

关于php - 从数据库中检索一条记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22497724/

相关文章:

c# - 好的做法 - 抛出异常以满足函数返回

php - Wordpress WP 列表表实现

c - C编程中如何判断给定的数组是否按降序排列

php - 如何使用 composer 在 Windows 中安装 Yii2 Alpha

c++ - 指针的第一个元素被污染了 C++

javascript - 将对象转换为数组并省略键

android - java.io.FileNotFoundException : Permission denied - in flutter i got this error

sharepoint - 如何定向到自定义错误页面?

php - 上传图片到主机

PHP、MySQL - 当输入是数组时返回使用哪个值?