0

I am trying to setup a connection to my sql database based off the example below.

// ----------------------
// Retrieve some private information like my db password

   include("db_info.php");

// ----------------------
// Connect to Oracle database

   $conn = oci_connect('username', $db_pwd, '(DESCRIPT...

My question is, how do I handle the db_info.php file? I have my password stored in there as

$db_pwd = "something"

*Edit - The error I get when trying to open my page is as follows.

Array ( [code] => 24415 [message] => ORA-24415: Missing or null username. [offset] => 0 [sqltext] => ) 
7
  • 1
    I'm not sure what the question is. Commented Apr 24, 2012 at 21:51
  • When you use include(), all global variables from the included file should be immediately available for use. What is the error you're seeing? Does it have anything to do with the fact that your include() statement references a file ".db_info.php", and the text of your question references "db_info.php"? Commented Apr 24, 2012 at 21:52
  • @TomvanderWoerdt I think the title is misleading and he is worried if anyone can read his password. So long as its out of the web root (public) folder its safe. In fact the only way it isn't safe (PHP being server-side) is if the PHP parser fails and the PHP file is displayed as plain text, which never happens. Commented Apr 24, 2012 at 21:53
  • Updated to show an error I am receiving. Commented Apr 24, 2012 at 21:59
  • Are you entering your correct username? Commented Apr 24, 2012 at 22:05

2 Answers 2

1

Make sure your username is correct. If it's a variable in db_info.php, the code below is wrong:

$conn = oci_connect('username', $db_pwd, '(DESCRIPT...

if it's a variable it should be:

$conn = oci_connect($username, $db_pwd, '(DESCRIPT...

Also, are you sure you're using an Oracle database? (Sorry, had to ask) :)

EDIT:

Looking at this again, it looks like you have a simple typo. Try this:

include("../db_info.php");

You had an extra . in there.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I was able to connect when I manually entered my password. I would like to be able to use the include("../.db_info.php"); though.
0

You have to write in your database information somewhere, and your solution is sound enough. it doesn't even need to be hidden, since unless you have FTP-access, you'll never be able to view its content.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.