Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Require_once And Fatal Errors... Automatic Sleep And Try Again Anyone?


I have a PHP page which loads OK 80% of the time. However
the rest of the time I get the following error:

Fatal error: Failed opening required 'DB.php'

This really bugs me, especially since the only reason
this is happeneing seems to be due to server load. I
would like to add code so that instead of displaying
the given error, the PHP code makes the HTTP response
thread simply sleep a little bit (say 4 seconds), and
then retry, and repeat until the file can be opened.

It seems strange to me that server load would prevent
the file from being opened. Anyhow, any ideas on how
I can improve the situation?




View Complete Forum Thread with Replies

Related Forum Messages:
Require_once() Errors
Im making a website and i am writing a php script for a register form. The script checks for required fields if a required field is missed out then a error is generated. I think the problem might be on the server site.

There errors i am getting are

Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(/Connections/userlogin.php) is not within the allowed path(s): (/tmp:/usr/share/pear:/home/fhlinux169/m/maltmandarkblues.co.uk/user) in /home/fhlinux169/m/maltmandarkblues.co.uk/user/htdocs/Register.php on line 2

Warning: require_once(/Connections/userlogin.php) [function.require-once]: failed to open stream: Operation not permitted in /home/fhlinux169/m/maltmandarkblues.co.uk/user/htdocs/Register.php on line 2

Fatal error: require_once() [function.require]: Failed opening required '/Connections/userlogin.php' (include_path='.:/usr/share/pear-php5') in /home/fhlinux169/m/maltmandarkblues.co.uk/user/htdocs/Register.php on line 2

The code:

View Replies !
Require_once() Not Foolproof For Me, Still Getting Class Redeclaration Errors
Hello, I use require_once() in all my code that includes a separate class declared inside there.

However, there are times in certain cases where I will still get a class redeclaration error. The php error log says I'm FATAL ERROR, can't redeclare class or something to that extent. ph34r.gif

Are there any other cases where this error might occur even while using require_once()?

View Replies !
Require_once :: Fatal Error: Main(): Failed Opening Required
Fatal error: main(): Failed opening required 'c:************SMS xtmessageClass.php' (include_path='.;c:php4pear') in c:************SMSmobile.php on line 2

I know I have all the code right. I'm not really sure what this means or why this error is happening.

View Replies !
Fatal Errors
I'm getting this rather ugly error when i try to use the same include more than once:

Fatal error: Cannot redeclare resize_png_image() (previously declared in path/backup+.php:189) in path/backup2.php on line 189

Is there anything I can do to stop it happening? - I need to re-use this include anything up to 50 times on a page.

View Replies !
Warning/Fatal Errors
I get this on my page. Does that mean my database is not working? If anyone wants to see the database using my control panel I will gladly let you have a fiddle if you can help. Thanks. (btw i am using URL a content management system on my site which is where it is not working)

Warning: main(language/lang-.php) [function.main]: failed to create stream: No such file or directory in /home/inme/public_html/mainfile.php on line 166

Warning: main() [function.main]: Failed opening 'language/lang-.php' for inclusion (include_path='') in /home/inme/public_html/mainfile.php on line 166

