请问mysql写法怎么改成mysqli
咱们教学的评论源码是mysql写法,可是在php7.0就不能用了,请问怎么把mysql改成mysqli<?php$sqlhost="127.0.0.1"; //数据库地址
$sqluser="root"; //数据库用户
$sqlpass="root"; //数据库密码
$sqldata="ping"; //数据库名字
$connect=mysql_connect($sqlhost,$sqluser,$sqlpass);
if(!$connect){
exit('mysql No!');
}
mysql_select_db($sqldata,$connect);
mysql_query("set names 'utf8'");
?>
请问这段代码怎么改成mysqli的啊
<?php
$sqlhost="127.0.0.1"; //数据库地址
$sqluser="root"; //数据库用户
$sqlpass="root"; //数据库密码
$sqldata="ping"; //数据库名字
$connect=mysqli_connect($sqlhost,$sqluser,$sqlpass);
if(!$connect){
exit('mysql No!');
}
mysqli_select_db($sqldata,$connect);
mysqli_query("set names 'utf8'",$connect);
mysql改成mysqli就好了- -...
然后需要自己加上连接的**$connect**
本帖最后由 mhand 于 2018-7-18 13:46 编辑
<br />
<b>Warning</b>:mysqli_select_db() expects parameter 1 to be mysqli, string given in <b>/www/wwwroot/ce.cn/app/p/config.php</b> on line <b>10</b><br />
<br />
<b>Warning</b>:mysqli_query() expects parameter 1 to be mysqli, string given in <b>/www/wwwroot/ce.cn/app/p/config.php</b> on line <b>11</b><br />源码提示错误
mhand 发表于 2018-7-18 13:44
Warning:mysqli_select_db() expects parameter 1 to be mysqli, string given in /www/wwwroot/ce.c ...
要习惯用百度翻译,然后就是你要看他的参数分别要哪些。 看看再说咯,反正看不懂
页:
[1]