Hey, I've got some code here that puzzles me. I'm putting together a
url based on user input. Should be pretty straightforward, but there's
a problem. First, here's my code.
---
$myurl="write.php?T1=" . $_GET["T1"] . "&T2=" . $_GET["T2"] . "&T3=" .
$_GET["T3"] . "&T4=" . $_GET["T4"] . "&T56=" . $_GET["T56"] . "&T7=" .
$_GET["T7"] . "&T89=" . $_GET["T89"] . "&T10=" . $_GET["T10"] . "&T11="
.. $_GET["T11"];
echo $myurl;
echo "<a href=\"" . $myurl . ">OK - Next Step >>" .
"</a>";
---
** Please note that the 3 lines with the $_GET variables are really on
1 line.
So, that makes my link fine. The problem is my output:
write.php?T1=Word1
Word2
It takes spaces in the $_GET["T1"] and for some reason makes them into
new lines....... which throws off my url completly because it's then
sending you to write.php?T1=Word1, dropping word2 and the rest of the
get variables.
Why is this??
Please help. Sorry if this wasn't clear, but it's a bit confusing, and
I'll try to clarify it if you need more.
Thanks, iw****@gmail.com 8 1484
Sorry, but I have a few corrections. I meant "4" lines instead of 3,
and it DOESN'T make my line fine. IW****@gmail.com wrote in news:1124478378.973496.290910
@z14g2000cwz.googlegroups.com: Hey, I've got some code here that puzzles me. I'm putting together a url based on user input. Should be pretty straightforward, but there's a problem. First, here's my code.
---
$myurl="write.php?T1=" . $_GET["T1"] . "&T2=" . $_GET["T2"] . "&T3=" . $_GET["T3"] . "&T4=" . $_GET["T4"] . "&T56=" . $_GET["T56"] . "&T7=" . $_GET["T7"] . "&T89=" . $_GET["T89"] . "&T10=" . $_GET["T10"] . "&T11=" . $_GET["T11"];
Format your string using urlencode():
$tmpa = array();
foreach ($idx in array('T1','T2','T3','T4','T56','T7','T89','T10'))
$tmpa[] = $idx . '=' . urlencode($_GET[$idx]);
$myurl = 'write.php?' . implode('&',$tmpa);
You'll notice I changed the way the code creates the URL. By using the
foreach() construct, you can easily change what indices you use.
echo $myurl; echo "<a href=\"" . $myurl . ">OK - Next Step >>" . "</a>";
echo '<a href="' . $myurl . '">OK - Next Step >></a>';
See if that helps.
Ken
That looks great to me, but when I run it, I get a
Parse error: syntax error, unexpected T_STRING in C:\Program
Files\Apache Group\Apache2\htdocs\schedule\confirm.php on line 48.
Line 48 is foreach ($idx in
array('T1','T2','T3','T4','T56','T7','T89','T10')) .
But I don't see a problem... Commenting out the code you gave resolves
the error...
Thanks, iw****@gmail.com IW****@gmail.com wrote in news:1124480293.949505.8120
@f14g2000cwb.googlegroups.com: That looks great to me, but when I run it, I get a
Parse error: syntax error, unexpected T_STRING in C:\Program Files\Apache Group\Apache2\htdocs\schedule\confirm.php on line 48.
Line 48 is foreach ($idx in array('T1','T2','T3','T4','T56','T7','T89','T10')) .
Can you post the lines before line 48. Sometimes the error is actually on a
preceding line and PHP doesn't realize it until something doesn't make
sense.
Ken
<?php
$tmpa = array();
foreach ($idx in array('T1','T2','T3','T4','T56','T7','T89','T10')) {
$tmpa[] = $idx . '=' . urlencode($_GET[$idx]);
}
$myurl = 'write.php?' . implode('&',$tmpa);
echo $myurl;
echo '<a href="' . $myurl . '">OK - Next Step >></a>';
?>
That's the only php in this document...
Sorry for being a pest iw****@gmail.com
Oh, I tried adding the { }'s after it didn't work the first time,
because the php manual uses them, but they didn't help. IW****@gmail.com wrote in news:1124481301.015505.79180
@g49g2000cwa.googlegroups.com: <?php
$tmpa = array(); foreach ($idx in array('T1','T2','T3','T4','T56','T7','T89','T10')) {
My error (that's what I get for not checking my code...)
The foreach line should read:
foreach (array('T1','T2','T3','T4','T56','T7','T89','T10') as $idx)
$tmpa[] = $idx . '=' . urlencode($_GET[$idx]); } $myurl = 'write.php?' . implode('&',$tmpa);
echo $myurl;
echo '<a href="' . $myurl . '">OK - Next Step >></a>';
?>
That's the only php in this document...
Sorry for being a pest
Not a problem. How else would you learn...
Ken This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ksedran |
last post by:
Hi All,
I am seeing a very strange issue with a winform I have.
There are a few statements in the code, that at one point were working just
fine.
I had compiled the code a few days ago and...
|
by: Tony Johansson |
last post by:
Hello!
I have two very small classes(Head_1 and Head_2) see below and a very small
main.
I have run into a very strange problem. This program doesn't compile but if
I replace
the string...
|
by: Thomas |
last post by:
Hi,
I implemented a composite pattern which should be serializable to xml.
After spending some time in the newsgroups, i finally managed
serializing, even with utf-8 instead of utf-16, which...
|
by: Don McNamara |
last post by:
Hi,
I've hit quite a strange problem with XmlSerializer on my W2K3 server. When
I serialize/deserialize using an exe on my local computer (XP), everything
works fine. When I put the code out on...
|
by: Neil Ginsberg |
last post by:
I have a strange situation with my Access 2000 database. I have code in the
database which has worked fine for years, and now all of a sudden doesn't
work fine on one or two of my client's...
|
by: Kris Vanherck |
last post by:
yesterday i started getting this strange error when i try to run my asp.net
project:
Compiler Error Message: CS0006: Metadata file
'c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net...
|
by: Buddy Ackerman |
last post by:
I have a web app that I have setup on numerous web servers. I've set one up for a new client at their hosting facility
and cannot get it to connect to their database. I get a "SQL Server does not...
|
by: WhiteWizard |
last post by:
Have we got a STRANGE one going here.
We converted from 1.1 to 2.0 about 2 weeks ago and this has been a problem
since then...but only on SOME machines in our development group. The
application...
|
by: TheSteph |
last post by:
Hi,
I have a small serializable struct :
public struct TestStruct
{
public string Title;
public int Age;
public string Name;
|
by: FBM |
last post by:
Hi there,
I am puzzled with the behavior of my code.. I am working on a
networking stuff, and debugging with eclipse (GNU gdb 6.6-debian)..
The problem I am experiencing is the following:
...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |