crazyfrog Posted December 10, 2010 Share Posted December 10, 2010 We are looking for a solution regarding the "USE" command in Mysql 5. We are running an integration script (Jfusion) between Vbulletin and Joomla. Basically, when trying to update users it sends the following errror. Database error in vBulletin 4.1.0: Invalid SQL: USE web178-training; MySQL Error : 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 '-training' at line 1 I think it is something to do with "USE" and the "-" in my database name, but i cannot change that as my host automatically adds it on creating a new database. Now looking around the internet, there isnt much regarding the USE statement. Mysql isnt my forte, and hopefully someone can help around here. Now i think i have found the line of code that is causing the error. //force into global scope $GLOBALS["vbulletin"] = $vbulletin; $vbulletin->db->query_first("USE" . $this->params->get('database_name')); $GLOBALS["db"] = $vbulletin->db; Looking at this, it seems the command needs to be wrapped in "", but where and how. PS, i tried this with no joy "USE '" . $this->params->get('database_name')."'" Hopefully this has been adressed by someone around here, only it wont accpt the search string here, as obviously it is a popular word and too short (use) This is quite urgent, as its a live site and my upgrade has gone t**s up. Regards Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 10, 2010 Share Posted December 10, 2010 Any identifier (database, table, column name) that contains special characters must be enclosed in back-ticks `` in a query. Quote Link to comment Share on other sites More sharing options...
crazyfrog Posted December 10, 2010 Author Share Posted December 10, 2010 Any identifier (database, table, column name) that contains special characters must be enclosed in back-ticks `` in a query. Could you provide an example of what would possibly work on the following line? PLEASE. $vbulletin->db->query_first("USE " . $this->params->get('database_name')); Thankyou for your swift response. Quote Link to comment Share on other sites More sharing options...
crazyfrog Posted December 10, 2010 Author Share Posted December 10, 2010 I think i got it. Thankyou! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.