[ale] [OT] .php logic problem

ChangingLINKS.com x3 at ChangingLINKS.com
Thu Aug 7 14:19:22 EDT 2003


Yeah. I knew that . . . but I have not learned how to handle \ either.
Like, if I say \\' to try to escape the slash, I get an error.
try to replace "\\" with "" and get a warning.
I am not a programmer.

Drew

On Thursday 07 August 2003 13:02, James P. Kinney III wrote:
> IANAPHPE (I am not a PHP expert).
>
> It looks to me that you need some logic code to handle the \' issue.
>
> if character_before(') eq "\" do_nothing else sed s/'/\'/
>
> Now the character_before function I can do in perl with string counting.
> No clue how to do this in php.
>
> On Thu, 2003-08-07 at 13:51, ChangingLINKS.com wrote:
> > I have spent a lot of time on a weird php problem.
> > I am trying to make sure that the ' character is always escaped in my
> > database.
> >
> > * I do not have the ability to configure the server.
> > * I do not know or care to know if magic_quotes_gpc is ON
> > ’
> > * htmlspecchar is not an option
> >
> > I am using a form to update a field in the table.
> > 1. If I use addslashes over and over like this:
> > 		$description = addslashes($description);
> > 		each time I click "update" it adds more and more slashes. (\\\\')
> >
> > 2. If I stripslashes and addslashes like this:
> > 		$description = stripslashes($description);
> > 		$description = addslashes($description);
> > 		this results in ' (no slashes) (why?)
> >
> > 3. If I try getting fancy, I get lost like this:
> > 		$description = stripslashes($description);
> > 	 	$description = ereg_replace("'", "3edc1", $description);
> > 	 	$description = ereg_replace("3edc1", "'", $description);
> > 		$description = addslashes($description);
> > 		this still results in ' (no slashes)
> >
> > 4. My goal is to always end up with \' in the database after I update
> > 		How do I do that?
> >
> > The code just modifys the "description" string:
> > 		$description = stripslashes($description);
> > 	 	$description = ereg_replace("%", "percent", $description);
> > 	 	$description = ereg_replace("\"", "", $description);
> > //	 	$description = ereg_replace("'", "d4c1", $description);
> > //	 	$description = ereg_replace("d4c1", "\\d4c1", $description);
> > //	 	$description = ereg_replace("d4c1", "'", $description);
> > //		$description = addslashes($description);
> > 		$description = ereg_replace("w/", "3edc", $description);
> > 	 	$description = ereg_replace("/", " ", $description);
> > 		$description = ereg_replace("3edc", "w/", $description);
> > 		$description = strtolower( $description );
> > 		$description = ereg_replace("&", "and", $description);
> >
> > Also related:
> > Does anyone know how to change the open (and close) apostrophes into \'
> > as well?

-- 
Wishing you Happiness, Joy and Laughter,
Drew Brown
http://www.ChangingLINKS.com
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list