Jump to content

real path function


jbooth952

Recommended Posts

I am new to PHP and new to dynamic web programming.

 

The realpath() function does not return anything. Is it a problem with my host or me?

 

I'm trying to open a database and I can't get the path to supply to the Data Source parameter within the OLEDB connection string.

 

Any help is appreciated.

 

I code - $db = realpath("/testdb/testname.mdb") or die("error") and it takes the die route.

Link to comment
https://forums.phpfreaks.com/topic/113961-real-path-function/
Share on other sites

Probably can't find the file you are trying to access.

 

$db = realpath("testdb/testname.mdb") or die("error")

 

True, but why? the file is on my web server. I verified that, and I can see it with my FTP client and the host's when I log into my account. This is a windows server, is there some IIS parm I need to set? Why can't it find the file?

 

 

Link to comment
https://forums.phpfreaks.com/topic/113961-real-path-function/#findComment-585699
Share on other sites

Doesn't IIS require backslashes? I can't remember if this is a function of PHP or Apache

 

Also the user running PHP might not have permissions to access the file... IIS/Windows deals with permissions in a stupid way ( IMO )

 

OK, I made some progress. I took out the / that was in front. The file_exists finds the file and realpath() finds the path.

 

But, now the open fails. This is just a little test script for my learning process.

 

Here is the code and the results. What the heck am I doing wrong?

 

<html>

<body>

<?php

if (  file_exists( 'testdb/naplayers.mdb' )  )

echo 'found file';

?>

<br>

<?php

$db = realpath('testdb/naplayers.mdb');

echo $db . "\n";

?>

<br>

<?php

$conn = new COM("ADODB.Connection") or die("Cannot start ADO");

$strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db";

echo $strConn . "\n";

?>

<br>

<?php

$conn->open($strConn) or die("open failed");

 

*************** Results on the web page;

 

found file

\\nawinfs06\home\users\web\b2884\sl.jimbooth\fproot\testdb\naplayers.mdb

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\nawinfs06\home\users\web\b2884\sl.jimbooth\fproot\testdb\naplayers.mdb

open failed

 

 

Thanks for the help.

 

 

Link to comment
https://forums.phpfreaks.com/topic/113961-real-path-function/#findComment-585740
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.