How do you use 1 database for multiple php scripts?
by alexanderino
Question by justin1003356: How do you use 1 database for multiple php scripts?
Ok, so i have a lot of different php scripts like user management, shopping cart, forums. I don’t want my customers to have to sign-up multiple times for my website. I need to know how to do this.
Thanks A lot
Best answer:
Answer by Nigel
You only need the one database, you can connect to it from as many scripts as you want.
Each script will have something like ( for MySQL )
$ conn = mysql_connect($ dbhost, $ dbuser, $ dbpass)
or die (‘Error connecting to mysql’);
Have a look at http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/connect-to-mysql-database.aspx for more examples.
Know better? Leave your own answer in the comments!