Re: Syntax error on concatenated SQL string.
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Thu, 30 Apr 2009 14:26:16 -0400
Mechphisto wrote:
On Apr 29, 7:14 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:Mechphisto wrote:Ah karp, nevermind.Good. Sometimes they can be very difficult to find. A syntax-aware
I found the missing bracket.
I was thinking it may be a problem with PHP stopping reading the
string at some point and thus acting like it was missing everything
after where it stopped...but no, it was an actual missing bracket I
over and over and overlooked.
Sorry,
Liam
editor (I use Crimson Editor on Windows and vim on Linux) helps a lot.
One other comment - you need to ensure you validate your data and use
mysql_real_escape_string() on strings. As it is written, your code is
ripe for SQL injection (google for it - it can be very insidious in the
wrong hands!).
Oh no no, I take SQL injection very seriously!
Every one of those SESSION variables are created with lines like this:
$_SESSION['txt_name'] = mysql_real_escape_string(field_sanitize($_POST
['txt_name'],2,2));
and that "field_sanitize" is a home-grown function which checks the
string for any suspicious characters or HTML or encoding or slashes.
No, I realized recently after setting the Web site up to e-mail me
whenever anyone tried to add something to the end of the site's URL
and subsequently getting dozens of emails a day showing _GET SQL
injection attempts that SQL injection was a serious deal!
Thanks for the reminder. :)
Liam
That's good.
As a personal preference - I wouldn't call mysql_real_escape_string() until I'm ready to insert the data into the database. You might want the unescaped data, for instance (i.e. what happens if you have the name O'Malley'?). And on the off chance you change the connection collation (i.e. multi-lingual site), you'll want mysql_real_escape_string() to be using the correct collation.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Next by Date: Re: Proper way to unset SOME session variables?
- Next by thread: Re: Proper way to unset SOME session variables?
- Index(es):
Relevant Pages
|