I’m getting the following error on my site when I upload it or submit a page:
mysql_real_escape_string() [function.mysql-real-escape-string]: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
What in the world does this mean?
Since the error is being thrown by the call to
mysql_real_escape_string()it rather implies that you didn’t callmysql_connect()first and pass a valid db handle tomysql_real_escape_string(or the call tomysql_connect()failed).In some circumstances, the mysql extension will attempt to connect automatically using the default settings in php.ini, failing over to my.cnf if these are not available – which obviously are not valid. Or it may be that the settings are valid but the mysqld is not running.
Have you got scripts which are connecting to the database successfully?
Do you have a username and password for the database?
Try: