query gives 1064 error in Joomla 3.4

Resolve a SQL syntax error after upgrading Joomla and ChronoConnectivity.

Overview

The error occurs because the code uses an outdated reference assignment in PHP that triggers a strict standards warning, which gets inserted into the SQL query.
Remove the ampersand from the database object assignment to comply with updated PHP standards in Joomla 3.4.

Answered
hp hpeterse 25 Sep, 2015
I have an Chrono Connection containing the following Where SQL-statement:

wedstrijd_jaar = <?php
global $jaar;
$db =& JFactory::getDBO();
$query = "SELECT `lopend_jaar` FROM `gpdtest_chronoforms_data_wedstrijdjaar` WHERE 1";
$db->setQuery($query);
$jaar = $db->loadResult();
echo $jaar?>

In Joomla 2.5 / ChronoConnectivity 4.0RC3.2 this query works fine. After upgrading to Joomla 3.4/ ChronoConnectivity 4.01 however this query gives an error:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
Strict Standards: Only variables should be assigned by reference ' at line 1 SQL=SELECT count(*) AS `Total` FROM `jos_chronoforms_data_wedstrijdinschrijvingen` WHERE wedstrijd_jaar =
Strict Standards: Only variables should be assigned by reference in /home/deb57186/domains/tvgpd.nl/public_html/test/components/com_chronoconnectivity/libraries/chronoconnection.php(1347) : eval()'d code on line 3
2015

I can't figure out what's wrong.
Gr GreyHead 25 Sep, 2015
Answer
1 Likes
Hi hpeterse,

It looks to me as if the query is wrong did you miss copying some of it? The error message refers to count(*) but that isn't in the code.

Joomla! 3 shows an PHP Warning if you use $db =& JFactory - just drop the & and use $db = JFactory

Bob
hp hpeterse 25 Sep, 2015
Bob,

This solves the problem. Thanks for helping!

Hans
This topic is locked and no more replies can be posted.