Oprano Adult Industry Forums

Oprano Adult Industry Forums (http://www.oprano.com/msgboard/index.php)
-   Legacy Archived Main Board (http://www.oprano.com/msgboard/forumdisplay.php?f=25)
-   -   PHP gurus...help please! (http://www.oprano.com/msgboard/showthread.php?t=92564)

Nymph 11-09-2008 09:09 AM

PHP gurus...help please!
 
I need to escape a character (') in one of my forms...actually it's in 3 different places for the same submit form.

This is for one of my mainstream sites...most of us do them, so don't bash me for asking here.

I can not add Sara's Sugar Cookies, or in the ingredients box, or directions, anything that has a ' in it. It just won't write it to the sql database.

What do I need to look for, and change, or add so I will be able to use that character...this is really starting to drive me more nuts than I already am.

sarettah 11-09-2008 09:22 AM

Re: PHP gurus...help please!
 
Quote:

Originally Posted by Nymph (Post 822032)
I need to escape a character (') in one of my forms...actually it's in 3 different places for the same submit form.

This is for one of my mainstream sites...most of us do them, so don't bash me for asking here.

I can not add Sara's Sugar Cookies, or in the ingredients box, or directions, anything that has a ' in it. It just won't write it to the sql database.

What do I need to look for, and change, or add so I will be able to use that character...this is really starting to drive me more nuts than I already am.

Turn on your icq...........dammit

Toby 11-09-2008 09:26 AM

Re: PHP gurus...help please!
 
You could replace all the (') with (’) using the following on each datafield before it's added to the database.

Code:

$item1 = preg_replace("/'/","’",$item1);
But sarettah probably has a more eloquent solution.

sarettah 11-09-2008 09:32 AM

Re: PHP gurus...help please!
 
The way i normally put a quote mark into a sql database is by replacing it with 2 quote marks.

$field2use=str_replace("'","''",$field2use)

I usually do that while building the sql string for the insert or update.

sarettah 11-09-2008 09:34 AM

Re: PHP gurus...help please!
 
Quote:

Originally Posted by Toby (Post 822034)
You could replace all the (') with (’) using the following on each datafield before it's added to the database.

PHP Code:

$item1 = preg_replace("/'/","’",$item1); 

But sarettah probably has a more eloquent solution.

lol. no nothing more eloquent. But what all she needs to do depends on how the var is being treated prior to that.

Toby 11-09-2008 09:46 AM

Re: PHP gurus...help please!
 
Grrrr, having trouble getting the board to display that snippet properly. the (’) should be ( & #146; ) without the space.

Quote:

Originally Posted by sarettah (Post 822036)
lol. no nothing more eloquent. But what all she needs to do depends on how the var is being treated prior to that.

Right, the chosen replacement string may still cause problems depending on how the strings are used when displayed.

sarettah 11-09-2008 10:00 AM

Re: PHP gurus...help please!
 
Quote:

Originally Posted by Toby (Post 822037)
Grrrr, having trouble getting the board to display that snippet properly. the (’) should be ( & #146; ) without the space.



Right, the chosen replacement string may still cause problems depending on how the strings are used when displayed.

Well that and if they are coming directly from the form she needs to protect against sql injection too, if that is not already happening.

I hate dealing with escapes, so I write my code to deal with them as little as possible..lol. It is the one thing about php that I don't like compared to the other languages I deal with.

My standard way of dealing with this shit if I have to is..

1. turn on mysql at the beginning of the script.
2. run all input vars through mysql_real_escape_string
3. run all input vars through addslashes
4. Stick them into the database

so.. like this

mysql_pconnect($mysql_host,$mysql_user,$mysql_ass) ;
mql_select_db($mysql_db);

$input_var=addslashes(mysql_real_escape_string($_P OST['input_var']));
$result=mysql_query("insert into database.tablename(field2insertinto)values(" . $input_var . ")");

But if the only thing I am dealing with is a single quote prob because it is a protected form or because I am doing an update routine that is not form fed then I just used the replace a single quote with 2 single quotes like I said orignally :)

Nymph 11-09-2008 10:03 AM

Re: PHP gurus...help please!
 
It might help if you turn yours on too sweetie :rolleyes:

sarettah 11-09-2008 10:27 AM

Re: PHP gurus...help please!
 
Quote:

Originally Posted by Nymph (Post 822039)
It might help if you turn yours on too sweetie :rolleyes:

mine is always on... in stealth mode ;p

sarettah 11-09-2008 11:19 AM

Re: PHP gurus...help please!
 
Quote:

Originally Posted by sarettah (Post 822038)
Well that and if they are coming directly from the form she needs to protect against sql injection too, if that is not already happening.

I hate dealing with escapes, so I write my code to deal with them as little as possible..lol. It is the one thing about php that I don't like compared to the other languages I deal with.

My standard way of dealing with this shit if I have to is..

1. turn on mysql at the beginning of the script.
2. run all input vars through mysql_real_escape_string
3. run all input vars through addslashes
4. Stick them into the database

so.. like this

mysql_pconnect($mysql_host,$mysql_user,$mysql_ass) ;
mql_select_db($mysql_db);

$input_var=addslashes(mysql_real_escape_string($_P OST['input_var']));
$result=mysql_query("insert into database.tablename(field2insertinto)values(" . $input_var . ")");

But if the only thing I am dealing with is a single quote prob because it is a protected form or because I am doing an update routine that is not form fed then I just used the replace a single quote with 2 single quotes like I said orignally :)


I have that all fucked up dammit.

Helps to have coffee first.

Should not need the addslashes if I am using the mysql_real_escape as it will do the same fucking thing.

Hate when I screw that shit up.

Nymph 11-09-2008 11:27 AM

Re: PHP gurus...help please!
 
I know I should switch to a new script, but this is the only way I get to talk with you sweetie ;)

Nymph 11-09-2008 11:50 AM

Re: PHP gurus...help please!
 
My knight in shining armour came through for me again.

I swear if I had a kid for him every time he has helped me with this stupid script, we'd have a basketball team by now!

Thanks again Sare...I'll love you forever & a day :kiss:


All times are GMT -4. The time now is 04:22 PM..

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright Evil Empire Inc. 2006-2022