For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2006 > Re: [PHP-DB] Single quotes in INSERT statements?









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 Re: [PHP-DB] Single quotes in INSERT statements?
Martin Alterisio

2006-04-25, 6:59 pm

1) Check that the string is not being truncated because of the column length

2) If you're seeing this data being truncated in the html output of your
site, check if it isn't being caused by outputing the data without properly
encoding special html characters.

3) ..... dunno

2006/4/25, Skip Evans <skip@bigskypenguin.com>:
>
> Hello all,
>
> I'm brand spanking new to the list and have a
> quick question.
>
> I was under the impression that addslashes() would
> handle single quote marks in INSERT statements,
> but when I execute the following:
>
> $sql="UPDATE images SET orderno=$orderno,
> url='".addslashes($url)."',
> banner=$banner,caption='".addslashes($caption)."'
> WHERE imageID=$imageID";
>
> ...and $caption contains something like:
>
> "Don't look"
>
> ...the data is chopped off at the single quote mark.
>
> How, if not addslashes(), does one handle this?
>
> Thanks!
> --
> Skip Evans
> Big Sky Penguin, LLC
> 61 W Broadway
> Butte, Montana 59701
> 406-782-2240
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


John Hicks

2006-04-25, 6:59 pm

Martin Alterisio wrote:
> 1) Check that the string is not being truncated because of the column length
>
> 2) If you're seeing this data being truncated in the html output of your
> site, check if it isn't being caused by outputing the data without properly
> encoding special html characters.
>
> 3) ..... dunno


Do a select directly from the mysql console (bypassing php) to verify
that the data is really truncated in the db and not in the output
process (per Martin's suggestion.

--John


> 2006/4/25, Skip Evans <skip@bigskypenguin.com>:
>

Skip Evans

2006-04-25, 6:59 pm

Martin Alterisio wrote:
> 1) Check that the string is not being truncated because of the column length
>


This was not it.

> 2) If you're seeing this data being truncated in the html output of your
> site, check if it isn't being caused by outputing the data without
> properly encoding special html characters.
>


Yup! This was it. The data was fine in the
database, so I wrapped the output with
htmlentities() and all came out good.

Thanks to Martin and all who made suggestions.

> 3) ..... dunno


See number 2 ;)

Thanks again!

--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240
Sponsored Links







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

Copyright 2008 codecomments.com