Jump to content

Wordpress can access my database, but my queries can't


davidtube

Recommended Posts

(I think this is the appropriate section for this question. Sorry if it isn't.)

 

I've moved my Wordpress site to a new domain. The website and database still sit on the same servers so the configuration shouldn't have changed. All the Wordpress features are still running correctly but anywhere I have added my own SQL queries to the template code I get the following error message:

 

"Warning: mysql_query(): Access denied for user 'httpd'@'localhost' (using password: NO) in..."

 

My queries were working fine before I changed domain. For some reason they are no longer able to access the database but the Wordpress code is able to.

 

Does anyone know why the user is amused to be 'httpd'@'localhost' and how to change that to the username and server specified in my wp-config file?

 

MySQL client version: 5.0.67

 

Link to comment
Share on other sites

Your database connection code is not working and since you don't have a valid database connection when the mysql_query() is being executed, it is attempting to create a connection using default values.

 

You would need to troubleshoot why your connection code is either not being executed or is failing to create a connection.

 

You would need to post your code if you want help with what it is or is not doing.

Link to comment
Share on other sites

I've cracked it! It's only taken me 2 weeks. Basically I had recently added a piece of code to the header which was trying to establish a second database connection. I got rid of that and everything is working perfectly. The fact I'd changed domains had nothing to do with it. It just added to the confusion.

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.