dbTalk Databases Forums  

mysql_query("update... simple question

comp.databases.mysql comp.databases.mysql


Discuss mysql_query("update... simple question in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Captain Paralytic
 
Posts: n/a

Default Re: mysql_query("update... simple question - 01-06-2012 , 08:59 AM






On Jan 6, 2:05*pm, Jerry Stuckle <jstuck... (AT) attglobal (DOT) net> wrote:
Quote:
On 1/6/2012 8:35 AM, Captain Paralytic wrote:

Paul, I know you were trying to be succinct in your posing, but your
example is very bad for security.

ALL strings need to use mysql_real_escape_string() to ensure characters
such as quotes (') (and others, depending on the charset) are handled
properly. *More importantly, it prevents SQL injection attacks.

Additionally, numeric values need to be verified that they actually are
numeric before inserting, again to prevent SQL injection attacks.
Oh I totally agree. But the point I was trying to make was that the
mess didn't have to be such a mess.

I assumed that he had already pre-processed the strings with
mysql_real_escape_string(). (OK, based on what we can see this is not
a likely scenario, but just how much re-writing can we go doing.)

Personally I almost always use the {} notation for double quoted
string expansion, but I wanted to invite the OP to see the
alternatives available.

Happy new year BTW.

Reply With Quote
  #12  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: mysql_query("update... simple question - 01-06-2012 , 12:08 PM






On 1/6/2012 9:59 AM, Captain Paralytic wrote:
Quote:
On Jan 6, 2:05 pm, Jerry Stuckle<jstuck... (AT) attglobal (DOT) net> wrote:
On 1/6/2012 8:35 AM, Captain Paralytic wrote:

Paul, I know you were trying to be succinct in your posing, but your
example is very bad for security.

ALL strings need to use mysql_real_escape_string() to ensure characters
such as quotes (') (and others, depending on the charset) are handled
properly. More importantly, it prevents SQL injection attacks.

Additionally, numeric values need to be verified that they actually are
numeric before inserting, again to prevent SQL injection attacks.

Oh I totally agree. But the point I was trying to make was that the
mess didn't have to be such a mess.

I assumed that he had already pre-processed the strings with
mysql_real_escape_string(). (OK, based on what we can see this is not
a likely scenario, but just how much re-writing can we go doing.)

Personally I almost always use the {} notation for double quoted
string expansion, but I wanted to invite the OP to see the
alternatives available.

Happy new year BTW.
Yup, I use {} syntax a lot also, and even heredoc where I can.
Sometimes I find printf() to be useful, but more often than not it
confuses the issue more than it helps.

And a very Happy New Year to you and yours, also!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #13  
Old   
Michael Joel
 
Posts: n/a

Default Re: mysql_query("update... simple question - 01-06-2012 , 02:32 PM



On Fri, 6 Jan 2012 06:59:06 -0800 (PST), Captain Paralytic
<paul_lautman (AT) yahoo (DOT) com> wrote:

Quote:
I assumed that he had already pre-processed the strings with
mysql_real_escape_string(). (OK, based on what we can see this is not
a likely scenario, but just how much re-writing can we go doing.)

Actaully yes. All variables were processed - except session vars since
these were loaded from the database and are not manipulated.

No need to rewrite anything. I only was asking about update syntax - I
had an incorrect understanding of it.

Mike

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.