Reputation: 685
i am getting a querystring parameter like companyname=Larson&tubro. Its a single string. But my script is just breaking it after '&'. What is the solution to take this as a single string in PHP. I tried like the below:
<A onclick="window.open('comparitive_files/price_add.php?supplier_name= + urlencode({$supplier_name})&tender_id={$tender_id}','mywindow','width=1200,height=800,scrollbars=yes,resizable=yes')"
href="#">
Upvotes: 0
Views: 140
Reputation: 1016
You are trying to use php functions outside of php. Try something like this.
echo '<A onclick="window.open(\'comparitive_files/price_add.php?supplier_name='.urlencode($supplier_name).'&tender_id='.$tender_id.',\'mywindow\',\'width=1200,height=800,scrollbars=yes,resizable=yes\')" href="#">';
Upvotes: 2
Reputation: 2530
Use urlencode
for encoding
urlencode($companyname);
and urldecode
for decoding
urldecode($companyname)
Upvotes: 0
Reputation: 6818
&
is used to seperate variables in a querystring. Instead use &
.
To prevent any other illegal characters from getting in your querystring, use urlencode()
Upvotes: -1