MySQL问题用PHP连接到网站 [英] MySQL issue connecting to site with php

查看:58
本文介绍了MySQL问题用PHP连接到网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我尝试连接到本地主机(使用MAMP)时,都会告诉我访问被拒绝或无法连接!这让我发疯了!我有下面的PHP示例.我想念的是什么,因为显然网络上没有人遇到同样的问题...

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")

推荐答案

尝试...

//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());

这篇关于MySQL问题用PHP连接到网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