Error Log errors... but can't see the fault.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Error Log errors... but can't see the fault.

Post by simonmlewis »

[text][15-Mar-2011 09:21:44] PHP Warning: include(includes/product\'.inc) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/site/public_html/index.php on line 110

[15-Mar-2011 09:21:44] PHP Warning: include(includes/product\'.inc) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/site/public_html/index.php on line 110

[15-Mar-2011 09:21:44] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'includes/product\'.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/site/public_html/index.php on line 110

[15-Mar-2011 09:21:45] PHP Warning: include(includes/product And 1=0--.inc) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/site/public_html/index.php on line 110

[15-Mar-2011 09:21:45] PHP Warning: include(includes/product And 1=0--.inc) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/site/public_html/index.php on line 110

[15-Mar-2011 09:21:45] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening 'includes/product And 1=0--.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/site/public_html/index.php on line 110

[15-Mar-2011 09:21:46] PHP Warning: include(includes/product And 1=1--.inc) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/site/public_html/index.php on line 110[/text]

Code: Select all

<?php session_start(); 
if(isset($_REQUEST['itemtype']))
{
    $itemtype = $_REQUEST['itemtype'];
    $_SESSION['itemtype']=$itemtype;
} else { $itemtype=$_SESSION['itemtype'];
}
if ($itemtype == NULL) { $itemtype = "BB Guns";}
if(isset($_REQUEST['sort']))
{
    $sort = $_REQUEST['sort'];
    $_SESSION['sort']=$sort;
} else { $sort=$_SESSION['sort'];
}

if($sort == NULL) { $sort=title; }
?>
<script>
function precheck(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("srcHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","presearch.php?q="+str,true);
xmlhttp.send();
}
</script>
<script>
function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("search");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Search box not completed");
	// dialog message
	var alertMsg = "OOPS!\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
// -->
</script>

<?php
$page= isset($_GET['page']) ? $_GET['page'] : null;
if (isset($_GET['page']))
{
function getPage()
{
 $thispage="includes/".$_GET['page'].".inc";
 include $thispage;
THIS IS LINE 110 >>> }  
} 
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: Error Log errors... but can't see the fault.

Post by phphelpme »

No such file or directory in /home/site/public_html/index.php on line 110

Its saying your file or directory does not exist on your host, localhost, server etc.

Best wishes
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Error Log errors... but can't see the fault.

Post by simonmlewis »

meaning it is lookking for a page that doesn't existing within that Include section?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: Error Log errors... but can't see the fault.

Post by phphelpme »

Yes, its saying it can not find that file you are calling or the directory which you are stating the file is in.

Best wishes
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Error Log errors... but can't see the fault.

Post by simonmlewis »

Code: Select all

$page= isset($_GET['page']) ? $_GET['page'] : null;
if (isset($_GET['page']))
{
But surely this script should only do the function IF there is something there to find???
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: Error Log errors... but can't see the fault.

Post by phphelpme »

Keep in mind that an empty string is not null, and an empty GET or POST field returns an empty string instead of NULL.

Best wishes
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: Error Log errors... but can't see the fault.

Post by phphelpme »

With that in mind, one probably would use isset() to check if a variable has been declared somehow and it's value is not the special value NULL. If you want to check if the value is an empty string, it's probably a better idea to check it literally:

Code: Select all

<?php
(isset($a) && $a == '') // => TRUE
?>
Best wishes
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Error Log errors... but can't see the fault.

Post by simonmlewis »

Sorry, I don't know what you mean - how do I interpret this:

Code: Select all

$page= isset($_GET['page']) ? $_GET['page'] : null;
if (isset($_GET['page']))
{
function getPage()
{
 $thispage="includes/".$_GET['page'].".inc";
 include $thispage;
}  
} 
into your:

Code: Select all

(isset($a) && $a == '') // => TRUE
As mine has the GET part looking in the URL.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: Error Log errors... but can't see the fault.

Post by phphelpme »

Well how about this simple version:

Code: Select all

<?php

$page = $_GET['page'];
if ($page == "") {  // perform something here
}
else { // perform your function
function getPage()
{
 $thispage = "includes/".$page.".inc";
 include $thispage;
}  
} 

?>
Best wishes
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Error Log errors... but can't see the fault.

Post by simonmlewis »

Funnily enough, that is how it use to be!!!
I changed it to the other way on a recommendation from someone here.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: Error Log errors... but can't see the fault.

Post by phphelpme »

Well, a blank variable string is not classed as NULL so the safest way for you would be your original way.

Just check out the manual and you can see the issues with isset()

http://php.net/manual/en/function.isset.php

Best wishes
Post Reply