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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|