PHP的MySQL配置
报错信息:Class ‘mysqli’ not found in
Answer:
1.在conf/php.ini中,在vim用”/php_mysql”搜索到extension=php_mysql.dll,去掉前面的”;”,
同时在下面增加extension=php_mysqli.dll;
注意后面那个dll多了个i
2.”/extension_dir”检查路径是否正确;
3.找到ext/目录,把其中的php_mysql.dll,php_mysqli.dll两个文件Copy to %systemroot%/system32下.
4.重启服务
连接数据库
//在conf/php.ini中,在vim用"/php_mysql"搜索到extension=php_mysql.dll,去掉前面的";",同时在下面增加extension=php_mysqli.dll;<BR>$mysqli = new mysqli("127.0.0.1","用户名", 密码","库名");<BR>$query="select * from 表 order by theindex desc";<BR>$mysqli->query("SET NAMES gb2312");//注意此处不加会乱码<BR>$result = $mysqli->query($query);</P><P> //printf() 函数输出格式化的字符串<BR>while(list($name, $theindex) = $result->fetch_row())<BR> echo(" <br />".$name.$theindex);</P><P>$con = mysql_connect("localhost", "用户名", "密码");<BR>if ($con) {<BR> mysql_query("set names 'gb2312'");<BR> mysql_select_db("库名", $con);//注意此处不加会乱码<BR> $rs = mysql_query("select * from 表 order by theindex desc;", $con);<BR> if ($rs) {<BR> echo ("<table border="1">");<BR> while($row = mysql_fetch_assoc($rs)) <BR> {<BR> echo "<tr>" .<BR> "<td><b style="color:transparent">来&源gao@dai!ma.com搞$代^码%网</b><img>搞gaodaima代码</img>$row[theindex]</td>" .<BR> "<td>$row[name]</td>" .<BR> "</tr>";<BR> }<BR> mysql_free_result($rs);<BR> }<BR> echo ("</table>");<BR> mysql_close($con);<BR>}<BR>