MySQL PHP - Can You Select Someone Else Database
Interview Question Database For Software Developers
|
|
| Can You Select Someone Else Database | | Can You Select Someone Else Database? - MySQL FAQs - PHP Connections and Query Execution | | By: FYIcenter.com | If your MySQL server is provided by an Internet service company, they will
provide you one database for your use only. There are many other databases on the server
for other users. But your user account will have no privilege to select other databases.
If you try to access other databases, you will get an error.
The following tutorial exercise shows you a guest user trying to access the system
"mysql" database:
<?php
$con = mysql_connect('localhost:8888', 'guest', 'pub');
if (mysql_select_db('mysql', $con)) {
print("Database mysql selected.\n");
} else {
print("Database selection failed with error:\n");
print(mysql_errno($con).": ".mysql_error($con)."\n");
}
mysql_close($con);
?>
You will get something like this:
Database selection failed with error:
1044: Access denied for user 'guest'@'%' to database 'mysql'
| | ID: 1005 | Rank: 1071 | Votes: 0 | Views: 41 | Submitted: 20070510 |
1057 :-) | | How To Create a New Table | | How To Create a New Table? - MySQL FAQs - Managing Tables and Running Queries with PHP Scripts... | | Submitted: 20070510 |
|
Copyright © 2009 FYIcenter.com
All rights in the contents of this Website are reserved by the individual author.
No part of the contents may be reproduced in any form without author's permission.
|
|
|