Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SOME ONE LOOK AT THIS

Status
Not open for further replies.

rizza

Programmer
Jul 16, 2002
66
US
I'm an ASP developer at work and trying to learn php by night. I'm trying to write a page to display some links at of an SQL dbase. I can connect and do all the thing i normally do. I JUST CANT GET A DMAN INCLUDE TO WORK. In asp i just put my con scripts in a file and use a SSI to keep it "secure".

How do i pull this off in PHP? here's what i got so far.

this is my con script in a file off my root/dir called includes

<?php
$user = &quot;nnnnnn&quot;; username
$pw = &quot;mmmmmm&quot;; // mySQL password
$db = &quot;mmmmmmm&quot;; // database $mysql_access = mysql_connect(&quot;localhost&quot;, $user, $pw);
mysql_select_db($db, $mysql_access);
?>

ok no i have this code in the page that i want to included this with.

<?php
include('includes/cndb.inc');
?>

I'm always getting

Warning: Failed opening 'cndb.inc' for inclusion (include_path='.:/usr/local/plesk/php/lib/php') in /usr/local/plesk/apache/vhosts/mydomain.com/httpdocs/test.php on line 13

ANYBODY HELP ME...I'm pulling my hair out over something so stupid.

Also if there is a better way to hide my connection scripts please let me know.

Thanks in advance,

Brian Ridsdale
 
1. Try a better topic title than &quot;SOMEONE LOOK AT THIS&quot;. Normally I just ignore these.

2. Your system has a defined include path (not necessary in PHP, but allows you to include scripts from that directory without specifying a path). So, when you try to include something without a defined path as just 'includes/filename', PHP is going to look in your include path, rather than in your current directory. One way around this is: include('./includes/cndb.inc'), which specifies that you look in the local directory. Another way is to specify the full path. I have found one very useful method is to use PHP's getcwd() function, which returns the current working directory. Thus you could do:

Code:
include ( getcwd() . '/includes/cndb.inc' );
-------------------------------------------

&quot;Now, this might cause some discomfort...&quot;
(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top