louthmedia Posted October 16, 2010 Share Posted October 16, 2010 i have just sent the last 4 hours trying to connect to the msql database here is the to sets of code i i'm using <?php $db_host = "host"; $db_usernamen = "username"; $db_pass = "password" $db_name = "database name"; mysql_connect("$db_host","$db_username","$db_pass") or die ("couldnot connect to mysql"); mysql_select_db("db_name") or die ("no database"); ?> this code i'm using to connect to the database <?php require "connect_to_mysql.php"; echo "<h1>success in database connection! happy coding</h1>"; ?> and i have used this one as a quick test. i have up loaded the the two codes to the sever however when i opened the web site to test it all i get is a blank screen. i have looked at a number of codes like this one and i can't see anything wrong with the code. i have uploaded the codes three times just in case the files had been corrupt while uploading have every this has not work if anyone can help i would be very greatful Quote Link to comment Share on other sites More sharing options...
Gighalen Posted October 16, 2010 Share Posted October 16, 2010 What happens when you use: <?php $db_host = "host"; $db_usernamen = "username"; $db_pass = "password" $db_name = "database name"; mysql_connect($db_host, $db_username, $db_pass) or die ("couldnot connect to mysql"); mysql_select_db("db_name") or die ("no database"); ?> and <?php require("connect_to_mysql.php"); echo "<h1>success in database connection! happy coding</h1>"; ?> ? Quote Link to comment Share on other sites More sharing options...
Gighalen Posted October 16, 2010 Share Posted October 16, 2010 Also, if all you're seeing is a blank screen, you might be receiving an error but have warnings turned off in your php.ini file. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 16, 2010 Share Posted October 16, 2010 You're missing the line terminating semicolon here: $db_pass = "password". Quote Link to comment Share on other sites More sharing options...
louthmedia Posted October 18, 2010 Author Share Posted October 18, 2010 i would like to thank you all for your help with my problem. i have know found the problem the first was the as Pikachu had pointed out i was missing the end tag on line; $db-pass = "password" the next problem was the i had addied typing mistake on line 3 and the final one was i and missed the '$' off on line 9 i know have connection to the database. which means i can move on with building the CMS software 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.