|
Posted by Curtis on 02/05/07 07:36
On Sun, 04 Feb 2007 07:22:17 -0800, zek2005 <esapoznik@gmail.com> wrote:
> Hi !!!
Greetings!!
> I have the following php code
>
> <?php
> $db = mysql_connect("1", user, password)
> or die ("can´t connect");
> mysql_select_db(efemerides,$db);
> mysql_close();
> ?>
>
> I receive the error "can´t connect". Right beacuse "1" is not my
> server.
>
> Then I insert a function in the code and I do not receive the "can´t
> connect" error. It seems that when I insert the function in the PHP
> doesn´t work as it should
>
> <?php
> $db = mysql_connect("1", user, password)
"1" is not a valid host name. You should usually use "localhost"
> or die ("no se ha podido conectar");
> mysql_select_db(efemerides,$db);
> function quitar($mensaje)
> {
> $mensaje = str_replace("<","<",$mensaje);
> $mensaje = str_replace(">",">",$mensaje);
> $mensaje = str_replace("\'","'",$mensaje);
> $mensaje = str_replace('\"',""",$mensaje);
> $mensaje = str_replace("\\\\","\",$mensaje);
> return $mensaje;
> }
> mysql_close();
> ?>
Use PHP built-in escaping instead of making your own function:
$safe = htmlentities(get_magic_quotes_gpc() ? stripslashes($mensaje) :
$mensaje);
> <snip>
--
Curtis, http://dyersweb.com
[Back to original message]
|