473,377 Members | 1,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,377 software developers and data experts.

pg_escape_string and too many slashes

Ok. I have a web form with text fields.

When the form is submitted, it goes to a php page to insert into a
Postgres DB.

Example:

pg_query($db,"INSERT INTO table VALUES = ('" .
pg_escape_string($_POST['formfield']) . "')";

However, and I could swear this didn't always happen, now it seems that
if the formfield has a ' in it (i.e. "Sugapablo's music") then when I
would return that field on another page such as:

echo $row['field'];

It would show up: Sugapablo\'s music

Every subsequent time I would submit that form, a slash would be added
before each \ and '. Sometimes producing: Sugapablo\\\\\\\\\\'s music

Shouldn't the slash be elimnated before it get's into the database? Why
is it remaining. By submitting "INSERT INTO table VALUES ('Sugapablo\'s
music') actually put "Sugapablo's music" into that field?

I've also had the same problem with addslashes().

--
Sugapablo - ru***********@stargate.net
http://www.sugapablo.com | ICQ: 902845

Jul 16 '05 #1
1 4113
ljb
ru***********@statgate.net wrote:
Ok. I have a web form with text fields.
...
pg_query($db,"INSERT INTO table VALUES = ('" .
pg_escape_string($_POST['formfield']) . "')";
...
Every subsequent time I would submit that form, a slash would be added
before each \ and '. Sometimes producing: Sugapablo\\\\\\\\\\'s music


You're probably getting double escaping due to magic_quotes_gpc adding
slashes to your POST data. If you control the site, turn off this misfeature
site-wide, otherwise you need to stripslashes() your incoming form data.
Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randell D. | last post by:
Folks, I'm using Apache/1.3.28 (SuSE 7.1, kernal 2.4) with PHP/4.3.2. I have the following code to help cleanse form data. function cleanData($sourceData, &$cleanData) { foreach($myData as...
1
by: mr_burns | last post by:
Hi, I have been sending emails using PHP with the mail() command/method. When I send them tho it adds slashes, for example: 'hi guy's' gets sent as 'hi guy\'s' Why is this? How do I sort...
13
by: lawrence | last post by:
A user writes this sentence: "It was the New Urbanist's nightmare of sprawl run amok." They input that and my PHP script hits it with addslashes() and then the sentence gets put in the database....
16
by: droog | last post by:
Hello! I have just started learning python and encountered a problem. All I wanted to do, was to open a text file search and count the number of occurances of a single word and print that count....
10
by: Carlos Ribeiro | last post by:
Hello all. I'm sending this to the list because I would like to know if someone else has ever stumbled across this one, and also because one possible solution is to patch, or simply "decorate",...
7
by: Alex | last post by:
I'm new to Oracle, so this question may sound silly. I have been given a list of Oracle tables (they may be views, I'm not sure) that are available to me. I can run simple SQL select statements...
5
by: Treetop | last post by:
I have noticed with various codes that the slashes are not consistent. Is there a reason for this. For example </td> </\td> <\/td> <td /> what is the difference with these tags?
4
by: bdwise | last post by:
I have a textbox in a form, and I need to allow users to enter dates in US Format (MM/DD/YYYY). But they do not want to type any slashes, just 8 numbers, and have the slashes added for them. ...
0
by: Henrik de Jong | last post by:
Hello, I'm using radeditor. When I set the html-property to the text wich has to be altered, it gives me an error when try to save the new values of the html-proterty. It occurs only when i'm...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.