GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Really Quick PHP Help REQ (https://gfy.com/showthread.php?t=825123)

dirtysouth 04-29-2008 07:56 AM

Really Quick PHP Help REQ
 
I need to trim special characters out of a form because it's parsing the "'" (single quote) and fucking up a cart I'm building. Users that have something like "Joe's Mags" crashes the cart due to the single quote. Here's what I have:

PHP Code:

if(!empty($_POST['shipcompany']))
{
    
$shipcompanytrim($_POST['shipcompany']);
}
else
{
    
$shipcompany '';


Been mucking around with this:

PHP Code:

$shipcompany "'!£$%^&ss*()}{@:'#~/?><>/ 1 2 3 4 5 3/.,/:@/||\-=-__++-¬``1`sds";
$shipcompany preg_replace('/[^a-z0-9]/'''$shipcompany); 

I just don't know how to mesh the code together. Thanks in advance as you guys always come through in a pinch and the client is pinching the fuck outta me ATM!

Zorgman 04-29-2008 08:38 AM

Why not addslashes?

brandonstills 04-29-2008 11:45 AM

http://us.php.net/addslashes

fluffygrrl 04-29-2008 01:41 PM

And btw, don't start the regexp engine if you don't REALLY need it. it's a hog.

k0nr4d 04-29-2008 01:50 PM

I'm in awe that you know how to write regex like that but didn't know about addslashes :P

bDok 04-29-2008 02:12 PM

or ... mysql_real_escape_string

ugh.

fluffygrrl 04-29-2008 02:16 PM

Quote:

Originally Posted by k0nr4d (Post 14128057)
I'm in awe that you know how to write regex like that but didn't know about addslashes :P

I think it's pretty obvious he c/p'd stuff he found on the internetz.

GrouchyAdmin 04-29-2008 02:33 PM

Quote:

Originally Posted by bDok (Post 14128152)
or ... mysql_real_escape_string

ugh.

Don't forget, mysql_real_escape_string() requires a handler, so you must have an open DB socket to use it.

For the love of god, people, learn to sanitize your variables.


All times are GMT -7. The time now is 01:58 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123