Re: Re: Programs not Running - SOLVED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jan 6, 2013 at 6:32 PM, Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx> wrote:
> On 1/6/2013 7:17 PM, Ethan Rosenberg, PhD wrote:
>>
>> The problem was in this piece of code:
>>
>>          require '/var/www/pass.inc';
>>          $db = "Store";
>>          $cxn = mysqli_connect($host,$user,$password,$db);
>>          if ( !$cxn ) {
>>            die( 'connect error: '.mysqli_connect_error() );
>>              }
>>
>> I had moved the password file [/var/www/pass.inc] out of root, but
>> forgot to change the code!
>>
>> This still leaves a question:
>>
>>          if ( !$cxn ) {
>>            die( 'connect error: '.mysqli_connect_error() );
>>              }
>>
> You're asking why the die was reached rather than having a fatal error occur
> because the require couldn't be performed?  Perhaps because there exists
> another "pass.inc" file somewhere in PHP's default search folders for the
> require, but it contained the wrong password?

It is a bit difficult having not seen a shred of Ethan's scripts'
actual output, and questionable actual content, but the snippet as
shown here is an absolute path specification, and thus php would not
go through it's load path to look for it:

<?php
$testpath = "/tmp/www";
$ipath = ini_get("include_path");
$ipaths = explode(":",$ipath);
if (!file_exists($ipaths[0].$testpath)) {
  mkdir($ipaths[0].$testpath,0777,true);
}
file_put_contents($ipaths[0].$testpath."/testfile","This is the
searched version");
require($testpath."/testfile"); // note that the absolute path is given here

-*- mode: compilation; default-directory: "/home/tamara/Projects/examples/" -*-
Compilation started at Sun Jan  6 21:27:03

php phpincludepath.php
PHP Warning:  require(/tmp/www/testfile): failed to open stream: No
such file or directory in
/home/tamara/Projects/examples/phpincludepath.php on line 13
PHP Stack trace:
PHP   1. {main}() /home/tamara/Projects/examples/phpincludepath.php:0
PHP Fatal error:  require(): Failed opening required
'/tmp/www/testfile' (include_path='.:/usr/share/php:/usr/share/pear')
in /home/tamara/Projects/examples/phpincludepath.php on line 13
PHP Stack trace:
PHP   1. {main}() /home/tamara/Projects/examples/phpincludepath.php:0

Compilation exited abnormally with code 255 at Sun Jan  6 21:27:03

Thus, I would conclude that the file /var/www/pass.inc actually *did*
previously exist, but contained incorrect credentials, making the
require not complain, but the connect complain instead.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux