For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2007 > mysql_real_escape_string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mysql_real_escape_string
Ron Piggott

2007-04-27, 9:57 pm


The following PHP command

$new_maintainers_notes =
mysql_real_escape_string($new_maintainer
s_notes);

returned this error while running in a ***cron***.

Warning: mysql_real_escape_string(): Access denied for user:
'actsmin@localhost' (Using password: NO)
in /home2/actsmin/actsministries-www/memberservices/administration/ ministry_directory_annual_review_mainten
ance.php on line 39

Warning: mysql_real_escape_string(): A link to the server could not be
established
in /home2/actsmin/actsministries-www/memberservices/administration/ ministry_directory_annual_review_mainten
ance.php on line 39

where

$new_maintainers_notes = "Listing has been set for it's annual review";



But when I return it from the web --- ie http://www........... no
error.

Any idea why the cron is upset?

Ron

David Robley

2007-04-28, 3:58 am

Ron Piggott wrote:

>
> The following PHP command
>
> $new_maintainers_notes =
> mysql_real_escape_string($new_maintainer
s_notes);
>
> returned this error while running in a ***cron***.
>
> Warning: mysql_real_escape_string(): Access denied for user:
> 'actsmin@localhost' (Using password: NO)
> in
> /home2/actsmin/actsministries-www/memberservices/administration/ ministry_directory_annual_review_mainten
ance.php
> on line 39
>
> Warning: mysql_real_escape_string(): A link to the server could not be
> established
> in
> /home2/actsmin/actsministries-www/memberservices/administration/ ministry_directory_annual_review_mainten
ance.php
> on line 39
>
> where
>
> $new_maintainers_notes = "Listing has been set for it's annual review";
>
>
>
> But when I return it from the web --- ie http://www........... no
> error.
>
> Any idea why the cron is upset?
>
> Ron


mysql_real_escape_string needs to have an open connection to the db to work.
From the docs - http://www.php.net/mysql_escape_string :

"link_identifier

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 by chance no connection is found or established, an E_WARNING level
warning is generated."

and

"Note: A MySQL connection is required before using
mysql_real_escape_string() otherwise an error of level E_WARNING is
generated, and FALSE is returned. If link_identifier isn't defined, the
last MySQL connection is used."



Cheers
--
David Robley

Some days, nothing goes left.
Today is Pungenday, the 45th day of Discord in the YOLD 3173.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com