數(shù)據(jù)庫連接失敗....
$link = mysql_connect('127.0.0.1', 'root', 'root','3307') or die('數(shù)據(jù)庫連接失敗');
mysql_select_db('phpdata');//選擇一個需要操作的數(shù)據(jù)庫
mysql_query("set names 'utf8'");
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo '數(shù)據(jù)庫連接成功!';
mysqli_close(!$link);
ps:本地的mysql 庫端口已經(jīng)改成3307了.
2019-05-31
先測試一下配置有沒有問題,再試試前端數(shù)據(jù)能不能傳入數(shù)據(jù)庫
2019-05-31
我已經(jīng)不確定是否 連上去了...
反正查不出數(shù)據(jù)。。。
2019-05-31
連上去了 不過報可一大堆 警告..啥意思呀?
Warning: mysql_select_db(): in?D:\sts\Phphello\mysql.php?on line?11
Warning: mysql_select_db(): A link to the server could not be established in?D:\sts\Phphello\mysql.php?on line?11
Warning: mysql_query(): in?D:\sts\Phphello\mysql.php?on line?12
Warning: mysql_query(): A link to the server could not be established in?D:\sts\Phphello\mysql.php?on line?12
數(shù)據(jù)庫連接成功!
Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in?D:\sts\Phphello\mysql.php?on line?17