Page 1 of 2

How do we stop error log "file does not exist"?

Posted: Sun Mar 17, 2013 9:34 am
by simonmlewis
[text][Sun Mar 17 10:50:45 2013] [error] [client 86.31.23.37] File does not exist: /home/site/public_html/apple-touch-icon.png[/text]

We are getting tens of thousands of things on our error logs.
If someone goes to www.sitename.com/apple-touch-icon.png, it redirects them to our homepage anyway, so why are we getting this?

Anyone know?

Re: How do we stop error log "file does not exist"?

Posted: Sun Mar 17, 2013 1:45 pm
by twinedev
Do you have anything in your pages that reference that file? If not, perhaps Apple devices automatically check for it like many browsers automatically try to load favicon.ico

Either place an image on the server, or adjust the server to give a different 404 responce.

worse case, you can create a blank file... and if you have SSH access, to make it really funny use this command:

Code: Select all

touch /home/site/public_html/apple-touch-icon.png
(touch is a command that will update the timestamp on the file, and if it doesn't exist, will create an empty file)

-Greg

Re: How do we stop error log "file does not exist"?

Posted: Sun Mar 17, 2013 1:50 pm
by simonmlewis
Thank you. The first part of your answer, was the answer.
I read more and it seems Apple devices try to find that file to place on the screen. I wish I'd known, as this site has been like this for years!!!
We have over 30,000 lines in an error log abotu it. Could be even over 100,000 lines.

So hoping this will reduce that somewhat!

Re: How do we stop error log "file does not exist"?

Posted: Sun Mar 17, 2013 3:08 pm
by twinedev
Yeah, it is getting crazy with all the icons needed now....

Here is good info on it:
http://www.kylejlarson.com/blog/2012/ad ... r-website/

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 8:13 am
by simonmlewis
Here is another error I don't understand:

[text][18-Mar-2013 12:17:39] PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/site/public_html/includes/product.inc on line 1265[/text]

The code is this:

Code: Select all

$resultrccheck = mysql_query ("SELECT rcstock, photoprimary, price, title FROM products WHERE romancode = '$romancodetick' AND rcstock = 'in stock'");
            $num_rcstock = mysql_num_rows($resultrccheck); 
Now, if there are no results, there are no result. So why is it erroring ont he second line:

Code: Select all

$num_rcstock = mysql_num_rows($resultrccheck); 

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 10:59 am
by Christopher
mysql_query() returns a resourse on success and FALSE on error. And FALSE is not a valid resource ID. You should always check for errors after a query.

Code: Select all

$resultrccheck = mysql_query ("SELECT rcstock, photoprimary, price, title FROM products WHERE romancode = '$romancodetick' AND rcstock = 'in stock'");
if (($resultrccheck !== false) && !mysql_errno($resultrccheck)) {
    $num_rcstock = mysql_num_rows($resultrccheck);
} else {
    // deal with error
}

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 12:20 pm
by simonmlewis
Oh wow I didn't know that.

Also what about this code:

Code: Select all

$menu = $_REQUEST['menu'];
if ($menu != "")
{	getMenu();}
And I get the error:
[text][18-Mar-2013 15:51:41] PHP Fatal error: Call to undefined function getmenu() in /home/site/public_html/index.php on line 631[/text]
It's only called if there is a request for it, and there is a request or the site would be permanently errored on the rendered page.

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 3:10 pm
by simonmlewis
<?php

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);

$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows\n";

?>
This from: http://php.net/manual/en/function.mysql-num-rows.php
Is this incorrect then, or are you simply explaining why this script produces occasional errors?

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 5:18 pm
by Christopher
simonmlewis wrote:Oh wow I didn't know that.

Also what about this code:

Code: Select all

$menu = $_REQUEST['menu'];
if ($menu != "")
{	getMenu();}
And I get the error:
[text][18-Mar-2013 15:51:41] PHP Fatal error: Call to undefined function getmenu() in /home/site/public_html/index.php on line 631[/text]
It's only called if there is a request for it, and there is a request or the site would be permanently errored on the rendered page.
I can't say why getmenu() is not defined. My guess is that it has not been included.

For the code above, I would recommend:

Code: Select all

if (isset($_REQUEST['menu']) && ($_REQUEST['menu'] != "")) {
	$menu = $_REQUEST['menu'];
	getMenu();
}

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 5:21 pm
by simonmlewis

Code: Select all

$menu = $_GET['menu'];
if ($menu != "")
{
function getMenu()
{
$thismenu="includes/menu/".$_GET['menu'].".inc";
if (file_exists($thismenu)) 
  {
   include $thismenu;
  } 
  else 
  {
  echo "<meta http-equiv='Refresh' content='0 ;URL=/error'>";
  }
}}
This is wha tI am using at the moment - incorrect?

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 5:37 pm
by Christopher
Is that code separate from the code that calls getMenu() you posted above?

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 5:40 pm
by simonmlewis
Getmenu calls that script.

Re: How do we stop error log "file does not exist"?

Posted: Mon Mar 18, 2013 9:25 pm
by Christopher
The reason getMenu() is not found is that it is not being included. That should be easy to track down. If the menu file is not being included then it is probably that the relative path is not getting the actual file. Finally, the included code is inside the getMenu() function. How does it get out because getMenu() does not return anything?

Re: How do we stop error log "file does not exist"?

Posted: Sat Mar 23, 2013 5:59 am
by simonmlewis
Do you mean, it's not being requested in the URL, and that is why the script is running, not finding what's being asked of it, thus erroring ??

Re: How do we stop error log "file does not exist"?

Posted: Sat Mar 23, 2013 11:39 am
by McInfo
simonmlewis wrote:[text][Sun Mar 17 10:50:45 2013] [error] [client 86.31.23.37] File does not exist: /home/site/public_html/apple-touch-icon.png[/text]

We are getting tens of thousands of things on our error logs.
If someone goes to http://www.sitename.com/apple-touch-icon.png, it redirects them to our homepage anyway, so why are we getting this?

Anyone know?
You can clean up the error log by running this command:
[text]grep -Ev "File does not exist: [^ ]*/(favicon\.ico|robots\.txt|apple-touch-icon[0-9a-z-]*\.png)(, referer: [^ ]+)?$" error_log > error_log_filtered[/text]
It produces a new file called "error_log_filtered" with errors for commonly-requested files stripped out.

I'm not sure if I agree with the idea of serving an empty icon file.