A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearSilly sprintf() question - page 1
User InfoPosts
Silly sprintf() question#1
How do I add the SQL wildcard characters to this:

 sprintf("SELECT robot FROM robots WHERE robot LIKE '%s'",strtolower($user_agent));


as

 sprintf("SELECT robot FROM robots WHERE robot LIKE '%%s%'",strtolower($user_agent));


blows up in a spectacular ball of flame,

PS sorry for the rather basic question. I'm cutting down on my coffee these days.

posted date: 2008-12-16 03:17:00


Re: Silly sprintf() question#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-16 03:17:01


Re: Silly sprintf() question#3
A literal % is specifed as %%, so you want "... LIKE '%%%s%%'"

posted date: 2008-12-16 03:20:00


Re: Silly sprintf() question#4
perfect thank you RoBorg!

posted date: 2008-12-16 03:23:00


Re: Silly sprintf() question#5
another accepted answer for RoBorg :)

posted date: 2008-12-16 03:52:00


Re: Silly sprintf() question#6
Keep voting this up, I don't have a gold badge yet :p

posted date: 2008-12-16 03:57:00


Re: Silly sprintf() question#7
Why use sprintf here (no formatting) instead of string concatenation or simple variable substitution?

posted date: 2008-12-16 04:17:00


Re: Silly sprintf() question#8
Side note: you're opening yourself to code injection by using such constructs...

posted date: 2008-12-16 04:53:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.