Re: help passing string with spaces
| From: | David Robley | Date: | Thu, 24 Aug 2000 02:05:57 +0000 |
| Subject: | Re: help passing string with spaces | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13281@lists.php.net to get a copy of this message | ||
On 23 Aug, Zen Rodeo wrote:
> Here's some code to print some data from MySQL into a
> table data cell. The idea is you click on the link to
> see the entire row:
> printf ("<a
> href=\"show_more.php?d_title=%s\">%s</a></td>",
> ($val), ($val));
>
> And here's the code from show_more.php that's supposed
> to bring up the entire row :
> $my_query = "SELECT * FROM driver WHERE driver_title =
> '$d_title'";
>
> This all works fine when the data is a short string
> like Major. But the page containing the SQL query
> doesn't see the whole string $d_title when the string
> is Major Tom. It doesn't like the empty chars.
> However, in the URL area of the browser window, the
> entire string is visible, and of course it's visible
> in the table.
>
> We're using PHP4 with magic_quotes_gpc = on. Tried
> addslashes, stripslashes, urlencode, etc.
>
> How can the entire string be passed to the next page
> and then used successfully in a SQL query?
>
> Thank you.
urlencode is what you want. Try echo to output the URL and use urlencode
on $val. Something like
<a href="show_more.php?d_title=<?php echo
urlencode($val)?>"></a></td>
or similar.
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA