Online Support from Domainscape

 

Support Database
How do I query a MySQL database from a PHP script?

Use the following outline to connect and begin querying the MySQL server from within your PHP scripts. Remember that you cannot connect to your databases remotely for security reasons; you can only connect from localhost.

1. Connect to the MySQL Server

Use the following statement to connect to the database server. Substitute the username and password for those that have been created in the control panel and have given adequate permissions to this database.

mysql_connect('localhost','USERNAME','PASSWORD');

2. Select Your Database

Use the following statement to select the database you wish to connect to. Make sure you substitute your database name.

mysql_select_db("DATABASENAME");

3. Executing A Query

You are now ready to execute your queries. Most problems that arise with your scripts will be caused by incorrect permission settings or syntax errors within the code.

Return to category list

 

 

 

Every attempt has been made to ensure that all information, opinions and guidance notes are accurate, comprehensive, verified and complete.

We accept no liability whatsoever for any perceived inaccuracy or incompleteness of the information contained in the Web Site or for any reliance placed by any person on the information.

 

Copyright ©2008
Domainscape Internet
All rights reserved