Reputation: 149
I apologize in advance if this is a really dumb question (i'm a newb at php & mysql.
Basically, I am at the step of setting up the connect_to_mysql.php file, as shown here at (5:50): http://www.youtube.com/watch?v=YaII5QhNCH0
and as shown here: http://www.developphp.com/view_lesson.php?v=248
I'm using MAMP. the ports are 80 / 3306 However I know that at the MAMP start page it says, the following, which also, does not work.:
MySQL
The MySQL Database can be administrated with phpMyAdmin.
To connect to the MySQL Server from your own scripts use the following connection parameters:
Host: localhost Port: 3306 User: root Password: root
Here is what I have:
this is 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");
?>
and this is 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
?>
So, when I load the test site on Chrome, it says: Server error The website encountered an error while retrieving . It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
So, this is probably part of the problem: In DW, when I open test.php it tells me that "this site may have dynamically related files that can only be discovered by the server [ Discover ] [ Preferences ]"
Then, if I click discover, it says: "Dynamically related files could not be resolved because of an internal server error. [ Retry ]"
Thanks, and sorry if this is a dumb question. I truly don't know jack about php / mysql.
Upvotes: 1
Views: 3266
Reputation: 110
I think they should be.
mysql_connect($db_host,$db_username,$db_pass) or die ("could not connect to mysql");
mysql_select_db($db_name) or die ("no database");
Upvotes: 5