livethedead Posted February 8, 2012 Share Posted February 8, 2012 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. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 8, 2012 Share Posted February 8, 2012 Your opening php tag, isn't. It should be <?php Quote Link to comment Share on other sites More sharing options...
livethedead Posted February 8, 2012 Author Share Posted February 8, 2012 I feel like slamming my head into this desk atm. I'm still receiving the same error though, after fixing the tag and saving the file. Edit: Never mind, I had the file open in a diff dir, gah.. smoke break is necessary. Thanks man. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.