dodgei Posted February 5, 2007 Share Posted February 5, 2007 I'm saving the variables that I retrieve from the database into a link so that it can be passed to the next page. My problem is that the 'Merchant' field sometimes contains multiple words. When I try to set the contents of the 'Merchant' field into the url, it is only setting the first word. while($r = @odbc_fetch_array($results)) { echo "<tr><td>".$r['EntryID']."</td>"; $alldate=substr($r['DueDate'],0,2).'.'.substr($r['DueDate'],2,2).'.'.substr($r['DueDate'],4,4); echo "<td>".$alldate."</td>"; echo "<td>".$r['Merchant']."</td>"; echo "<td>".$r['Amount']."</td>"; echo "<td>".$r['Status']."</td>"; echo "<td><a href=http://www.merediencapital.com/ada/makepay.php?action=pay &row_id=" . $r['EntryID']."&merchant=". $r['Merchant']."&duedate=".$r['DueDate']." &amount=".$r['Amount'].">Payment</a></td>"; echo "<td><a href=" . $_SERVER['PHP_SELF'] . "?action=delete&row_id=" . $r['EntryID'].">delete</a></td></tr>"; } How can I fix this? Link to comment https://forums.phpfreaks.com/topic/37176-solved-passing-variable-via-url/ Share on other sites More sharing options...
ted_chou12 Posted February 5, 2007 Share Posted February 5, 2007 yeah, as long as there are no line breaks, like: test test this is a line break, this wont work, but spaces dont matter. Ted Link to comment https://forums.phpfreaks.com/topic/37176-solved-passing-variable-via-url/#findComment-177578 Share on other sites More sharing options...
dodgei Posted February 5, 2007 Author Share Posted February 5, 2007 This is the link that it creates when there are 2 words in the 'Merchant' field, http://www.merediencapital.com/ada/makepay.php?action=pay&row_id=22&merchant=Western The value of the field is 'Western Printing'. And this is displayed when I use odbc to just echo the contents of that field. Why does it stop when it hits the space? Link to comment https://forums.phpfreaks.com/topic/37176-solved-passing-variable-via-url/#findComment-177594 Share on other sites More sharing options...
ted_chou12 Posted February 5, 2007 Share Posted February 5, 2007 as far as i tried, the word space doesnt matter, but if that is the case for you, you can try replacing the space with some special string like "EGIEG" using str_replace() and use the same fuction to replace the special string back with space after passing through the url, in that way, you wont have this problem then. Link to comment https://forums.phpfreaks.com/topic/37176-solved-passing-variable-via-url/#findComment-177597 Share on other sites More sharing options...
dodgei Posted February 5, 2007 Author Share Posted February 5, 2007 The problem was that the url cannot contains spaces so this is the function that will enable variables with spaces to be passed by the url. urlencode() Link to comment https://forums.phpfreaks.com/topic/37176-solved-passing-variable-via-url/#findComment-177633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.