0

I had someone build out a custom CMS for a small site and now I can't get a hold of the developer. I get this error when trying to view my site:

You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near 'order by sortorder' at line 1:

select path, title
from pages
where parent_id =
order by sortorder

After some help I was able to I think pin point where the problem is:

public function getChildLinks()
{
    $list = array();
    $WHERE_path = substr($_SERVER['REQUEST_URI'], 1);
    $WHERE_path = strlen($WHERE_path) ? '= "'.$WHERE_path.'"' : 'IS NULL';
    $parentPageRowset = Axl_Db::query('SELECT id, parent_id FROM '.$this->_name.' WHERE path '.$WHERE_path);
    $parent_id = $parentPageRowset[0]['parent_id'] ? $parentPageRowset[0]['parent_id'] : $parentPageRowset[0]['id'];
    $listRowset =  new Axl_Db_Rowset('SELECT path, title FROM '.$this->_name.' WHERE parent_id = '.$parent_id.' ORDER BY sortorder');
    while($listRowset->next())
    {
        $list['/'.$listRowset->path] = $listRowset->title;     
    }
    return $list;
}

This is the function causing the problem.

3 Answers 3

2

The issue is with your WHERE clause; it has parent_id = but nothing following. You need to provide a value into the query.

7
  • thank you for your response. Now where would I look in order to make this correction with the structure you see above?
    – TikaL13
    Nov 15, 2011 at 15:57
  • I do not know what file this is in. If it were me, I would search/grep the source code for this query (maybe just 'order by sortorder') to find the file that calls it. This gives you a place to start looking to add the parameter. Nov 15, 2011 at 16:06
  • @Adam... again thanks for your response. I am going to go through all the files and see if I can find something that resembles that query. I'm not too familiar with grep. Or anything command line so I don't think that would be the best option for me. unless you can point me somewhere I can read how to do this. Thanks again!
    – TikaL13
    Nov 15, 2011 at 19:26
  • 1
    I use agent ransack mythicsoft.com/page.aspx?type=agentransack&page=home but there are many free tools for this if you do not like this one. Nov 15, 2011 at 19:42
  • Just installed and yes this is a nice application. I see that there are 8 files that have the text 'sortorder' but don't really see where it may be missing. Hmmmm
    – TikaL13
    Nov 15, 2011 at 22:40
0

More than likely the CMS needs a GET var in the url in order for the mysql statement to work.

0

Well after getting great feed back from Adam I was able to really pin point what file I needed to fix and or look into a little deeper.

It turns out that I needed to quote out the parent_id variable

like so:

$listRowset =  new Axl_Db_Rowset('select path, title from '.$this->_name.' where parent_id = "'.$parent_id.'" order by sortorder');

Thanks Adam for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.