davidtube Posted December 10, 2010 Share Posted December 10, 2010 (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 Quote Link to comment https://forums.phpfreaks.com/topic/221243-wordpress-can-access-my-database-but-my-queries-cant/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 10, 2010 Share Posted December 10, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/221243-wordpress-can-access-my-database-but-my-queries-cant/#findComment-1145489 Share on other sites More sharing options...
davidtube Posted December 10, 2010 Author Share Posted December 10, 2010 Thanks. The problem for me is that Wordpress has so many files referencing so many other files, with so many function, it's very hard to track down what does what (especially if you're only an amateur with php like me). Quote Link to comment https://forums.phpfreaks.com/topic/221243-wordpress-can-access-my-database-but-my-queries-cant/#findComment-1145501 Share on other sites More sharing options...
davidtube Posted December 10, 2010 Author Share Posted December 10, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/221243-wordpress-can-access-my-database-but-my-queries-cant/#findComment-1145516 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.