FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » str_replace ?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: str_replace ? [message #183360 is a reply to message #183357] Mon, 21 October 2013 02:11 Go to previous messageGo to previous message
David Robley is currently offline  David Robley
Messages: 23
Registered: March 2013
Karma:
Junior Member
richard wrote:

> On Sun, 20 Oct 2013 21:02:10 -0400, Lew Pitcher wrote:
>
>> On Sunday 20 October 2013 20:48, in comp.lang.php, "richard"
>> <noreply(at)example(dot)com> wrote:
>>
>>> In my database I am noting that none of the song names containing a
>>> single quote are being written.
>>> If I use str_replace, how exactly should I write it?
>>
>> By using mysql_real_escape_string()
>>
>> http://ca1.php.net/manual/en/function.mysql-real-escape-string.php
>>
>> See example #1, and modify for INSERT
>
> I don't quite follow the example.
> What I have is this:
>
$played = mysql_real_escape_string($playme[$number][2]);
>
> mysql_query(
> "INSERT INTO top20 (songs,name,hits)
> VALUES (' ".$song." ',' ".$played." ',1)
> ON DUPLICATE KEY UPDATE hits=hits+1");
>
> Assume that $played="I'm Sorry".
>
> Please show me how and where to put the proper coding.

Use the above; this is simpler than trying to introduce you to the
complexities of sprintf. You should use mysql_real_escape_string on any
strings you send to mysql.
--
Cheers
David Robley

"I teach at a university," Tom professed.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: has anyone used multithreaded PHP appserver.io for application?
Next Topic: Observation
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 13:05:56 GMT 2024

Total time taken to generate the page: 0.05111 seconds