benjahnee Posted March 20, 2013 Share Posted March 20, 2013 hello guys i have made a basic database in myadmin and i have written php code to connect to it. my database is called products. When i run the page i get the output - Connection Successful could not connect to products can somebody look at my code and tell me why i can not connect to my database <?php $host="localhost"; $user=""; $password=""; $db = "products"; $connect = mysql_connect($host, $user, $password); if($connect) { echo "Connection Successful"; $select = mysql_select_db($db); if ($select) { echo "<br /> connected to ".$db; } else { echo "<be /> could not connect to ".$db; } } else { echo "failed connection"; } ?> thankyou Link to comment https://forums.phpfreaks.com/topic/275918-problem-connecting-to-databse/ Share on other sites More sharing options...
Barand Posted March 20, 2013 Share Posted March 20, 2013 are you sure the database name is "products" or is that your table name? Link to comment https://forums.phpfreaks.com/topic/275918-problem-connecting-to-databse/#findComment-1419814 Share on other sites More sharing options...
benjahnee Posted March 20, 2013 Author Share Posted March 20, 2013 i called both the table and the database "products" would this cause a problem? Link to comment https://forums.phpfreaks.com/topic/275918-problem-connecting-to-databse/#findComment-1419823 Share on other sites More sharing options...
Barand Posted March 20, 2013 Share Posted March 20, 2013 i called both the table and the database "products" would this cause a problem? No, that's ok. Are you sure you spelled it correctly when you created it? try SHOW DATABASES Link to comment https://forums.phpfreaks.com/topic/275918-problem-connecting-to-databse/#findComment-1419922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.