On Jan 23, 2008 10:03 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> On 23/01/2008, James Ausmus <[EMAIL PROTECTED]> wrote:
> > Try using the mysql_ping() command to check to see if your connection
> > is available:
> >
> > http://us2.php.net/manual/en/function.mysql-ping.php
> >
> > something like:
> >
> > <?php
> >
> > if ([EMAIL PROTECTED]()) //Note the @ is because, if mysql_ping cannot get
> > connected, it will display a warning - suppress so users don't see
> > {
> >   connectToDB();> }
> >
> > mysql_real_escape_string('stuff');
> >
> > ?>
> >
> > HTH-
> >
> > James
> >
>
> I was thinking about that, but the problem is that if there is no
> connection, then the include is called and doesn't provide the
> mysql_clean function that I expect that it would. Then, I make a
> connection and use the function, expecting it to clean my data and it
> doesn't.

You should be able to have the best of both worlds - it shouldn't have
to be an either/or:

function clean_mysql ($dirty) {
   $dirty=str_replace ("--", "", $dirty);
   $dirty=str_replace (";", "", $dirty);
   if ([EMAIL PROTECTED]())
   {
     functionThatConnectsToMySQL();
   }
   $clean=mysql_real_escape_string($dirty);
   return $clean;
}

This will connect if not connected, but either way it will still run
the mysql_real_escape_string function - it's not inside an else
statement...

-James





>
>
> Dotan Cohen
>
> http://what-is-what.com
> http://gibberish.co.il
> א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
>
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
>

Reply via email to