Re: Require error

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

 



On Fri, Dec 19, 2008 at 12:55 PM, Kyle Terry <kyle@xxxxxxxxxxxxx> wrote:

>
>
> On Fri, Dec 19, 2008 at 9:50 AM, Wolf <lonewolf@xxxxxxxxx> wrote:
>
>>
>> ---- Kyle Terry <kyle@xxxxxxxxxxxxx> wrote:
>> > On Fri, Dec 19, 2008 at 9:43 AM, Wolf <lonewolf@xxxxxxxxx> wrote:
>> >
>> > > Bottom Post
>> > >
>> > > ---- sean greenslade <zootboysean@xxxxxxxxx> wrote:
>> > > > No. The file is called testing.php and it is trying to include
>> sql.inc
>> > > >
>> > > > On Fri, Dec 19, 2008 at 12:36 PM, Kyle Terry <kyle@xxxxxxxxxxxxx>
>> wrote:
>> > > >
>> > > > >
>> > > > >
>> > > > > On Fri, Dec 19, 2008 at 9:28 AM, sean greenslade <
>> > > zootboysean@xxxxxxxxx>wrote:
>> > > > >
>> > > > >> So, I have this code in a php file called testing.php:
>> > > > >> $incl = '/webs/www.zootboy.com/sl/sql.inc';
>> > > > >>  if(!is_readable($incl)) die('ERROR: MySQL Include file does not
>> > > > >> exist??!?');
>> > > > >>  require $incl or die('MySQL page not found. Unable to
>> continue.');
>> > > > >>
>> > > > >>
>> > > > >> When I run the code in command line, it outputs this:
>> > > > >>
>> > > > >> [root@localhost ~]# php -f /webs/www.zootboy.com/sl/testing.php
>> > > > >> PHP Warning:  require(1): failed to open stream: No such file or
>> > > directory
>> > > > >> in /webs/www.zootboy.com/sl/testing.php on line 13
>> > > > >> PHP Fatal error:  require(): Failed opening required '1'
>> > > > >> (include_path='/var/php/inc/') in /webs/
>> > > www.zootboy.com/sl/testing.php on
>> > > > >> line 13
>> > > > >>
>> > > > >> I have no idea what's going on. All the files have 777 perms.
>> > > > >>
>> > > > >> --
>> > > > >> --Zootboy
>> > > > >>
>> > > > >
>> > > > > Are you trying to require itself?
>> > >
>> > > Change your line to:
>> > > require('$incl') or die('File not found');
>> > >
>> > > Require can be dork about things like this, I normally wind up
>> handling to
>> > > fiddle with the coding for them.
>> > >
>> > > Wolf
>> > >
>> >
>> > Actually, single quoted will be string literal. He would need to encase
>> them
>> > in double quotes so the parser knows it might be looking for a variable.
>> > require("$incl") is what he wants.
>> >
>>
>> See!  I told you I always have problems with those!  :)
>>
>> Normally I'm not so literal though.
>>
>> so yeah:
>> require("$incl");
>> include("$incl");
>>
>> I prefer the includes over the requires, but that is personal preference.
>>
>> Wolf
>>
>
> It really all depends on how you want to handle errors. If you want to kill
> the script because the database can't be reached, use require or
> require_once, if you want the script to continue and handle everything
> differently in the event that a file isn't loaded, use include or
> include_once.
>
>
> --
> Kyle Terry | www.kyleterry.com
>

I want the page to stop if it can't access the DB. It is required for the
function of the page.

-- 
--Zootboy

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux