1 (edited by 2012-06-29 17:02:23)

Topic: Common php Warnings and Errors

TOPIC INDEX
If your error isn't in this list don't bother looking through this topic.

* date() expects parameter 2 to be long, ...
* Warning: Division by zero (...)
* Smilies display vertical
* Error 500: Internal Server Error
* failed to open stream: Permission denied in (...)
* Warning: preg_replace(): Compilation failed: unmatched parentheses
* Failed to open stream: No such file or directory
* Fatal error: Allowed memory size of (...) bytes exhausted (tried to allocate (...) bytes)
* Warning: main() [function.main]: URL file-access is disabled ...
* Deprecated: Function eregi() is deprecated in ...
* Deprecated: Function split() is deprecated in ...
* Fatal error: Maximum execution time of ## seconds exceeded
* Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.


----------------------
As we have many variations regarding this let's write a nice tutorial.
error:
Warning: date() expects parameter 2 to be long, string given in /home/****/public_html/***/cutenews/inc/main.mdu on line 140

now note that this error says main.mdu on line 140. Yours may say something different at the end. No worry, keep reading.
Now we open the file given by the warning: main.mdu

How? With your favorite editor. I suggest using Notepad if you're a windows user.
Now that we have opened the file we'll go to line 140.
How?Notepad and some other editors can easily find a certain line with ctrl + g, now all you got to do is type in the desired line.

result:

$last_login_year = date("Y", $member_db[9]);

The line will always have

date(

in it.

1) Now find the , and add (int) after it.

Now we know where the problem is caused. So we can fix it.
this doesn't work for everyone but it is the best fix.
put this before the variable that causes problems.

(int)

in this case we would get

$last_login_year = date("Y", (int)$member_db[9]);

2) if that didn't work, make a empty line above line given by your warning. (DON'T delete the code above this line if there is code there)
Now put this on that empty line and keep in mind that you need to replace the variable in this example with the variable that gives you trouble.

if( !is_numeric( $member_db[9] ) ) $member_db[9] = time();

3) save changes and upload your edited file in the inc folder.

Credits go to Eyece and Damoor.

2 (edited by 2008-07-25 16:01:38)

Re: Common php Warnings and Errors

error:
Warning: Division by zero in /webroot/x/a/xavie001/www/xaviercontent/inc/functions.inc.php on line 469
remark:This problem has been fixed in CN 1.4.6 so updating CN is adviced.

Like the warning says the problem occurs in functions.inc.php. So let's open this file

How? With your favorite editor. I suggest using Notepad if you're a windows user.
Now that we have opened the file we'll go to line 469.
How? Notepad and some other editors can easily find a certain line with ctrl + g, now all you got to do is type in the desired line.

result:

if($i%$break_location == 0 and $break_location)


This may be different as this line is not the same for all CN versions.
The fix is the same though.

This fix was suggested by FI-DD

FI_DD wrote:

The better way is to change line 469 to this:

if($break_location and $i%$break_location == 0)

That way the original purpose of this line is still intact.


Now save the changes and upload your edited file.

If it didn't work try changing line 469 to this

if($break_location)

When experience this problem it's very likely you'll have problems with the smilies of the comments form. Therefore i refer you to the next post.

3 (edited by 2009-12-22 17:50:46)

Re: Common php Warnings and Errors

this problem commonly occurs with the division by zero thing. So I posted it here, too.
error: the smiley's are aligned vertically.

The most likely cause to this problem: the fix for the division by zero problem probably messes this up.
So be sure to try FI-DD's fix for that problem first.

before attempting to FIX this, be sure it's not a HTML problem. Like putting the {smilies} tag (comment form) in a to small place.

Now the fix for this problem.
open shows.inc.php
How? With your favorite editor. I suggest using Notepad if you're a windows user.

and find

insertSmilies('short', FALSE);

and replace FALSE with the number of smilies you want on 1 horizontal line.
This fix is also the way to go to put smilies on more then 1 line.
as stated in a FAQ topic in the FAQ section of the forum (url posting is disabled at the moment)

4 (edited by 2009-08-09 18:27:25)

Re: Common php Warnings and Errors

error:
Error 500
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@domain.tld and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

reason 1
the most common reason you see this is due to the fact that your Cutenews index.php has been chmodded to 777, while you shouldn't change it's value. Keep at 644

reason 2
not common but for some reason you have a .htaccess file in your CN root folder. (be aware with most ftp clients you need to enable "show hidden files" to see this file listed)
It's not supposed to be there so delete it.

reason 3
only 1 case seen up to now, but it seems that if you have to much text in your article when adding news you can see this error too!
This is due too a server setting

post_max_size

. Though keep in mind that your host has probably a good reason to have this certain value set.

reason 4

WebGremlin wrote:

I had the "500 internal server error" error pop up whenever I tried to save the changes I made to my template. Turns out my host runs the apache module "mod_security", which prevents me from saving my template. The way to bypass this is by adding the following in the .htaccess file in the cutenews root:

SecFilterEngine Off
SecFilterScanPOST Off

In addition, cn does not have a .htaccess file in the root, so make one yourself by saving an empty txt file as .htaccess

reason 5
Well we could add resaon 5,6,7,8 etc.. But the 500 internal server error is the most general error you can get. It shows when it can't be categroized in any other error. If you search google for '500 internal server error' you'll find lots more possible reasons. For example, the error says

Please contact the server administrator

