Jump to content

Recommended Posts

Hi, this is more of a question than asking for help so if its in the wrong section could someone please move.

 

my question is could you connect to a database by using an array that has been generated from getting contents from a file, for example...

$file_c = file_get_contents("example.txt");
$colms = explode(",",trim($file_c));

mysql_connect("$colms[0]","$colms[1]","$colms[2]") or die(mysql_error());
mysql_select_db("$colms[3]") or die(mysql_error());

 

if not how else would someone go about doing this.

Link to comment
https://forums.phpfreaks.com/topic/237486-mysql_connect-question/
Share on other sites

Array variables are no different than any other variable, as long as they contain what you expect.

 

What sort of problem or error did you have when you tried your code?

 

Be careful when storing database credentials in a plain text file as anyone who discovers that file or sees it if your server allows directory listings can simply browse to the file and see your database credentials.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.