Page 1 of 1

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

Posted: Wed Aug 24, 2011 2:53 am
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 >>> }  
} 

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

Posted: Wed Aug 24, 2011 6:14 am
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

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

Posted: Wed Aug 24, 2011 6:21 am
by simonmlewis
meaning it is lookking for a page that doesn't existing within that Include section?

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

Posted: Wed Aug 24, 2011 6:33 am
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

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

Posted: Wed Aug 24, 2011 6:36 am
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???

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

Posted: Wed Aug 24, 2011 6:56 am
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

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

Posted: Wed Aug 24, 2011 7:00 am
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

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

Posted: Wed Aug 24, 2011 7:06 am
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.

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

Posted: Wed Aug 24, 2011 7:21 am
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

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

Posted: Wed Aug 24, 2011 7:42 am
by simonmlewis
Funnily enough, that is how it use to be!!!
I changed it to the other way on a recommendation from someone here.

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

Posted: Wed Aug 24, 2011 7:54 am
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