Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: [PHP] backslashes
On Friday 27 August 2004 15:31, Ryan Schefke wrote:

First of all:

Using unsanitised data from forms and links is a VERY bad thing.

> <option value="<?PHP echo 'giftprint.php?passid='.$passid.'&sort=WHERE
> thankyou='Not Sent' ORDER BY cash ASC';?>">Show
>
>             Thank You Notes "Not Sent"</option>

Two problems here:

1) URLs needs to be urlencode() appropriately
2) But your major problem is you're passing too much superfluous data
(technically known as crap).

Breaking it down, you want to pass 4 pieces of data:

1) passid
2) thankyou status
3) sort column
4) sort direction

NB depending on what you're doing (3) & (4) may not be needed (eg if they're
supposed to be hard-coded defaults that are not user selectable).

Now assuming (3) & (4) aren't needed, you would construct your URL something
like this:

giftprint.php?passid=$passid&status=$status

> Then, the below query is run:
>
> $query = "SELECT name, event, description, cash, action, thankyou
>
> FROM gifts WHERE customerID='$passid' $sort";
>
> My problem is with the 'Not Sent'.  I need the backslashes for the php
> statement but the sql query can't handle it and the jump box gives me an
> error.

No, what you should do is assign various codes for the different status, eg

1 - not sent
2 - sent
3 - unknown

Then when you receive the data you sanitise and verify that $passid and
$status are valid.

So for $status it has to be one of 1, 2, or 3.

Then finally you can construct your query.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
You are a bundle of energy, always on the go.
*/

Report this thread to moderator Post Follow-up to this message
Old Post
Jason Wong
08-27-04 01:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP General archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:08 PM.

 

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.