Forum Moderators: open

Message Too Old, No Replies

SQL syntax error, anyone please?

SQL error in syntax

         

cindywaters

7:51 pm on May 5, 2009 (gmt 0)

10+ Year Member



Hey guys

I'm getting this error (in a joomla search component - advanced search). It did work fine when i first made the website but all of a sudden it has stopped working and I get this nasty message:

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 \')\' at line 1 SQL=SELECT count(u.id) FROM jos_users u, jos_comprofiler ue WHERE u.id=ue.id AND u.block !=1 AND ue.approved=1 AND ue.banned=0 AND ue.confirmed=1 AND u.gid IN ()

Can anyone suggest what to do?

Thank you soooo much in advance

coopster

8:12 pm on May 5, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, cindywaters.

It looks like it is choking on your IN() list. There is nothing in your IN() list, it is empty.

cindywaters

1:33 am on May 6, 2009 (gmt 0)

10+ Year Member



Hi, thanks so much for the reply and thank you for your welcome.

I'll be honest, I don't really understand what this means. Do you need some more information?

this is the corresponding code:

$database->setQuery("SELECT count(u.id) FROM #__users u, #__comprofiler ue WHERE u.id=ue.id AND u.block !=1 AND ue.approved=1 AND ue.banned=0 AND ue.confirmed=1 AND u.gid IN (".$usergids.")");
$total_results = $database->loadResult();

Thanks

cindywaters

2:55 pm on May 6, 2009 (gmt 0)

10+ Year Member



Hi, I have fixed this problem. I will describe what happened just incase someone else gets a similar problem.

I think its to do with an upgrade from php4 to php5.

In cb_search.html.php around line 350, it says:

$allusergids = array_merge($allusergids,$groupchildren);

php4 is ok with this but php5 NEEDS to have the (array) keyword forced in. Therefore:

$allusergids = array_merge((array)$allusergids,(array)$groupchildren);

Thanks for the help