Jump to content

Simple Question


Diegar

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...