PHP连接MYSQL数据库的问题! $db=new mysqli('localhost','root','123','db'); if(mysqli_connect_errno()) { exit; } $result=$db->query("select count(*) from users");$db是 数据库连接的那个 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 随便写了一下,不知道是不是你要的,记住,这是用了数据库操作的类。$sql = 'select count(*) AS total_records from users';$result = $db->query($sql);$row = $db->sql_fetchrow($result);$total_records = $row['total_records'];//一共的记录数 貌似LZ不是很明白类的概念,此处的$db是一个包含数据库相关操作的类.通俗讲就像一个工具包,里面各种方法可以直接拿来调用,而不需你重新编写.所以你只需看明白3楼给你的例子,之后去你自己的类里找与之功能一样的方法即可. $row = $db->sql_fetchrow($result);这行代码报错Call to undefined method mysqli::sql_fetchrow() 呵呵,3楼只是给你一个参考,你要看明白他给你的写的方法,之后你要去你自己的DB类里找功能相同的方法拿来用.你直接用他的CODE当然不行了.sql_fetchrow()该方法在你的DB里可不是这个名. 相关参考:http://www.php.net/manual/zh/language.oop5.basic.php 谢谢 你们了可是 我还是不明白 我就是 想 练习一下 简单的登陆这个是 全部代码<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>上传文件</title></head><body><?php $names=$_POST['username']; $pwd=$_POST['userpwd']; if($names && $pwd) { $db=new mysqli('localhost','root','123','db'); if(mysqli_connect_errno()) { exit; } $result=$db->query("select count(*) from users where username='$names' and userpwd='$pwd' "); 这里 不知道该怎么 接值了 }?> <form action="login.php" method="post"> 账号: <input type="text" name="username"><br> 密码: <input type="text" name="userpwd"><br> <input type="submit" value="提 交"> <input type="reset" value="重 置"> </form></body></html>刚才 你说的类 我没有太明白是什么意思 麻烦您了 能不能 说的详细些 谢谢了 我知道了用系统定义的 sql_fetchrow();方法就可以了 谢谢你们了 PHP一维数组转成二维数组的方法? 小弟做了个新站大家给点建议 怎么在SQL语句中使用一个变量? HTTP状态码对于浏览器显示内容有影响么? php中用类的速度比用函数慢吗? 字符串'k:\mrp\PhotoPath\',在php中怎麼寫呀? 为什么无输出结果? 怎样替换Html文件中的某些代码呢? php怎么判断一个字节是汉字的高位还是低位 数据记录集怎么总出现错误? 如何将body标签里面的内容都转换成繁体或者简体 RMB求一个简单的程序
$sql = 'select count(*) AS total_records from users';
$result = $db->query($sql);
$row = $db->sql_fetchrow($result);
$total_records = $row['total_records'];//一共的记录数
这行代码报错
Call to undefined method mysqli::sql_fetchrow()
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>上传文件</title>
</head>
<body>
<?php
$names=$_POST['username'];
$pwd=$_POST['userpwd'];
if($names && $pwd)
{
$db=new mysqli('localhost','root','123','db');
if(mysqli_connect_errno())
{
exit;
}
$result=$db->query("select count(*) from users where username='$names' and userpwd='$pwd' ");
这里 不知道该怎么 接值了
}
?>
<form action="login.php" method="post">
账号: <input type="text" name="username"><br>
密码: <input type="text" name="userpwd"><br>
<input type="submit" value="提 交"> <input type="reset" value="重 置">
</form>
</body>
</html>刚才 你说的类 我没有太明白是什么意思 麻烦您了 能不能 说的详细些 谢谢了