非常基本连接到mysql/test问题

Pat*_*ney 1 php mysql dreamweaver

如果这是一个非常愚蠢的问题,我会提前道歉(我是php和mysql的新手.

基本上,我正在设置connect_to_mysql.php文件,如下所示(5:50):http://www.youtube.com/watch?v = YaII5QhNCH0

如下图所示:http: //www.developphp.com/view_lesson.php?v = 248

我正在使用MAMP.端口是80/3306然而我知道在MAMP起始页面上说,以下,它也不起作用:

MySQL的

可以使用phpMyAdmin管理MySQL数据库.

要从您自己的脚本连接到MySQL服务器,请使用以下连接参数:

主机:localhost端口:3306用户:root密码:root

这是我有的:

这是connect_to_mysql.php:

        <?php  
    // Created BY Adam Khoury @ www.flashbuilding.com - 6/19/2008  
/*  
1: "die()" will exit the script and show an error statement if something goes wrong with     the     "connect" or "select" functions. 
2: A "mysql_connect()" error usually means your username/password are wrong  
3: A "mysql_select_db()" error usually means the database does not exist. 
*/ 
// Place db host name. Sometimes "localhost" but  
// sometimes looks like this: >>      ???mysql??.someserver.net 
$db_host = "localhost"; 
// Place the username for the MySQL database here 
$db_username = "builder2";  
// Place the password for the MySQL database here 
$db_pass = "builder2";  
// Place the name for the MySQL database here 
$db_name = "suitstore"; 

// Run the actual connection here  
mysql_connect("$localhost","$builder2","$builder2") or die ("could not connect to     mysql");
mysql_select_db("$suitstore") or die ("no database");              
?>
Run Code Online (Sandbox Code Playgroud)

这是test.php:

    <?php   
    // Connect to the file above here   
require "connect_to_mysql.php";  

echo "<h1>Success in database connection! Happy Coding!</h1>";   
// if no success the script would have died before this success message 
?>
Run Code Online (Sandbox Code Playgroud)

因此,当我在Chrome上加载测试网站时,它会说:服务器错误网站在检索时遇到错误.它可能已关闭以进行维护或配置不正确.以下是一些建议:稍后重新加载此网页.HTTP错误500(内部服务器错误):服务器尝试完成请求时遇到意外情况.

所以,这可能是问题的一部分:在DW中,当我打开test.php时它告诉我"这个站点可能有动态相关的文件,只能由服务器发现[发现] [首选项]"

然后,如果我单击"发现",则会显示:"由于内部服务器错误,无法解析动态相关文件.[重试]"

谢谢,对不起,如果这是一个愚蠢的问题.我真的不知道关于php/mysql的杰克.

小智 5

我认为他们应该是.

mysql_connect($db_host,$db_username,$db_pass) or die ("could not connect to mysql");
mysql_select_db($db_name) or die ("no database");   
Run Code Online (Sandbox Code Playgroud)