mysql_logo

Today I was moving some stuff to a live server and Whaamm my code was giving me the following error:

Access denied for user: 'apache@localhost' (Using password: NO)

I debugged it to be the line containing mysql_real_escape_string. But why did it work on the dev server and not the live? My memory immediately kicked in and remembered having similar problems. The code on live was not using persistent connections (not an issue) and the call to mysql_real_escape_string requires a connection to mysql to be open at the time of call. Since the line of code came before any connection to the database was being made, it caused this error.

Make sure you have a connection to mysql open before calling this method!

1 thought on “Mysql_real_escape_string”

  1. Hello, I need some help with it. When I try to go to magento front page it pops up this: Warning: siemlpxml_load_string(): Entity: line 2: parser error : Comment not terminated. Nothing is shown in system.log about this as well. I don’t know where to put Mage::log(print_r($filename, true)); to help me find this error.Help please.

Leave a Comment

Your email address will not be published. Required fields are marked *