为什么我不能用PHP连接到mysql [英] Why can't I connect to mysql with PHP

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

问题描述

我是php / mysql的新手,我想简单地连接到我的数据库。当我在我的服务器上运行下面的代码时,我得到一个http 500错误。我在端口80打开的Ubuntu服务器机器(不是虚拟机)上托管它。当然安装了php和mysql服务器。



我尝试过:



I am new to php/mysql and i want to simply connect to my database. When i run the code below on my server i get a http 500 error. I am hosting it on a Ubuntu server machine (not a virtual machine) with port 80 open. of course php and mysql server are installed.

What I have tried:

<?php
	$servername = "localhost";
	$username = "root";
	$password = "*******";


    mysql_connect($servername,$username,$password);
	echo "hi";
?>

推荐答案

servername =localhost;
servername = "localhost";


username = root;
username = "root";


password =*******;


mysql_connect(
password = "*******"; mysql_connect(


这篇关于为什么我不能用PHP连接到mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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