Diegar Posted September 17, 2007 Share Posted September 17, 2007 Hello. I am rather new to PHP and this question isn't about something that needs a fix. I was just looking for clarification, just so i know i understand it. $msa = mysql_connect(localhost,$username,$password);@mysql_select_db($database,$msa) or DIE("unable to select database"); Could this basically be written as: @mysql_select_db(localhost,$username,$password,$database) or DIE("unable to select database"); It isn't that i want to. I just want to make sure that i have the concept down. Every little bit of understanding seems to lead to a lot more of it. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 17, 2007 Share Posted September 17, 2007 The mysql_select_db function has one required parameter and one optional parameter, the name of the database to select and the connection object to use (if any). You cannot use mysql_select_db to connect to the database, that's not what it does. This would work though:mysql_select_db("database_name", mysql_connect("localhost", "user", "pass")); Link to comment Share on other sites More sharing options...
Diegar Posted September 17, 2007 Author Share Posted September 17, 2007 The mysql_select_db function has one required parameter and one optional parameter, the name of the database to select and the connection object to use (if any). You cannot use mysql_select_db to connect to the database, that's not what it does. This would work though:mysql_select_db("database_name", mysql_connect("localhost", "user", "pass"));Thank you. That made perfect sense. Link to comment Share on other sites More sharing options...
zppblood Posted September 18, 2007 Share Posted September 18, 2007 You will also want to enclose text/string with quotation marks as PHP will first look for constants with the same name, therefore making it slower. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.