qasaa Posted June 9, 2011 Share Posted June 9, 2011 hi, i came across some code like: $db=''; . . . mysql_select_db($db) or die("SomeText"); As you can see $db parameter is empty. What database name will "mysql_select_db" function use? Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/ Share on other sites More sharing options...
Maq Posted June 9, 2011 Share Posted June 9, 2011 What database name will "mysql_select_db" function use? It will use the empty string and return FALSE if it doesn't find the DB. Are you sure that it's not resigning $db somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227655 Share on other sites More sharing options...
qasaa Posted June 9, 2011 Author Share Posted June 9, 2011 It is empty. Does it give an error if we dont specify a database name? Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227659 Share on other sites More sharing options...
Maq Posted June 9, 2011 Share Posted June 9, 2011 It is empty. Does it give an error if we dont specify a database name? What is? Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227663 Share on other sites More sharing options...
matthew9090 Posted June 9, 2011 Share Posted June 9, 2011 go into phpmyadmin or whatever you use and see what the database name is then do this: mysql_connect("hostname", "user", "pass") or die("could not connect"); mysql_select_db("database_name") or die("could not connect to the database"); if your using a local server the connect normally looks like this: mysql_connect("localhost", "root", ""); Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227664 Share on other sites More sharing options...
qasaa Posted June 9, 2011 Author Share Posted June 9, 2011 can you pls check this link : http://www.phpeasystep.com/phptu/24.html There is a config.php file in Step 5. Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227670 Share on other sites More sharing options...
Maq Posted June 9, 2011 Share Posted June 9, 2011 That code is telling you to provide YOUR credentials, hence the comments: $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227672 Share on other sites More sharing options...
qasaa Posted June 9, 2011 Author Share Posted June 9, 2011 oh, ok now. i am a beginner Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227676 Share on other sites More sharing options...
matthew9090 Posted June 9, 2011 Share Posted June 9, 2011 search on google for php tutorials. like w3schools or tizag Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227677 Share on other sites More sharing options...
qasaa Posted June 9, 2011 Author Share Posted June 9, 2011 thanks for your kind help. Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227678 Share on other sites More sharing options...
Maq Posted June 9, 2011 Share Posted June 9, 2011 thanks for your kind help. Sure, if you're still having trouble with the tutorial/script just come back and ask. You can mark threads resolved (bottom right button, I believe). Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227680 Share on other sites More sharing options...
Pikachu2000 Posted June 9, 2011 Share Posted June 9, 2011 can you pls check this link : http://www.phpeasystep.com/phptu/24.html There is a config.php file in Step 5. Please don't use that site as a learning resource. Their code is badly outdated. Quote Link to comment https://forums.phpfreaks.com/topic/238914-about-mysql_select_db/#findComment-1227683 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.