Resolved: Custom module error message after joomla searh Topic is solved

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
hookah
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu May 20, 2021 6:57 am

Resolved: Custom module error message after joomla searh

Post by hookah » Thu May 20, 2021 7:25 am

I was some hours to resolve this problem. I missing the quotes in '$id'. Its working, but some next db query isnt wokring. Sorry for questions.
The correct query is
$db->setQuery("SELECT #__categories.title FROM #__content, #__categories WHERE #__content.catid = #__categories.id AND #__content.id = '$id'");



I was made module for custom breadcrumbs.
Joomla! 3.9.26 Stable

This code is display good and working,

$db->setQuery("SELECT #__categories.title FROM #__content, #__categories WHERE #__content.catid = #__categories.id AND #__content.id = $id");

I have a joomla standard search in the same page. After write some random search string "ten years" or anything else and press enter - joomla give me error page with error bellow. If remove this query and search is working normal. I don't understand where is the error!?

the error message is
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 '' at line 1

I have another query and its working with search without problem.
$db->setQuery("SELECT cat.title FROM #__categories cat WHERE cat.id='$id'");

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 '' at line 1


This is all code
<?php

class ModVolumeMagazineHelper
{
public static function getVolumeMagazine($params)
{

$htmlCode = '<div class="custom_magazine_volume"><div class="container">';

//initiate db connection
$db = JFactory::getDbo();
//get current category id
$id = JRequest::getString('id');
$view = JRequest::getString('view');

$db->setQuery("SELECT #__categories.title FROM #__content, #__categories WHERE #__content.catid = #__categories.id AND #__content.id = $id");

$category_title = $db->loadResult();
//echo "$id";
//echo "$view";
$htmlCode .= "$category_title";

.....

Locked

Return to “Joomla! 3.x Coding”