Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable in url

Status
Not open for further replies.

dingleberry

Programmer
Dec 13, 2002
143
US
Hey Perhaps someone out there knows the answer to this cause I'm a little stumped.

If I'm passing variables between scripts using the url like

$var="hi";
$var2="hi2";

however if
$var="hi Dan"
$var2="hi 2 Dan"

only carries
and that's it. Does anyone know how to force the url to carry the whole string? I've tried

but then I only get


Thanks in advance.
Dan
 
try this

function qlink( $q )
{
GLOBAL $QUERY_STRING;
if ( ! $q ) return $QUERY_STRING;
$ret = "";
foreach( $q as $key => $val )
{
if ( strlen( $ret ) ) $ret .= "&";
$ret .= urlencode( $key ) . "=" . urlencode( $val );
}
return $ret;
}
$q = array ( name => "Arthur Harold Smith",
interest => "Cinema (mainly art house)",

homepage =>
'');
print qlink( $q );
// prints
name=Arthur+Harold+Smith&interest=Cinema+%28mainly+art+house
//
%29&homepage=http%3A%2F%2F?>
<p>
<a href=&quot;anotherpage.php?<? print qlink($q) ?>&quot;>Go!</a>
</p>

(taken from sams teach yourself php in 24 hours- I think you need to do something similar and make your variables into an array) Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top