jbooth952 Posted July 9, 2008 Share Posted July 9, 2008 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 More sharing options...
DyslexicDog Posted July 9, 2008 Share Posted July 9, 2008 Probably can't find the file you are trying to access. $db = realpath("testdb/testname.mdb") or die("error") Link to comment https://forums.phpfreaks.com/topic/113961-real-path-function/#findComment-585677 Share on other sites More sharing options...
discomatt Posted July 9, 2008 Share Posted July 9, 2008 For debugging <?php if ( !file_exists( 'testdb/testname.mdb' ) ) echo 'Could not find file'; ?> Link to comment https://forums.phpfreaks.com/topic/113961-real-path-function/#findComment-585687 Share on other sites More sharing options...
jbooth952 Posted July 9, 2008 Author Share Posted July 9, 2008 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 More sharing options...
jbooth952 Posted July 9, 2008 Author Share Posted July 9, 2008 For debugging <?php if ( !file_exists( 'testdb/testname.mdb' ) ) echo 'Could not find file'; ?> I'm certain that the file exists. For some reason it can't find it. Link to comment https://forums.phpfreaks.com/topic/113961-real-path-function/#findComment-585704 Share on other sites More sharing options...
discomatt Posted July 9, 2008 Share Posted July 9, 2008 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 ) Link to comment https://forums.phpfreaks.com/topic/113961-real-path-function/#findComment-585711 Share on other sites More sharing options...
jbooth952 Posted July 9, 2008 Author Share Posted July 9, 2008 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 More sharing options...
DyslexicDog Posted July 10, 2008 Share Posted July 10, 2008 Install mysql and make your life so much easier. Link to comment https://forums.phpfreaks.com/topic/113961-real-path-function/#findComment-586026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.