View previous topic :: View next topic |
Author |
Message |
brent_weaver Guru
Joined: 01 Jul 2004 Posts: 510 Location: Burlington, VT
|
Posted: Sun Apr 20, 2014 11:21 pm Post subject: Php and mysql username and password - do I put it in all php |
|
|
Hello - is there a way (or I should say there has to be a way) to avoid having to put mysql authentication into every php page. I assume there is a sort of include statement or something like that. I have also need a php.ini file, is it in there?
Any help is MUCH appreciated! _________________ Brent Weaver |
|
Back to top |
|
|
aCOSwt Bodhisattva
Joined: 19 Oct 2007 Posts: 2537 Location: Hilbert space
|
Posted: Mon Apr 21, 2014 3:21 pm Post subject: |
|
|
Php and mysql username and password ?? having to put mysql authentication into every php page ? What do you mean ?
An instruction of the kind
Code: | if(!(mysql_connect('localhost','root','')&&mysql_select_db('CTL_DB')&&mysql_query("SET NAMES utf8")&&mysql_query("SET lc_time_names='fr_FR'")))... | ? _________________
|
|
Back to top |
|
|
brent_weaver Guru
Joined: 01 Jul 2004 Posts: 510 Location: Burlington, VT
|
Posted: Mon Apr 21, 2014 3:31 pm Post subject: |
|
|
let's say I change the password in MySQL for the user I am using, do I have to go to each PHP page that connects to MySQL and change it there? There has to be a place I can store login info globally for MySQL that PHP pages can refer to. _________________ Brent Weaver |
|
Back to top |
|
|
aCOSwt Bodhisattva
Joined: 19 Oct 2007 Posts: 2537 Location: Hilbert space
|
Posted: Mon Apr 21, 2014 4:09 pm Post subject: |
|
|
brent_weaver wrote: | let's say I change the password in MySQL for the user I am using |
thanks to what ? phpmyadmin ? another tool of the kind ? A custom program you wrote ? An instruction from console ?
Where are your php server and database server running (locally ? remotely?)
Who gets access to them ? you only ? The world ? How ?
Well... all these questions only to understand if what you want is only to avoid fiddling the mysql_connect statement. _________________
|
|
Back to top |
|
|
snkmoorthy Guru
Joined: 19 Nov 2002 Posts: 376
|
Posted: Tue Apr 22, 2014 8:51 am Post subject: |
|
|
brent_weaver wrote: | let's say I change the password in MySQL for the user I am using, do I have to go to each PHP page that connects to MySQL and change it there? There has to be a place I can store login info globally for MySQL that PHP pages can refer to. |
Write a DBConn singleton class and put your mysql_connect call there. Once this is done you have to decide, all your client code can access the DBconn.instance run their own query or you can write a 'execute_query' method as single point of running SQL queries with the DBconn class, so that it is easier to managing SQL logging. |
|
Back to top |
|
|
|