What's problem of the database query code in this post?

Discussion in 'Joomla' started by wiseboke, Jul 6, 2011.

  1. #1
    This is part of the code
    $loc=JRoute::_($loc);
                $arr=array();
    			$arr=split("&",$loc);
    			$myurl=$arr[0]."&".$arr[3]."&".$arr[2]."&".$arr[4]."&".$arr[1];
    			//here we begin sef url,we need to get url structure like this index.php?option=com_content&catid=10&id=109&lang=en&view=article first
    			$epdb     =& JFactory::getDBO();
    		$epquery="SELECT oldurl FROM rev_redirection WHERE newurl ='".$myurl."'";
    //$epquery="SELECT oldurl FROM rev_redirection WHERE newurl ='index.php?option=com_content&catid=9&id=111&lang=en&view=article' LIMIT 10";
    		$epdb->setQuery($epquery);
    		$epresult=$epdb->loadResult();
    		$eperror=$epdb->getErrorMsg($epresult);
    		$newloc="Result:".$epresult."Error:".$eperror."Url:".$myurl."Query:".$epquery;
    PHP:
    here is one of the results
    Result:Error:Url:index.php?option=com_content&catid=14&id=171&lang=en&view=articleQuery:SELECT oldurl FROM rev_redirection WHERE newurl ='index.php?option=com_content&catid=14&id=171&lang=en&view=article'
    PHP:
    and when I query this
    SELECT oldurl FROM rev_redirection WHERE newurl ='index.php?option=com_content&catid=14&id=171&lang=en&view=article'
    PHP:
    in mysql,it runs successful,returns the result I want,but here in this code,when I can't get the result?thanks in advance
     
    wiseboke, Jul 6, 2011 IP