Be a Supporter!

Mysql Select

  • 463 Views
  • 3 Replies
New Topic Respond to this Topic
Mister-Mind
Mister-Mind
  • Member since: Jul. 1, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Mysql Select 2006-08-31 16:31:42 Reply

Does anyone know the MYSQL code To Select a database. Not the PHP code but the Syntax please.

SpamBurgeralt
SpamBurgeralt
  • Member since: Jul. 22, 2005
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to Mysql Select 2006-08-31 16:46:00 Reply

mysql_select_database('database');

??


I'm 12 years old and what is this?

Ross
Ross
  • Member since: Dec. 15, 1999
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Mysql Select 2006-08-31 17:17:27 Reply

use <databasename>;


Ross Snyder - PHP Juggler
If you find a problem on the website, send me a PM.

JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to Mysql Select 2006-08-31 22:55:38 Reply

Before selecting a database, make sure you are connected to MySQL. The following lines show how to connect to MySQL and how to select a database:

@mysql_connect('localhost','usernameToData
base','password') OR die('Could not connect to MySQL.');
@mysql_select_db('databaseName') OR die('Could not connect to database.');

*NOTE: the @ preceeding the mysql functions are used to suppress any errors that would be returned. Using "or" after these functions instructs execution of the next command if the first execution returns false. In this case, and better understood, if the mysql function fails, it's error will be suppressed and a die function will execute in order to output a more "user-friendly" error message.
Also, you need to actually feed queries to PHP to carry out tasks to the database.