Nomadic Posted December 27, 2008 Share Posted December 27, 2008 Ok I have a test database named user up that looks like: user_ID |user_NAME |user_PASS 1JoeTest 2BillTesting 3CarlATest I am totally new to PHP/mySQL stuff and have been trying to figure out how to connect to a database. The problem is that when I run this code: <?php $username = "root"; $password = "<my password>"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to mySQL server."); print "Connected to mySQL server.<br>"; $selected = mysql_select_db("user",$dbh) or die("Could not access user database."); mysql_close($dbh); ?> It is unable to connect to the database. This despite the fact that I can look at the database in SQLiteManager and clearly see it (and everything is correctly placed and spelled as far as I know). Earlier when I was trying this I got an error that said it could not find the 'user' database (even though I was viewing the 'user' database right in front of me). So any ideas what I am doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/138595-solved-mysql-cannot-find-database/ Share on other sites More sharing options...
Mchl Posted December 27, 2008 Share Posted December 27, 2008 Do you know the difference between a database and a table? In short a database is a collection of tables. You seem to have a table called 'user' not a database. Another thing: SQLiteManager is not for MySQL. It's for SQLite, which is totally different thing. Quote Link to comment https://forums.phpfreaks.com/topic/138595-solved-mysql-cannot-find-database/#findComment-724666 Share on other sites More sharing options...
Nomadic Posted December 27, 2008 Author Share Posted December 27, 2008 Do you know the difference between a database and a table? In short a database is a collection of tables. You seem to have a table called 'user' not a database. Another thing: SQLiteManager is not for MySQL. It's for SQLite, which is totally different thing. The table is called userInfo (sorry for leaving that part out). So then how do I access and use the mySQL database on my server (I have wamp installed)? Quote Link to comment https://forums.phpfreaks.com/topic/138595-solved-mysql-cannot-find-database/#findComment-724667 Share on other sites More sharing options...
wildteen88 Posted December 27, 2008 Share Posted December 27, 2008 To manage MySQL databases you can use phpMyAdmin (this comes with WAMPServer). SQLiteManager is for SQLite databases only, these cannot be used with MySQL (or phpMyAdmin). Quote Link to comment https://forums.phpfreaks.com/topic/138595-solved-mysql-cannot-find-database/#findComment-724670 Share on other sites More sharing options...
Nomadic Posted December 27, 2008 Author Share Posted December 27, 2008 To manage MySQL databases you can use phpMyAdmin (this comes with WAMPServer). SQLiteManager is for SQLite databases only, these cannot be used with MySQL (or phpMyAdmin). Thanks I think that got it. Guess I was confused with the whole database thing (not amazing since my previous database experience is with txt and ini files with a splash of xml). Thank you, all of you (and thanks for the amazingly quick responses). Quote Link to comment https://forums.phpfreaks.com/topic/138595-solved-mysql-cannot-find-database/#findComment-724672 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.