toxictoad Posted December 28, 2006 Share Posted December 28, 2006 hi all,i'm working through some tutorials on php and mysql and have hit a problem i can't work out.i have created a new user account for the mysql database. i have tested it, by logging in - (mysql -u phpuser -p) and that's fine. the next thing was to get a web page to send the login details and connect to the specified database (newdb)this is where i'm at...i've created a directory in my web root directory called 'config' and have 1 php file in there 'db_config.php'this is the script:<?php $db_host = "localhost"; $db_user = "phpuser"; $db_password = "myp4ssword"; $db_name = "newdb";?>then i have this script saved in the web root directory:<?php require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php"); $connection = mysql_connect($db_host, db_user, $db_password) or die("error connecting"); echo "connection made";?>has anyone got any ideas on why i can't connect using these?ps i've installed the latest wamp thanks Link to comment https://forums.phpfreaks.com/topic/32064-solved-simple-login-script-not-working/ Share on other sites More sharing options...
bljepp69 Posted December 28, 2006 Share Posted December 28, 2006 You're missing a '$' in front of 'db_user' and you need to select a database:[code]<?php require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php"); $connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting"); $db = mysql_select_db("$db_name", $connection) or die("Unable to select database!"); echo "connection made";?>[/code] Link to comment https://forums.phpfreaks.com/topic/32064-solved-simple-login-script-not-working/#findComment-148825 Share on other sites More sharing options...
toxictoad Posted December 28, 2006 Author Share Posted December 28, 2006 [quote author=bljepp69 link=topic=120148.msg492639#msg492639 date=1167324558]You're missing a '$' in front of 'db_user' and you need to select a database:[code]<?php require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php"); $connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting"); $db = mysql_select_db("$db_name", $connection) or die("Unable to select database!"); echo "connection made";?>[/code][/quote]oh boy :-[thanks bljepp69, much appriciated Link to comment https://forums.phpfreaks.com/topic/32064-solved-simple-login-script-not-working/#findComment-148829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.