PHP查询问题
PHP code:
<?php
/*
* Created on 2010-3-3
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$mysqli=mysqli_connect("localhost","root","x-d","news");
$sql = "SELECT * from news";
$res = mysqli_query($mysqli,$sql);
$a = mysql_fetch_array($res);
$num = mysql_num_rows($a);
echo $num;
?>
报下面的错。。。
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in G:\PHP\news\select.php on line 14
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in G:\PHP\news\select.php on line 15
请大侠指导。。。
news 既是数据库名又是表名?
你不要把mysqli和mysql混着用.....
应该是$res = mysqli_query($mysqli,$sql)这句有问题.楼主看看手册:
mixed mysqli_query ( mysqli $link , string $query [, int $resultmode ] )
$a = mysql_fetch_array($res);
$num = mysql_num_rows($a);
---------------------------
把上面的mysql_ 换成mysqli_
发现函数混用啊,mysql和mysqli.楼主还是查查手册吧
你得保证mysqli_connect中最后一个参数news是数据库名称
PHP code
Code highlighting produced by Actipro CodeHighlighter (freeware
相关问答:
各位大些
求一段php代码
可以实现以下功能
针对不同的浏览器显示不同的图片
就是有一张图片,只想给ie6用户看到
如果ie7、chrome、firefox用户浏览则显示另外一张图片
价格不要太离谱就行 ......
PHP code:
$date = '2009-12-25';
$ptn = '/([\d]{4})[- \/](0?[\d]|1[0-2])[-\/ ](0?[\d]|[1-2][\d]|3[0-1])/';
if (preg_match($ptn,$date,$out))
{
print_r($out);exit();
}
结果为:
PHP code:
......
得到客户端IP老问题了,但这次环境有点不一样( 客户是这样的环境没办法,说BT的请飘过 :) )。
win2k3该系统(下称系统A)上装了VMware Server,VM下有个win2k3系统(下称系统B)。
系统A:直接连接公网。有公网I ......
我的项目所在的环境是php+apache+linux
现我重启服务是 service httpd restart
现我想定时重启此项服务(定在每天下午4点) 怎么实现呀,多谢
crontab
* 16 * * * service httpd restart
学习 + d ......
谁有PHP memcached的项目实例,主要用来学习。发送到我的邮箱790684386@qq.com 谢谢
就是看手册就可以了
都是那样子的
key $value
queryphp ORM数据库类
---------------------------------------------------- ......