top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to select a mysql database in php?

–1 vote
43 views
How to select a mysql database in php?
posted Mar 13, 2017 by Kavyashree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Using mysql_select_db() function we can select a database in PHP is mysql is in connected state. Following sample code may help you -

$db=mysql_pconnect(<hostname>, <username>, <password>);
if (is_resource($db)) {
   if (!mysql_select_db(<database>, $db)) {
          mysql_close($db);
          // <report error>;
    }
}
// Now we can use $db in various operation
answer Mar 14, 2017 by Arun Angadi
Similar Questions
0 votes

I have a client where their next auto-increment number just jumped from 2300 to 1000000000 for reasons not understood. They want it set back.

Options such as dropping the primary key and rebuilding the index is NOT possible -- this is a relational table thing. So, is there a way (programmatically) to set the next number in an auto-increment?

Something like:

alter table abc auto_increment = 2301;

Any ideas of why this happened?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...