I'm making a website that uses SQL and PHP functionalities. How do I connect to a database?
3条回答 默认 最新
drh47606 2017-06-30 13:58关注The easiest way that I do with my site is make a file called
db.phpcontaining:<?php $host = 'localhost'; $user = 'root'; $pass = 'password'; $db = 'databasename'; $mysqli = new mysqli($host,$user,$pass,$db) or die($mysqli->error);..then in the
index.phpfile, at the top:<?php require_once('db.php') ?>本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报