Warning: head(themes//theme.php) [function.head]: failed to create stream: No such file or directory in /home/inme/public_html/header.php on line 31

Warning: head() [function.head]: Failed opening 'themes//theme.php' for inclusion (include_path='') in /home/inme/public_html/header.php on line 31

Fatal error: Call to undefined function: themeheader() in /home/inme/public_html/header.php on line 47

View Replies !
Fatal Errors Due To Cookies
We have created a business portal for our organization. The technology used for that is LAMP. Our major access management system of the portal is based on cookies. we set some user level cookies at the time of login; using thesecookies we provide access of our pages to user.

The problem is, sometimes after login process we are getting fatal errors due to cookies, because of cookies are not set and our files checking for the that. But the problem we can resolve after cleaning history, cookies, temp internet files in IE.

View Replies !
Include Path Fatal Errors
I have require statements that call pages sending variables:

<? require("http://www.MYDOMAIN.com/include/navbar.php?page=$page") ?>

PHP Fatal error: Failed opening required 'http://www.MYDOMAIN.com/include/navbar.php?page=Services' (include_path='.;c:phpincludes') in d:inetpubftprootvertechMYDOMAIN.comincludeheader.php on line 79

I'm pretty sure it's due to the php.ini file since everything was working before that.

View Replies !
Provide Pretty Page For Fatal Errors?
Is it possible in PHP to provide a nice pretty page when a fatal error occurs? (Or any of the errors listed here http://uk.php.net/manual/en/functio...ror-handler.php which you
cannot catch).

I have error_reporting turned off as I have a production server - but that just gives a blank page which is less than good.

View Replies !
Supress Errors At The Page Level? Undefined Index Errors.
I'm creating a simple reply form, and if a form item isn't answered I
get an error:
"Notice: Undefined index: rb_amntspent in
c:inetpubwwwrootmackinawsurvey.php on line 36"
even if in the code I allow for an unselected item. (Code at the
bottom here.)
It works fine otherwise.

Now in the past I've made a change to php.ini to repress errors, but
for this project I don't have access to the php.ini.
Is there a way to supress errors on that page for that session?

Or, is there a way to just not get that error at all?

Here's a sample of the code that gets the form response. If an item is
selected, no error for that question, but if an item is not selected I
get the error above even though I still get a successful echo for the
"else" or "default" option which occurs if nothing is selected:

$rb_visited = $_POST["rb_visited"]; //Have you ever visited Mackinaw
City, Michigan?
if ($rb_visited == "1") {
$rb_visited_reply = "Yes";
} elseif ($rb_visited == "0") {
$rb_visited_reply = "No";
} else {
$rb_visited_reply = "You did not answer this question";
};

$rb_lastvisit = $_POST["rb_lastvisit"]; //When was your last visit to
Mackinaw ity?
switch ($rb_lastvisit) {
case "1":
$rb_lastvisit_reply = "Earlier this year (2003)";
break;
case "2":
$rb_lastvisit_reply = "Last year (2002)";
break;
case "3":
$rb_lastvisit_reply = "2 years ago (2001)";
break;
case "4":
$rb_lastvisit_reply = "3 years ago (2000)";
break;
case "5":
$rb_lastvisit_reply = "4 or more years ago (1999)";
break;
default:
$rb_lastvisit_reply = "You did not answer this uestion";
}

View Replies !
PHP Sleep()
I've been sitting for quite a while now, reading the sleep() manual and tried to turn the code upside down and inside out but nothing helps... I want the current page to wait a few seconds before it is directed to another ( after a successfull registration ). So i thought the best way to do that is to use sleep().

However, this does work to a certain point ... the current page waits for 5 seconds, but the text I want to show the user in the meantime doesn't show? Why? Without the sleep() and the header() it shows without any problem. Code:

View Replies !
Sleep()
I tried to make a script which would print a line of text at 1 line per second or whatever time i put. So i went ahead and tried this. PHP Code:

echo "Passwords match.";
        sleep(1);
    echo "Passwords match.";
        sleep(1);
    echo "Passwords match.";
        sleep(1);
    echo "Passwords match.";

This is a example and the text in echo has no meaning. However the sleep waits and waits for all the other sleeps to finish and then prints out all text at once.

View Replies !
PHP Messaging And Sleep
I would like to get my php script to send a message to a user for example to notify that a DB update or insert has been successful or not. After that the script will be redirected to the home page.

how can this be done ?

I have tried using sleep(5) to delay the script but that does not work the way that I want it to since it simply delays the execution of the ENTIRE script RATHER than a part of it !!

View Replies !
Sleep() In The Background
how much the sleep() which is set to no limit can consume the system resource. Could it cause to hang the server? I tried the following and couldnot see the server got busy. Although the browser seemed to be so, if I access to a different page, it responded very quick as usual. It's not a big deal, is it? sleep.php PHP Code:

<?php
set_time_limit(0);
sleep(0);
?>

fork_sleep.php

PHP Code:

<?php
$str = "php -f sleep.php";
exec("$str > /dev/null &");
?>

View Replies !
Fsocketopen & Sleep
I'm trying to setup a fsocketopen script to ping a site every 15 minutes or so and if the site is down, send an email. I'm thinking of using ignore_user_abort() to run the script in the background and sleep() for the time intervals. I'm not really sure how to script this out.

View Replies !
Sleep And Max_Execution_Time
I have the following code:

$i=0;
while($i++<15) {
   mail("rantsh@hotmail.com",date("d m Y H:i:s"),"This is email # $i ");
   echo "mandado $i <br>";
   sleep(60);
}

Now, I know my server has a 30 second max_execution_time setting... nonetheless, this code runs successfully!!!. Now, this is actually better for me (for the application I need to run)... Yet I'm concerned of why it's being allowed to run for 15 minutes if max_execution_time is set to 30. Code:

View Replies !
Would I Use Sleep To Delay
I am making a site for a friend, but with his PHP it always renders too quick and I would like it to wait a bit for the rest of the page to load,

otherwise its a bunch of annoying gaps and whacked alignment as the CSS and images load and it all just looks annoying as it loads. And it takes away from the order of of information outputted as it goes through the PHP when your focused on the tripped out layout.

View Replies !
Sleep Function
I'm playing about with delaying results of a PHP program. I want to print some results then wait for a few seconds and print some more. I have found the php sleep function however have a small problem.

<?php
echo ("The time in 3 seconds from page loading:
");
sleep(3);
echo date('h:i:s') . "
";
?>

The above script is meant to print the top line, wait 3 seconds and print the bottom line. Infact, it starts, waits 3 seconds and prints all at once.

Now from my understand from php.net it should not sleep untill it hits the sleep command in there.

View Replies !
Sleep For 10 Seconds Help
I am trying to run it will load an iframe for every entry found in my DB, I am trying to make it sleep for 10 seconds between each iframe with: PHP Code:

sleep(10);

PHP Code:

$train = "<table width=800 bgcolor=F0F0F0 aling=center><tr><td colspan=4>&nbsp;&nbsp;&nbsp;$pages<br></td></tr>";
$i=0;
while ($addall = mysql_fetch_assoc($res))
{
    if ($i/2 == ceil($i/2)) $train .= "<tr>";
    $i++;
$train .= "<td width=120 valign=top><BR><iframe src="potspace.php?u=$addall[intId]" width="400"></iframe>";
}
$train .= "<tr><td colspan=4><br><br>&nbsp;&nbsp;&nbsp;$pages<br><br></td></tr></table>";

View Replies !
Session Timeout, Use Of Sleep Ect...
I have a custom script that uses sessions to track UID's. The only problem I have with the script is that the session times out in 1440 (min?) which I believe is 24 min. I was thinking that I could use php's sleep to hold off from doing a refresh until minute 20.

Unfortunately, I have also read that using sleep can leave a server open to a DoS attack.
I do not have access to the php.ini file to be able to change the timeout variable for the session. What is the best way to keep a session open without changing the .ini variable. Is sleep a good way do go about it, and if so, are there significant security risks in using sleep()?

View Replies !
Sleep() Affects The Variables?
could it be that the sleep() function affects my variables? When I set a very long delay time (1-3 hours) in my CronJob PHP4 script (of couse with a big set_time_limit) some of my variables go lost! But there's no problem with short times in the sleep-function (1-5 min).

set_time_limit(86400);
for($x=1;$x<5;$x++) {
echo $x; //$x will be shown only one time
sleep(7200);}

View Replies !
Need To Flush Before Sleep But I'm Blank.
I'm new to php and am converting a bunch of asp pages to php.

Current problem :

I am using a Submit button on a form to POST ( send the database variables )
to a php page that will send a personalised e-mail to each client.

On the php page,
I am looping through a database,
compiling a message ( html format ),
and mailing the message to my client.

After the mail has been sent, I need to wait for 4 seconds before continuing
with the next database record.

I am using this code after the mail has been sent :

echo "Mail Sent to : " . $row['CliName'];
ob_flush();
flush();
sleep(4);

Problem is, that nothing appears after I click on the Submit button on the
first page's form ( the first page just remains on the screen ). Once the
database has been looped, the entire (correct) output appears on my screen -
but I need to see some sort of progress as it works it's way through the
database.



View Replies !
Sleep Function Or Any Thing Like?
i wanna make search page when you submit the search form it will direct you to search page but before the search starts i wanna make it waiting how can i make this.

View Replies !
Sleep(900) ? Delayed Query... ?
Trying to set a marker in a MySQL table on our Primary host (WAMP stack) indicating whether or not there is current User Activity -- ON THAT SERVER -- as a signal to remote Secondary -- tablet pc based servers to skip scheduled database synchronization with the Primary. Code:

View Replies !
Sleep(), Exec() And MySQL
How to create dynamically generated table .....

View Replies !
Sleep() And Browser Load.
is there a way to get around the browser continually acting like they are loading when using sleep()? It says the page is still loading but it really isn't because we are causing a delay for some data on purpose with php.

So it is for an intentional reason that we cause it. Many of us like using sleep(). Anyway to do it without the browsers showing the page is still loading? There must be a way, so many programmers for intense programming use sleep(), I can't imagine they have to deal with the browsers loading prompts whenever they do.

View Replies !
Staggering Execution With Sleep()
For my site, currently in development, I will be hosting some latest RSS picks from friend websites. To start with there will only be a couple, but eventually I hope to be sourcing from up to 50 partner blogs.

Obviously, i dont want to make a request on every page load, so I would instead cache data from the past half hour/hour.

I will be using CRON to schedule an update every so often, but having a single script making 50 requests one after the other then processing and storing the data may be taxing, especially if the outside server is slow.

I thought about using sleep() to leave gaps between each request so that a sudden hogging of resources doesnt happen every hour.

What are your views on this method? Is it feasable (and possibly even a good idea), or should I just get it all to execute in one go?

View Replies !
Processlist Sleep Command
a couple times i have notice the command sleep, with times like 200 or even 1700, what might be the cause of this? anyone know?


View Replies !
Resources Used When Using The Sleep() Function
I want to use the Sleep() function in a script that may run multiple times, but i dont want hte system to crash or be overloaded with scripts in memory. When the script enters a sleep mode, what happens to the script? is it resident in memory? if so could i experience the system bogging down if there were 100+ scripts resident in memory or are they just sitting there doing nothing until they run again?

View Replies !
SLEEP + Header Problem
I'm running a community website where I send out weekly newsletters to all of my clients. However, I'm sure my hosting provider wouldn't be so happy if I just FOR LOOP and send it all out at once.

SO what I did was I just a SLEEP and a header mthod that triggers after every second, where the header sends out GET variables for the next iteration to fetch at which account I am currently at to send the next newsletter. Code:

View Replies !
Insert Sleep Every X Rows
i am trying to insert a sleep command in my loop every 100 rows, the below works for every 2 but if i try to sleep every 100 rows it will not work.

if($i % 2) {
sleep(5);
}

does not work

[php]
if($i % 100) {
sleep(5);
}
[/php

View Replies !
Long Sleep() And Time-out's
The script I'm writing needs to wait a random amount of time (1-300s)
between each iteration of a loop, eg.

while(condition) {
do something
//wait between 1s and 5 minutes
sleep(rand(1,300));
}

Problem is, a browser times out if it doesn't get an answer within
about 30 seconds. Is the idea of having a PHP script sleep for a
longer amount of time incompatible with web applications? Any
work-around?

View Replies !
Putty Processlist Command Sleep
I'm using php with mysql. I am connecting through putty and I run the command for processlist. Lately I am seeing many threads with the command "sleep" in them. My site and the database are running smoothly, but I am seeing up to 200-300 threads like this with the command "sleep". Can anyone tell me what may be causing this and how do I resolve it? Or is it normal to see this when your site grows to a certain size?

Code: ......

View Replies !
Require_once()
require_once() does not include files if they were already included, does it mean that it would reuse the previous included file, and retain it as though it were included?

View Replies !
Require_once
I have an include file for the connection information to the server. It is
like this:

$hostname= "the_server_location";
$database = "the_database_name";
$dbUsername = "the_username";
$dbPassword = "the_password";
$dbCon = mysql_pconnect($hostname, $dbUsername, $dbPassword) or
die(mysql_error());
mysql_select_db($database, $dbCon);

In my main file I have right near the top: Code:

View Replies !
Require_once Problem
I hava several php files in different folders.

I tried to use relative paths. But when I call a script from another
folder that has another depth, it cannot find the files that are
embedded via require once within the included file.

sample:

fileA.php (in the root dir!)
-----
require_once 'common_inc.php'
....
-----

classes/fileB.php (in /classes)
-----
require_once '../fileA.php'
....
-----
No it trys to find the 'common_lib in the /classes folder insted of the
root dir.

Well, I tried now to specify absolute paths like
"http://127.0.0.1:8080/projectname/common_inc.php"
But it cannot be included then. Thats the browser string of the file.
Why doesn't it work?

How can I solve this problem?
It doesn't matter for me if relative or absolute paths specifications
are used. It should only work :)

View Replies !
Includes - Require_once
I have 3 files Index.php, x.php and  login/Login.php in Login.php

<?php require_once "../x.php"; ?>

Index.php
<?php require_once "loginLogin.php"; ?>

when executing Index.php error is Failed opening required '../x.php'
I can of course say <?php require_once "x.php" ?> in Login.php, then Index.php would load fine.. However if I load loginLogin.php independently, x.php would not be found.
So what should I do?

View Replies !
Require_once() Question.
I don't seem to be able to use full url's in either require_onec() or include() statements. is there anyway to signify the root folder so I can use the full file path?

View Replies !
Require_once - Use Chdir But Only Once
I need to use chdir but only once. Is there a way to stop chdir after a point in PHP? It keeps messing up my other scripts that I'm working on.

View Replies !
Include Vs Require_once
//include "clsUtilities.php";
//include "clsStaticMySqlUtilities.php";
require_once('clsUtilities.php');
require_once('clsStaticMySqlUtilities.php');
class MySqlInterface{

I had to use require_once('blah') as opposed to include 'blah' in all of my php classes. However, I did not have to use require_once('blah') in my non class files. Does anyone no what the difference is between these two methods of including classes in php?

View Replies !
Warning: Require_once
I have a php/mysql based website/shopping cart hosted on godaddy.  It was working fine for the last year then one day I get the following errors.

Warning: require_once(DB/DataObject.php) [function.require-once]: failed to open stream: No such file or directory in /home/content/p/h/r/phrazecrazy/html/cart/lib/classes/Font.php on line 5

Fatal error: require_once() [function.require]: Failed opening required 'DB/DataObject.php' (include_path='.:/usr/local/php5/lib/php') in /home/content/p/h/r/phrazecrazy/html/cart/lib/classes/Font.php on line 5

There has been absolutely no changes in my scripts etc, the only thing that could have happened is something on Godaddy's end.  Any ideas on what would cause this?  The files that it is asking for are there.

View Replies !
Require_once() Function
I have three files called index.php,output_fns.php,and php_fns.php. The php_fns contains all of the require function that links every page to one another.

the output_fns.php contains many functions that will be displayed different pages. The index.php just have two functions it. One connects to the php_fns and the other calles a function from output_fns.php.

The problem is that I want the data inside the output_fns.php to display inside of the body tag when it is called by index.php.

Example: Click Here And view source.

View Replies !
Weird Require_once
I have a file(call this file1) that has a class definition extending a parent class. This file has require_once on the top to include another file(call this file2) which has its own require_once which include the file that has the actual parent class definition. Somehow, php always complains at file2 and says that it can't find the parent class. Does anyone know why?

View Replies !
Require_once And Pear.php
I have code that brings in the Pear DB

require_once 'DB.php'

However, there is an include in the DB.php for the PEAR.php file, and the system does not appear to be able to locate that file. The PHP.ini has

include_path = ".;c:phpincludes;c:phpincludesPear"

PHP appears to use this dir. search path for the DB.php but not the internal Pear.php!

I can force the include but changing it to a full path, but this is not the best option.

View Replies !
Using Require Vs Require_once()
I have been using require_once() throughout my scripts because I thought it would save the processor time keep looking up the same function include file.

But it seems I might be wrong !

The Manual says

The require_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the require() statement, with the only difference being

Does this mean the require_once() is only useful if you use it in the same script more than once ?

I have about 30 different scripts that start like this:

/*
* a_get_detail.php
* Connects to tables and extracts the data
*/

require_once("my_functions.php");

other code ....

I have also just read that require_once() is slower than the standard require() function.

In this case is it better for me to be using require() as I don't think I am gaining anything from using require_once().

View Replies !
Require_once() And Subdirectories
Does require_once() treat "file.inc" and "subdirectory/file.inc" as the same things or different?

The reason for my question is that I'd like to organize my PHP library into subdirectories, and if I accidentally have a naming collision, I'm curious how require_once() will behave.

View Replies !
Correct Way Require_once?
I am working on a website. I have one index.php page that I am using "?do=dosomething" in the url link like http://www.index.com?do=showthingpage. Then I am using a switch statement to check what the do is and switch($_GET['do']) then using "<? case showthingpage: ($isloggedin) ? require_once(/showthingpage.php) : require_once(/anon.php) ?>" to load the required page into my main div. I am using about 20 case statements to do this for about 20 pages for the site. Is it alright to do it this way and just use one index.php page then load the pages into the div or should I have a page for each one. I though it would be easier to maintain this way?

View Replies !
Won't Recognize Require_once()
I'm trying to require_once("output_fns.php"); where the file includes my functions to create header & footer information around my main content. For some reason, the require code isn't working. This is the function code inside of output_fns.php:

Code: .....

View Replies !
Warning: Require_once(DB.php)
I have installed PHP on my windows 2003 server. I have also installed PEAR - following multiple instructions found online. However, I continue to get the following error when trying to write login authentication pages.

PHP Warning: require_once(DB.php)

I loaded PEAR via the .msi installer off of php.net and I tried loading PEAR from pear.php.net.

Does anyone know of a crystal clear tutorial for making sure PEAR gets loaded correctly and this DB.php file gets loaded?

View Replies !
Problem With Require_once() In Windows
I have been hoping to use my laptop as a porta-server but ran into
this problem. It seems that require_once() is not working for me!

The child class file has a 'require_once()' to the parent class file
and I'm sure it is correct (this works fine in *nix environments). But
I get this error message:

Fatal error: Class sessionmodel: Cannot inherit from undefined class
model in ...includemodel-session.php on line 7

Anybody know what might be up with this?
I am using Windows XP Professional, with the latest apache 1.x and
php4. No extra libraries installed, everything pretty much default
settings.

View Replies !
Does Require_once Cache Files At All?
I have a file that looks like this: PHP Code:

View Replies !
Require_once, Undefined Function?
I have a script:

http://www.mydomain.com/test/admin/foo.php

That looks like this:
<?php
$baseDir = "http://" . $_SERVER[ "SERVER_NAME" ] . "/test";

require_once( $baseDir . '/helpers/helper.php' );

something();
?>

something() is a function in helper.php.

I get:
Call to undefined function: something() in
/home/mydomain/public_html/test/admin/foo.php on line 6

The require_once doesn't fail (well, I don't get an error message), so I'm
assuming that it finds helper.php OK. something() definitely exists in
helper.php.

If I put foo.php and helper.php in the same folder, lose all the $baseDir
crap and use require instead of require_once it works fine (not sure if it's
the $baseDir part or the require_once that is tripping it up), however I
need them to be in seperate folders and I'd rather use require_once than
require in case I end up including something twice by accident, it's so much
easier not to have to worry about it.

I've been fiddling with this for about an hour now and it's starting to get
really annoying.

View Replies !
Require_once('DB.php') Failure
I'm using a relatively simple php script to query a mySQL database and
return values formatted to a variable string for interpretation by an
embedded swf. There is one php file that handles the connection to the
db (db_login.php) and one that handles the query (db_getProjects.php).
If I call up the db_getProjects.php file it simply spits back a
"&varibale=value..." blah blah string. The problem is that it works
only half the time...it'll be fine for a while then simply stop working
at all for a while...then start working again. When it isn't working
it is failing to even get past the require_once('DB.php') statement -
anything after that is never reached.

What could I be doing that is causing the require_once('DB.php') to
fail after working flawlessly for stretches?

note: I am making sure to close the connection at the end of each DB
call, so I don't think its due to open DB connections piling up, though
that seems to be the only logical answer.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved