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
https://forums.phpfreaks.com/topic/221239-mysql-5-use-command/
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
https://forums.phpfreaks.com/topic/221239-mysql-5-use-command/#findComment-1145491
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.