In 2018 I had a little game I programmed for my workplace. Now I wants to do it again. I took the backup file and just installed in on a new website. I’ve corrected many things but this one I can’t figure out. Shortly, it is a game where we bet on the upcoming Euro 2024 in soccer and get point for betting correct. The problem is on the point-giving site.
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$jinput = JFactory::getApplication()->input;
$kampid = $jinput->get('kampid');
$res = $jinput->getString('res');
$bet = $jinput->getString('bet');
$resultat = array(
$db->quoteName('res') . ' = ' . $db->quote($res),
$db->quoteName('res1x2') . ' = ' . $db->quote($bet));
$kampensid = array(
$db->quoteName('id') . ' = ' . $kampid); */
$query->update($db->quoteName('em24_kampe'))->set($resultat)->where($kampensid);
$db->setQuery($query);
$db->execute();
// #### GIV POINT
$query2 = $db->getQuery(true);
$query2 = "UPDATE em_tabel t JOIN em_kuponer k ON t.uid = k.uid SET point = (
CASE
WHEN k.resu = '$res' AND k.bet = '$bet' THEN point + 5
WHEN k.resu = '$res' AND k.bet <> '$bet' THEN point + 3
WHEN k.bet = '$bet' AND k.resu <> '$res' THEN point + 1
ELSE point END)
WHERE t.uid = k.uid AND k.id = '$kampid' AND t.liga = k.liga";
$db->setQuery($query2);
$db->execute();
// ####
$query3 = $db->getQuery(true);
$query3 = "UPDATE em_tabel SET kampe = kampe + 1";
$db->setQuery($query3);
$db->execute();
header('location:/index.php?option=com_content&view=article&id=137');
?>
This is the entire code. So there’s 3 queries to do:
- Update the match-sheed with the result.
- Give points to the players.
- Update the table.
The $kampid
is the ID of the match, which is received from the input before this code. As is the $res
and $bet
(game-score and 1X2).
But when executing, it says ERROR 1064 and something about syntax error near ” on line 4. I’m not that good at coding and I don’t care if it could be hacked and so on, as it is only on my little workplace we use it, but I so frustrated because everything worked when I backed it up in 2018. Can someone please see the problem?
I’ve been trying my best to fix this but can’t seem to find the problem.