Index of /andrejciho/WordPress/Patch for Pods CMS 1.8.1 – mysql_real_escape_string

Post Title Posted Description
Back Parent Directory
Patch for Pods CMS 1.8.1 – mysql_real_escape_string 2010-01-18 11:41

A patch to Pods CMS 1.8.1 to add a link_identifier as a second parameter to mysql_real_escape_string to avoid "access denied" errors


Be Sociable, Share!

At Wordcamp Atlanta I learned about Pods CMS – a powerful WordPress plugin allowing you to build your content types, giving you an admin to add/edit/delete (kinda like RoR’s scaffolding) and an easy way to pull it out of database in your template. Very powerful plugin. Needless to say another world of possibilities opened up for me.

After spending some time on setting things up on my local box I uploaded it to a staging environment on our server and noticed a “mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user: ‘nobody@localhost’” error.

If you look up mysql-real-escape-string in the php manual you’ll notice that the second and optional parameter is link_identifier (the db resource). The manual describes it as:

The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If no connection is found or established, an E_WARNING level error is generated.

There might be another solution to the problem, for example changing a setting on the server, but if you don’t know how to change it or don’t have permissions to do so, you can modify code of Pods CMS so that anytime it calls mysql_real_escape_string it passes the link_identifier. Here is a patch I created.


Leave a Comment
*Required
*Required (Never published)
 

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

This website is powered by Wordpress