Page 1 of 1

Call to a member function on a non-object ???

Posted: Mon Nov 27, 2006 7:36 pm
by visonardo
this is the error: Fatal error: Call to a member function on a non-object in /home2/leonardo/public_html/wp7/proyecto2.php on line 49


this is part of my php file

Code: Select all

function url_raa($relative,$donde=false)
{
	global $url_gral,$mirando;
	$absolute=$url_gral;
	//echo 'R: '.$relative.'<br>';
	if(!preg_match("#^(((http|ftp)(s)?://)|mailto:)#i",$relative))
	{
		/*if(strtolower($mirando[1])=='href')
			echo 'ENTRA!<br><b>'.$relative.'</b><p>';*/
		global $url_gral;
		$absolute=$url_gral;
		$b=explode('/',$absolute);
		$h=explode('/',$relative);
		if($b[($c=count($b)-1)]!='' && strlen($b[$c])>strlen(strrchr($b[$c],'.')) && strpos($b[$c],'.')!=false && 3<count($b)) 
			$absolute=substr($absolute,0,(strlen($absolute)-strlen($b[$c])));
		//echo '<b>absolute: '.$absolute.'</b><p>';
		global $barra;
		$barra=false;
		//echo '$c='.$c.' -------------------------------------';
		if($h[($c=count($h)-1)]=='')
			$barra=true;
		/*{
			echo '<font size=8><b>BARRONNNNNNN</b></font>';
			$barra=true;
		}*/
		unset($c);
		extract(parse_url($absolute));
		if($relative{0} == '/')
		{
			$cparts = array_filter(explode("/", $relative));
		}
		else
		{
			$aparts = array_filter(explode("/", $path));
			$rparts = array_filter(explode("/", $relative));
			$cparts = array_merge($aparts, $rparts);
			foreach($cparts as $i => $part)
			{
				if($part == '.')
				{
					$cparts[$i] = null;
				}
				if($part == '..')
				{
					$cparts[$i - 1] = null;
					$cparts[$i] = null;
				}
			}
			$cparts = array_filter($cparts);
		}
		$path = implode("/", $cparts);
		$url = "";
		if($scheme)
		{
			$url = "$scheme://";
		}
		if($user)
		{
			$url .= "$user";
			if($pass)
			{
				$url .= ":$pass";
			}
			$url .= "@";
		}
		if($host)
		{
			$url .= "$host/";
		}
		$url.= $path;
		$url.=(($barra && $url{strlen($url)-1}!='/')?'/':'');
	}
	else
		$url=$relative;
	global $urlp,$mirando,$pasar,$link,$upserv,$url_gral;
	if($urlp==0)
		foreach($upserv as $gi => $avery)
		{
			if(strpos($url,$gi)!==false)
			{	
				global $madr;
				$madr=1;
			}
		}
	if($madr!==1 && $urlp==0)
		$pasar=url_guarda($url);
	else
		$pasar=$url;
	$madr=0;
	if($donde===false)
	{
		$dato=array();
		$dato[]=$pasar;
		$dato[]=$url;
	}
	else
	{
		$dato='';
		$dato=$pasar;
	}
	return $dato;
}

#49 line is that appear saved before that

Code: Select all

$absolute=substr($absolute,0,(strlen($absolute)-strlen($b[$c])));
would be:

Code: Select all

//echo '<b>absolute: '.$absolute.'</b><p>';

any one know why appear that?

Posted: Mon Nov 27, 2006 8:34 pm
by volka
Very unlikely.
please try

Code: Select all

function url_raa($relative,$donde=false)
{
	global $url_gral,$mirando;
	echo "<div>Debug: ", __FILE__, ':', __LINE, "</div>\n"; flush();

	$absolute=$url_gral;
	//echo 'R: '.$relative.'<br>';

Posted: Mon Nov 27, 2006 11:58 pm
by visonardo
thank you, the problem has been fixed :D