Welcome to WebmasterWorld Guest from 3.80.60.248

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

pound signs

safari adding extra characters to markup

     
3:58 pm on Oct 12, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


I've got a form that upload job details to a database among which is a salary field - this can be numerical or text based eg "3000" or "good salary". On safari when I submit the form it adds an A character with a ^ above it which renders as a? on the website.

I use str_replace to convert the pound sign into

£
but I can't seem to use a str_replace to get rid of this foreign A or find our why safari adds it.

Any ideas?

6:13 pm on Oct 12, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
posts:3719
votes: 0


Hi fwordboy,

Is the data coming from an array? It may be that the array was not initialised before it was used. Hence the inclusion of the strange character. I`m not sure why this happens, but I had a similar problem earlier this year.

If it is an array, make sure you initialise it first. ie:

$variable = array();

dc

8:51 pm on Oct 12, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


the data comes from
$_POST['form_field'];
so I think that's an array isn't it? ANd i upoad to the database like so

$salary = str_replace('','£',$_POST['salary']);
and then insert the [code]$salary into the database.
9:53 am on Oct 13, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
posts:3719
votes: 0


Can you post some more of your code?
10:59 am on Oct 13, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


yeah sure, I think the problem isn't Safari but the Apache server. As it seems to do it on the remote server (Linux Apache) but not on my testing server (Apple Apache).

the form:


<form id="add_job" method="post" action="/recruitment/admin/functions/jobs.php">
...
<label for="wage">Wage *</label><input type="text" id="wage" name="wage" tabindex="4" />
...
</form>

the PHP/SQL


//convert s into escaped signs
$_POST['wage'] = str_replace('', '&pound;', $_POST['wage']);

I've established that the strange character is added after the last str_replace code snippet.

11:21 am on Oct 13, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
posts:3719
votes: 0


Might be just a case of trial and error until you get something that works. Have you tried assigning a new variable to the data like this:

$variable = str_replace('', '&pound;', $_POST['wage']);

Then add to the database using the new variable. Or assign the data like this:

$variable = $_POST['wage'];

Then do the string replace upon database insertion:

INSERT INTO table (field) VALUES ('".str_replace("", "&pound", $variable)."');

See if that helps.

dc

12:20 pm on Oct 14, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


thanks dreamcatcher, your first suggestion seems to have worked.

and thanks to everyone who responded to my problem.

3:32 pm on Oct 14, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
posts:3719
votes: 0


Cool, glad you got lucky. :)
12:55 pm on Oct 17, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


dreamcatcher, actually when I looked back at the code today, it was still faulty but the following seems to have fixed it:


//convert s into escaped signs
$wage = htmlentities($_POST['wage']);
$wage = str_replace("&Acirc;", "", $wage);
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members