PDA

View Full Version : Access denied when executing a SQL query from a plugin


funyoo
06-22-2016, 08:34 PM
Hi,

I get this message when I enable the following plugin :

$query="SELECT username FROM user WHERE userid = 1";
$result = mysql_query($query) or die(mysql_error());

Access denied for user 'www-data'@'localhost' (using password: NO)

What could be the reason ? everything is working otherwise, the board, as the SQL queries from Maintenance > Execute SQL Query.

ForceHSS
06-22-2016, 10:33 PM
Your password is wrong check your config.php in your includes folder
$config['MasterServer']['password'] =

squidsk
06-23-2016, 10:34 AM
That's also not how you execute queries within vbulletin. You need to go through the db object to make the query. Take a look at any vbulletin page and see how it's done.

Paul M
06-23-2016, 12:06 PM
Its failing because you are using completely the wrong method to access the database.

As posted above, you need to use the $db object within vbulletin, not raw calls to mysql_query().