PHP - Selection of the currently used database
source link: https://www.codesd.com/item/php-selection-of-the-currently-used-database.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
PHP - Selection of the currently used database
I am having a problem in getting the string name of the currently selected database. this is what i did.. i am trying to echo the name of the database but it produces an error "Warning: mysql_fetch_array() expects parameter 1 to be resource"
<?php
$dbcon = mysql_connect("localhost", "root", "")
or die(mysql_error()."Not Connected");
$sql = mysql_query("select database()");
$row = mysql_fetch_array($sql);
echo "db ".$row[0];
?>
i need to get the selected database name because i will use it for
mysql_select_db()
You should either select a database right after connecting using your login credentials. Or, if you want to see what databases the root
user has access to, use:
SHOW DATABASES;
Related Articles
JQuery select only the current item when using on the click
Is it possible to use vimgrep for a visual selection of the current file?
PHP: What are the column-oriented databases
Change the current MongoMapper database at run time
PayPal WPP requires PHP cURL library. (Current use of CURL Not Found)
How to get the size of the current sqlite database or the size of the package in Android?
How do I replace the current MySQL database with an .sql file?
PHP Drop-down list of all records in the database + selection of the current record
How to make the selection of the current page use navigation
Is there a way to get ONLY the PHP page of the current page using javascript?
MySQLI Select from the table using prepared statements
How to start the php calendar on the current month of the viewer
PHP Check if the current time is before the specified time
JQuery How to select only the current and non-parent li
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK