Jump to content

Another Newbie Question


livethedead

Recommended Posts

I'm just learning PHP as a first language so you'll probably see my around here quite a bit!

 

I'm completely baffled at why this isn't working and after about 30 minutes of frustration I decided to seek some help lol.

 

	require '/opt/lampp/htdocs/PHP/Chapter 3/scripts/app_config.php';
//database connection code

if (mysql_connect($db_host, $username, $password) != false) {
	mysql_select_db("db_name");
	echo "MySQL Database Selected";
}
else {
	echo "Error connecting to database";
}

 

app_config.php

<php
// Database Connection Constants

$db_host = "";
$username = "";
$password = "";
$db_name = "chp3";
?>

 

results:

Notice: Undefined variable: db_host in /opt/lampp/htdocs/PHP/Chapter 3/scripts/connect.php on line 6

 

Notice: Undefined variable: username in /opt/lampp/htdocs/PHP/Chapter 3/scripts/connect.php on line 6

 

Notice: Undefined variable: password in /opt/lampp/htdocs/PHP/Chapter 3/scripts/connect.php on line 6

 

 

Any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/256650-another-newbie-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.