MySQL issue connecting to site with php

一世执手 提交于 2020-01-06 19:42:35

问题


Every time I try to connect to my localhost (using MAMP), it tells me that either access was denied or that it can't connect!!! It is driving me crazy! I have the php example below. What am I missing, because apparently nobody on the web is having this same problem...

//setup db connection

$link = mysqli_connect("localhost","root","");
mysqli_select_db($link, "iReport")

回答1:


Try...

//Database Information

$dbhost = "serverip";
$dbname = "databasename";
$dbuser = "username";
$dbpass = "password";


//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());


来源:https://stackoverflow.com/questions/12701358/mysql-issue-connecting-to-site-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!