, which would be the wisest to do. Your host has logs and knows their server better then we do. (We shouldn't know anything at all about it unless the slim chance a support members used that host). Your hsot can use those logs to track the problem down. It may be a problem with CN for wich we need to fix it, but then it's still because of a serer setting that's not generally used.

5 (edited by 2010-03-28 08:44:00)

Re: Common php Warnings and Errors

error:
Warning: fopen(./data/users.db.php) [function.fopen]: failed to open stream: Permission denied in /hsphere/local/home/[...]/[...]/cutenews/index.php on line 162
Warning: fwrite(): supplied argument is not a valid stream resource in /hsphere/local/home/[...]/[...]/cutenews/index.php on line 166

Only people with ftp access can fix this.
This error says that a/some file(s) in the data folder are not writable anymore. In other words It's no longer CHMOD'ed to 777.
A reason why this migth happen is that your server has recovered with a backup and gave all recovered files the defauls chmod setting.
Another reason might be that they no longer support 777, but only up to 755 (as explained in this FAQ)

Also, make sure that the file the error refers to exists. AKA the same caps.

Edit by (lKj) [Aug 16 2008]: If you are on a windows server, the CHMOD command will not be understood. Look for a feature called 'permissions' or so in your administration panel or ask for your host to solve this issue.

6 (edited by 2009-05-24 11:00:16)

Re: Common php Warnings and Errors

error:
Warning: preg_replace() [function.preg-replace]: Compilation failed: unmatched parentheses at offset 2 in /home/supah1/domains/just4tuning.nl/public_html/cms/inc/functions.inc.php on line 715

The line number might be a bit off due to some hacks or so.
Anyhow the line this error point to is

$sourse  = preg_replace($find,$replace,$sourse);


in functions.inc.php

Reason:
Please use neither parentheses ("(" and ")") nor square brackets ("[" and "]") as smiley names. They are not escaped properly in CuteNews and will result in a PHP error.
Failing this, please consult this topic.

7 (edited by 2009-04-29 12:48:40)

Re: Common php Warnings and Errors

Error: Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 163049 bytes) in /home/******/public_html/cutenews/inc/functions.inc.php on line 430

It means that your host has a limit on the resource you may use on the server. This to prevent you overloed the server. Be glad it's this error; In worst case your host has a max filesize restriction in effect and when exceeding that limit then, your txt file is emptied. In other words comments or/and news are deleted.

reason 1 This is due to excessive spam. in that case you'll see this message on your site and on your editnews page.
get spam protection (see spam protection topic), upload an empty comments.txt on your server and see the topic about comments in my signature so visitors may comment on older posts again as well.

reason 2 You have massive amounts of news and never made archives. In the best case scenario you'll see te error on your site and on your editnews page.
In the worst case it shows after adding a new article. Then you got a problem as all your news will be lost except for your latest article.
Now for the first scenario the only way to fix this is to make a manual archive. Meaning, not all news in 1 archive, but divide the news in at least 2 archives.

8 (edited by 2008-09-30 17:47:15)

Re: Common php Warnings and Errors

error: Warning: main() [function.main]: URL file-access is disabled in the server configuration in /home/****/mydomain.com/index.php on line 170
Warning: main(http://****) [function.main]: failed to open stream: no suitable wrapper could be found in /home/.mardi/mydomain.com/index.php on line 170

solution: do as the readme.html says. And use a relative path instead of an absolute path.
In other words: DON'T put http://www.domain.com/ in your include.

9 (edited by 2010-06-17 08:41:10)

Re: Common php Warnings and Errors

Error: Deprecated: Function eregi() is deprecated in xxx\news\inc\functions.inc.php on line 289
and/or
Deprecated: Function split() is deprecated in xxx\news\inc\main.mdu on line 139

reason:your host has upgraded it's php version or has very sensitive error reporting.
First thing you have to know, everything still works as it should. These messages are NOT errors, just notices.

solution:
This is a list of what you can do, ergo don't do them all, just 1 of them.
<ol type='1'> * use UTF-8 CN instead. These things have been fixed.
* look at the error messages. At the end you see a file name and a line number. Go to those lines in the named file and replace accordingly.
eregi -> preg_match
next you'll probably saw something like this. you'll also need to add /

eregi("^[_a-zA-Z0-9-]{1,}$", $template)
--->
preg_match("/^[_a-zA-Z0-9-]{1,}$/", $template)


split -> explode
</ol>

10 (edited by 2011-03-16 15:11:17)

Re: Common php Warnings and Errors

Error: Fatal error: Maximum execution time of 30 seconds exceeded in /home/**linux*/u/********.co.uk/user/htdocs/cutenews/inc/functions.inc.php on line 111

Reason: In other words, Cutenews needs more time to load news than you're allowed to (server restrictions). The server setting says you have to complete loading the page within 30 seconds. If not, the server will halt. This is done to protect the server against heavy loads.
The reason as to why it might take so long to load a page could be due to a very big news.txt. In that case, make sure to make regular backups. As this error could cause you to LOSE all existing news when editing an article. Another reason could be excessive spam.

Solution:
IF your news.txt is very big, archiving could be a solution.
If you receive masses of spam, get spam protection The FAQ contains a list of different spam protection hacks.

Re: Common php Warnings and Errors

Error: Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.

Reason: This kind of WARNING should never ever be shown by hosts.
I blame a bad server configuration.

Solution: report the warning to your host or follow below steps
Open shows_news.php index.php and show_archives.php
and add below <?php

date_default_timezone_set('America/Belem');

The bold part is your timezone identifier.
A full list of identifiers can bze found at http://www.php.net/manual/en/timezones.php however, not all will necessairly work on your host.

Posts: 11

Pages 1

You must login or register to post a reply

CutePHP Forums → Problem Solving / Help & Support → Common php Warnings and Errors



The pun_antispam official extension is installed. Copyright © 2003–2009 PunBB.