You are here: Re: Problem inserting a function - Easy question « PHP Programming Language « IT news, forums, messages
Re: Problem inserting a function - Easy question

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация