★ wanayoo — archive 1999 http://www.php.net/manual/function.mysql-select-db.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to MySQL
Quick Reference
MySQL
* mysql_affected_rows
* mysql_change_user
* mysql_close
* mysql_connect
* mysql_create_db
* mysql_data_seek
* mysql_db_query
* mysql_drop_db
* mysql_errno
* mysql_error
* mysql_fetch_array
* mysql_fetch_field
* mysql_fetch_lengths
* mysql_fetch_object
* mysql_fetch_row
* mysql_field_name
* mysql_field_seek
* mysql_field_table
* mysql_field_type
* mysql_field_flags
* mysql_field_len
* mysql_free_result
* mysql_insert_id
* mysql_list_fields
* mysql_list_dbs
* mysql_list_tables
* mysql_num_fields
* mysql_num_rows
* mysql_pconnect
* mysql_query
* mysql_result
* mysql_select_db
* mysql_tablename
Manual: mysql_select_db
View the source code for this pageSearch the site



Previous page
 mysql_result
mysql_tablename 
Next page


mysql_select_db

mysql_select_db -- Select a MySQL database

Description

int mysql_select_db(string database_name, int [link_identifier] );

Returns: true on success, false on error.

mysql_select_db() sets the current active database on the server that's associated with the specified link identifier. If no link identifier is specified, the last opened link is assumed. If no link is open, the function will try to establish a link as if mysql_connect() was called, and use it.

Every subsequent call to mysql_query() will be made on the active database.

See also: mysql_connect(), mysql_pconnect(), and mysql_query().

For downward compatibility mysql_selectdb() can also be used.


User Contributed Notes: mysql_select_db


scotts@maxify.com
27-Jun-1999 10:04
After a bit of frustration (and despite what would seem to be advice to the contrary), you _must_ feed the return value into a variable. So, for example, this won't work: mysql_select_db($dbName); $selectResult = mysql_error(); But this will: $selectResult = mysql_select_db($dbName,$connectDB); This is at least true with PHP 3.0.7, MySQL 3.22.22, and RedHat 6.0.


mcardia@travelnet.com.br
02-Apr-2000 12:09
Hi. I'm trying to use mySQL with PHP3 but it's not working on. I'm using
 $Db = mysql_connect('localhost','','');<br>
 mysql_select_db('teste');
when i try to select my database it fail. someone can help me?


rdominguez@harvardnet.com
04-Apr-2000 08:32
Hello in response to MCardia question im a php/MySQL newbie myself and im learning stuff as a go along and from all the tutorials on the net, i hope the following example helps:
mysql_connect()or die ("Problem connecting to DataBase");
$query = "YOUR SQL QUERY GOES HERE";
$result = mysql_db_query("DBname", $query); 


rdominguez@harvardnet.com
04-Apr-2000 08:32
Hello in response to MCardia question im a php/MySQL newbie myself and im learning stuff as a go along and from all the tutorials on the net, i hope the following example helps:
mysql_connect()or die ("Problem connecting to DataBase");
$query = "YOUR SQL QUERY GOES HERE";
$result = mysql_db_query("DBname", $query); 
Rodrigo


rdominguez@harvardnet.com
04-Apr-2000 08:48
try to select the database and execute time a query on it at the same (see example above)I HAVE A QUESTION FOR U ALL... WHAT IS BETTER TO USE :
mysql_fetch_array  or mysql_fetch_row ?
thank-Q Rodrigo


rasta@planetgrey.org
30-Apr-2000 04:41
You could also try specifying user and password in your connect statement.. ie $dbh = mysql_connect('localhost:3306','user','password');


 About Notes


Previous page
 mysql_result
mysql_tablename 
Next page



Site Statistics


Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.