[Labs-l] Connecting to MySQL in PHP
Maximilian Doerr
maximilian.doerr at gmail.com
Tue Jun 17 17:01:43 UTC 2014
Something like
<?php
$db_mycnf = parse_ini_file($_SERVER['HOME']."/replica.my.cnf");
$db_username = $db_mycnf['user'];
$db_password = $db_mycnf['password'];
unset($db_mycnf);
should do nicely. It’ll store the username and password to the variables $db_username and $db_password.
From: labs-l-bounces at lists.wikimedia.org [mailto:labs-l-bounces at lists.wikimedia.org] On Behalf Of Emilio J. Rodríguez-Posada
Sent: Tuesday, June 17, 2014 12:35 PM
To: Wikimedia Labs
Subject: [Labs-l] Connecting to MySQL in PHP
Hello;
I need to connect to a MySQL database using PHP. I have a replica.my.cnf that I guess I have to use. What is the best way to connect to MySQL using this file, without exposing the user/pass in the PHP code?
There is no help about this in the tutorial.[1]
Thanks
[1] https://wikitech.wikimedia.org/wiki/Nova_Resource:Tools/Help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/labs-l/attachments/20140617/00f12178/attachment.html>
More information about the Labs-l
mailing list