Jump to content

Mysql 5 USE command


crazyfrog

Recommended Posts

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.