access denies for function.mysql-real-escape-string

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
antuanjoseff
Forum Members
Forum Members
Posts: 10
Joined: Thu May 04, 2006 3:17 pm

access denies for function.mysql-real-escape-string

Post by antuanjoseff »

hi,

I have defined some user tags to connect to a mysql database and now I have this error: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/cmsmadesimple/lib/adodb_lite/adodbSQL_drivers/mysql/mysql_driver.inc on line 174

and then some accents (from the database) in my pages appear propertly and some don't.

Can anyone help me please?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: access denies for function.mysql-real-escape-string

Post by Ted »

So you're using user tags to make a 2nd connection to the database?  There could be a configuration issue going on her that is only allowing one connection per request (you have two...  one from CMSMS/adodb and one from your tag).  Your best bet it to use the adodb connection instead and not open up the 2nd one.

Code: Select all

global $gCms;
$db =& $gCms->GetDb();
Granted, that is an adodb connection, but it shouldn't be any harder to use than the standard php/mysql functionality.
antuanjoseff
Forum Members
Forum Members
Posts: 10
Joined: Thu May 04, 2006 3:17 pm

Re: access denies for function.mysql-real-escape-string

Post by antuanjoseff »

Hi,
it was a charset problem.
I created a use tag with utf-8 and my database is in latin1. I solved that and the error dissappear.
Sorry and thanks
booger

Re: access denies for function.mysql-real-escape-string

Post by booger »

Although this is an old post, it bears relevance to a problem I have just encountered, and may help someone else out there.

I also connected to another database using a tag linked to an external php script, and likewise I was receiving the access denied message for mysql-real-escape-string after my script had executed.  The error appeared in the cmsms footer.  In my case, it was nothing to do with the utf-8 or any other character set, it was because I had used mysql_close($linkname) at the end of my script.  Although mysql_close should only have closed the named link, it also appeared to close the link to the cmsms database as well (in a different database on a different server).

So one solution to try for this problem (only if you are connecting to a separate DB or server) is to remove mysql_close at the end of the script.
Post Reply

Return to “Tips and Tricks”