Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Php and mysql username and password - do I put it in all php
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
brent_weaver
Guru
Guru


Joined: 01 Jul 2004
Posts: 510
Location: Burlington, VT

PostPosted: Sun Apr 20, 2014 11:21 pm    Post subject: Php and mysql username and password - do I put it in all php Reply with quote

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
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Mon Apr 21, 2014 3:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
brent_weaver
Guru
Guru


Joined: 01 Jul 2004
Posts: 510
Location: Burlington, VT

PostPosted: Mon Apr 21, 2014 3:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Mon Apr 21, 2014 4:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
snkmoorthy
Guru
Guru


Joined: 19 Nov 2002
Posts: 376

PostPosted: Tue Apr 22, 2014 8:51 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum