php7 连接mysql
2022-07-28 15:20:24
92
{{single.collect_count}}

网上好多贴害人啊。。php7已经没有mysql这个扩展了,好多贴还是按照以前的方法讲,让我这个新手来回找了好多遍都没找到mysql,php7用后面两个链接数据库,千万不要傻傻去找也不要去来回拷贝什么dll之类的。

extension=php_mysqli.dll   extension=php_pdo_mysql.dll


下面附上一段mysqlli测试代码

<?php$mysqli = new mysqli("localhost", "root", "password", "testgame");if(!$mysqli){echo"database error";}else{echo"php env successful";}$mysqli->close();?>
localhost 意思是本地主机,如果你是在自己电脑上的话,这项就不用改了
root是mysql的用户名,如果你是默认的没有修改,也不用管,直接copy
password 这事mysql的密码,如果你没有试着的话,直接写空的就行,""这样哦
testgame这个是要访问的数据库名称,你如果没有建的话就建一个,这个地方也可以不写,后面用<span style="font-family: Verdana, Arial, 宋体; background-color: rgb(239, 239, 239);">mysqli_select_db()这个方法设置也行。</span>
<span style="font-family: Verdana, Arial, 宋体; background-color: rgb(239, 239, 239);"></span><pre name="code" class="php">

 

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}