$db->nameQuote is empty

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Post Reply
Piekfijn
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Sep 07, 2016 8:32 pm

$db->nameQuote is empty

Post by Piekfijn » Wed Sep 07, 2016 8:44 pm

Hi,

First of all, my Joomla website is up to date (Joomla and database) and no errors are showing in the control panel.

When trying to add a new user, I get the following error message:
Opslaan mislukt door de volgende fout: 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 'SET id=784, username="sdf", rookie=0' at line 1 SQL=INSERT INTO SET id=784, username="sdf", rookie=0
The user is successfully added to the database, but the error is thrown when trying to add the user to the discussions_user table. The error is clear, there should be a table name between "INTO" and "SET".
Upon looking into discussions.php (in the plugins/system/discussions folder) the following code is used:

Code: Select all

	function onUserAfterSave( $user, $isnew, $success, $msg) {

        if ( $success) {

            if ( $isnew) {

                // add a record to #__discussions_users
                $db = JFactory::getDBO();

                // get Rookie Mode setting from com_discussions parameters
                $params = JComponentHelper::getParams('com_discussions');

                if ( $params->get('rookie', '0') == 0) { // 0 = no rookie mode
                    $rookie	= 0;
                }
                else { // everything else means rookie mode
                    $rookie	= 1;
                }


                $sql = "INSERT INTO " . $db->nameQuote('#__discussions_users') . " SET " .
                        "id=" . $user['id'] . ", " .
                        "username=\"" . $user['username'] . "\", " .
                        "rookie=" . $rookie;


                $db->setQuery( $sql);
                $db->query();

            }
            else { // user is updated

                    // update the user record in #__discussions_users
                    $db = JFactory::getDBO();

                    $sql = "UPDATE " . $db->nameQuote('#__discussions_users') . " SET " .
                            "username=\"" . $user['username'] . "\" " .
                            "WHERE " . $db->nameQuote('id') . " = " . $user['id'];

                    $db->setQuery( $sql);
                    $db->query();

            }

        }
		
	}
$db->nameQuote('#__discussions_users') is returning nothing. I checked the database and everything seems allright.

Any ideas on what is wrong? The problem seems to be occurring in other queries as well, but off course, not all of them...

Thanks in advance.

mbabker
Joomla! Hero
Joomla! Hero
Posts: 2176
Joined: Sun Feb 28, 2010 8:26 pm

Re: $db->nameQuote is empty

Post by mbabker » Wed Sep 07, 2016 8:52 pm

JDatabase::nameQuote() was removed at 3.0. You should be using JDatabaseDriver::quoteName() instead.

https://docs.joomla.org/Potential_backw ... 2#Database
So long and thanks for all the fish.

Manually updating Joomla? See https://gist.github.com/mbabker/d7bfb4e ... 3607f89281

User avatar
toivo
Joomla! Exemplar
Joomla! Exemplar
Posts: 9609
Joined: Thu Feb 15, 2007 5:48 am
Location: Oxford, UK
Contact:

Re: $db->nameQuote is empty

Post by toivo » Wed Sep 07, 2016 9:07 pm

Piekfijn wrote:Any ideas on what is wrong?
The system plugin where the error comes from belongs to a third party extension. You need contact the developer of that extension to get a later version of the extension.
Toivo Talikka, Global Moderator
my first programs were assembled and run in 16KB :)
troubleshooting smtp and other articles https://talikka.com/joomla

Piekfijn
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Sep 07, 2016 8:32 pm

Re: $db->nameQuote is empty

Post by Piekfijn » Thu Sep 08, 2016 6:51 am

Ok, that's good news.
Thanks for the fast responses!

kmchen
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Sat Oct 21, 2006 12:57 am
Location: marseille (13) france
Contact:

Re: $db->nameQuote is empty

Post by kmchen » Mon Jul 16, 2018 6:59 pm

Piekfijn wrote:
Any ideas on what is wrong?
Yes I follow Joomla since 1.0 whitch was a realy good stuff but now what is wrong is the Joomla new team.

Could you tell me what is the interest to rename such a basic function namequote() to quotename() ?! :'( :'( :'(

Forcing 3rd party developpers to review their components for no reason ? Joomla lost and is loosing lot of third party developper discouraged by that un-backward-compatibility attitude. You develop a component and every five minutes you have to debug it for such stupid changes.


Post Reply

Return to “Administration Joomla! 3.x”