Space Issue with my PHP page

This is a discussion on Space Issue with my PHP page within the PHP Language forums, part of the PHP Programming Forums category; I am a newbie to PHP so hopefully this is a easy question. I am pulling data off of one ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-16-2006
MS
 
Posts: n/a
Default Space Issue with my PHP page

I am a newbie to PHP so hopefully this is a easy question.

I am pulling data off of one server, which holds our data base and
posts it to my PHP page.

I have the following code on my php page:


$pfirstname = $_POST['NFIRST0'];
$plastname = $_POST['NLAST0'];
$paddress = $_POST['NSTREET0'];
$pxaddress = $_POST['NEXTRAADDRESS0']; etc....

For the $paddress variable, it is skipping anything after a space. For
example, if the address is 1234 Main, the only data that pulls in to my
php page would be 1234. It would skip the Main. This is also occuring
with other variables as well.

Anyone have any ideas to why this is happening?

Reply With Quote
  #2 (permalink)  
Old 05-16-2006
reandeau
 
Posts: n/a
Default Re: Space Issue with my PHP page

Can you supply more code so I can see see what your script is doing?
How are you pulling the data off of the server?

Reply With Quote
  #3 (permalink)  
Old 05-16-2006
tim
 
Posts: n/a
Default Re: Space Issue with my PHP page


MS wrote:
> I am a newbie to PHP so hopefully this is a easy question.
>
> I am pulling data off of one server, which holds our data base and
> posts it to my PHP page.
>
> I have the following code on my php page:
>
>
> $pfirstname = $_POST['NFIRST0'];
> $plastname = $_POST['NLAST0'];
> $paddress = $_POST['NSTREET0'];
> $pxaddress = $_POST['NEXTRAADDRESS0']; etc....
>
> For the $paddress variable, it is skipping anything after a space. For
> example, if the address is 1234 Main, the only data that pulls in to my
> php page would be 1234. It would skip the Main. This is also occuring
> with other variables as well.
>
> Anyone have any ideas to why this is happening?


Hi there

How are you delivering the data to your page?

It could be because spaces in post data need to be converted to
pluses(+) or %32 before delivery

If you are using php to send the data to the php page then use the
urlencode function on the data before you post it
http://uk.php.net/urlencode

Tim

Reply With Quote
  #4 (permalink)  
Old 05-16-2006
Rik
 
Posts: n/a
Default Re: Space Issue with my PHP page

MS wrote:
> I am a newbie to PHP so hopefully this is a easy question.
>
> I am pulling data off of one server, which holds our data base and
> posts it to my PHP page.
>
> I have the following code on my php page:
>
>
> $pfirstname = $_POST['NFIRST0'];
> $plastname = $_POST['NLAST0'];
> $paddress = $_POST['NSTREET0'];
> $pxaddress = $_POST['NEXTRAADDRESS0']; etc....
>
> For the $paddress variable, it is skipping anything after a space.
> For example, if the address is 1234 Main, the only data that pulls in
> to my php page would be 1234. It would skip the Main. This is also
> occuring with other variables as well.
>
> Anyone have any ideas to why this is happening?


I'd think the posting goes wrong, have you got a snippet of code from that
side?

What does print_r($_POST); say?

If $_POST['NSTREET0'] does have to right value, are you sure not casting
$paddress to an integer somewhere?

Grtz,
--
Rik Wasmus


Reply With Quote
  #5 (permalink)  
Old 05-17-2006
Geoff Muldoon
 
Posts: n/a
Default Re: Space Issue with my PHP page

mscurto@gmail.com says...

> For the $paddress variable, it is skipping anything after a space. For
> example, if the address is 1234 Main, the only data that pulls in to my
> php page would be 1234. It would skip the Main. This is also occuring
> with other variables as well.
>
> Anyone have any ideas to why this is happening?


Yes, It's a HTML issue not a PHP one. You need to double-quote any
strings with spaces in your inputs.

Example:
echo "<input type=hidden name=paddress value=$paddress>";
should be changed to
echo "<input type=hidden name=paddress value=/"$paddress/">";
or
echo '<input type=hidden name=paddress value="$paddress">';

GM
Reply With Quote
  #6 (permalink)  
Old 05-17-2006
Rik
 
Posts: n/a
Default Re: Space Issue with my PHP page

Hmmmz, it's getting late for you I think....

Geoff Muldoon wrote:
> Example:
> echo "<input type=hidden name=paddress value=$paddress>";
> should be changed to
> echo "<input type=hidden name=paddress value=/"$paddress/">";


You mean:
echo "<input type=hidden name=paddress value=\"$paddress\">";

> echo '<input type=hidden name=paddress value="$paddress">';


You mean:
echo '<input type=hidden name=paddress value="'.$paddress.'">';
or:
echo "<input type=hidden name=paddress value='$paddress'>";

And now we're busy. just as well put quotes around hidden: couldn't hurt,
and it's a good habit to quote all the attribute-values regardless wether it
is really necessary or not.

Grtz,
--
Rik Wasmus


Reply With Quote
  #7 (permalink)  
Old 05-17-2006
Geoff Muldoon
 
Posts: n/a
Default Re: Space Issue with my PHP page

In article <e4dq6d$37e$1@netlx020.civ.utwente.nl>,
luiheidsgoeroe@hotmail.com says...
> Hmmmz, it's getting late for you I think....
>
> Geoff Muldoon wrote:
> > Example:
> > echo "<input type=hidden name=paddress value=$paddress>";
> > should be changed to
> > echo "<input type=hidden name=paddress value=/"$paddress/">";

>
> You mean:
> echo "<input type=hidden name=paddress value=\"$paddress\">";
>
> > echo '<input type=hidden name=paddress value="$paddress">';

>
> You mean:
> echo '<input type=hidden name=paddress value="'.$paddress.'">';
> or:
> echo "<input type=hidden name=paddress value='$paddress'>";
>
> And now we're busy. just as well put quotes around hidden: couldn't hurt,
> and it's a good habit to quote all the attribute-values regardless wether it
> is really necessary or not.


Oops, not enough coffee, thanks for the corrections.
Reply With Quote
  #8 (permalink)  
Old 05-17-2006
Toby Inkster
 
Posts: n/a
Default Re: Space Issue with my PHP page

tim wrote:

> It could be because spaces in post data need to be converted to
> pluses(+) or %32 before delivery


%20, not %32.

<?php
print urldecode('%32'); // prints '2'.
?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Reply With Quote
  #9 (permalink)  
Old 05-17-2006
tim
 
Posts: n/a
Default Re: Space Issue with my PHP page


Toby Inkster wrote:
> tim wrote:
>
> > It could be because spaces in post data need to be converted to
> > pluses(+) or %32 before delivery

>
> %20, not %32.
>
> <?php
> print urldecode('%32'); // prints '2'.
> ?>
>


Oops I forgot to convert to hex, thank you for the reminder.

Tim

Reply With Quote
  #10 (permalink)  
Old 05-23-2006
MS
 
Posts: n/a
Default Re: Space Issue with my PHP page

Thanks for all the postings, I got it working.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:47 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0