Howdy,
First things first folks, I’m a newb.
Here is my issue:
I get this error:
////////// error //////////////
Notice: Undefined variable: localhost in /Users/patrickmeaney/localhost/BobsSuits/storescripts/connect_to_mysql.php on line 21
Notice: Undefined variable: builder2 in /Users/patrickmeaney/localhost/BobsSuits/storescripts/connect_to_mysql.php on line 21
Notice: Undefined variable: builder2 in /Users/patrickmeaney/localhost/BobsSuits/storescripts/connect_to_mysql.php on line 21
Notice: Undefined variable: suitstore in /Users/patrickmeaney/localhost/BobsSuits/storescripts/connect_to_mysql.php on line 22
no database
/////////////error///////////
when I run my test file. Below are the files of my connect to mysql file and the test file. Also, I wanted to mention, my site documents are not in the MAMP htdocs folder, rather they’re in my user folder, under local host ( users/patrickmeaney/localhost/bobsuits/ ) I dunno if that matters…
My connect file
[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 = “root”;
// Place the password for the MySQL database here
$db_pass = “root”;
// 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”);
?>[/php]
My test file:
[php] <?php
// Connect to the file above here
error_reporting(E_ALL); ini_set(‘display_errors’, 1);
require_once(“storescripts/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
?>
[/php]
Thanks for your help!