howard-moore Posted December 3, 2009 Share Posted December 3, 2009 I have a PHP page where I call a Perl script with the name of a particular field (Committees) being the search delimiter. The issue I have is where the Committee has spaces in its name: <?php include ("$domain/php-bin/councillors.pl?order_by=Surname&order=abc&template=2&method=all&Committees=$Committees"); ?> Therefore, if the end of the include is [b]...&Committees=Example One"); ?>[/b] it will fail to show up. I believe that it is caused by the fact that I cannot use spaces when including a PHP file, but I have also tried with replacing the spaces with %20, and this also does not work. Any help would be gratefully received. Thanks, Neil Link to comment https://forums.phpfreaks.com/topic/183843-spaces-in-php-include/ Share on other sites More sharing options...
trq Posted December 3, 2009 Share Posted December 3, 2009 url_encode. Link to comment https://forums.phpfreaks.com/topic/183843-spaces-in-php-include/#findComment-970395 Share on other sites More sharing options...
howard-moore Posted December 3, 2009 Author Share Posted December 3, 2009 I have tried replacing it with: <?php include ("$domain/php-bin/councillors.pl?order_by=Surname&order=abc&template=2&method=all&Committees=', urlencode($Committees), '"); ?> and still getting no results. Any idea what I may be doing wrong? Link to comment https://forums.phpfreaks.com/topic/183843-spaces-in-php-include/#findComment-970398 Share on other sites More sharing options...
trq Posted December 3, 2009 Share Posted December 3, 2009 Any idea what I may be doing wrong? Using spaces in a url. There not valid, and neither is that last snippet of code you posted. Do you have access to change the perl script? Link to comment https://forums.phpfreaks.com/topic/183843-spaces-in-php-include/#findComment-970401 Share on other sites More sharing options...
cags Posted December 3, 2009 Share Posted December 3, 2009 urlencode is a function and as such it shouldn't be kept inside a string which is what your doing, just look at the highlighting... <?php include("$domain/php-bin/councillors.pl?order_by=Surname&order=abc&template=2&method=all&Committees=',urlencode($Committees), '"); ?> ..it should be.. include("$domain/php-bin/councillors.pl?order_by=Surname&order=abc&template=2&method=all&Committees=".urlencode($Committees)); Link to comment https://forums.phpfreaks.com/topic/183843-spaces-in-php-include/#findComment-970402 Share on other sites More sharing options...
howard-moore Posted December 3, 2009 Author Share Posted December 3, 2009 Cags and Thorpe - thanks very much indeed - working perfectly, and I have today learnt something very helpful indeed! Link to comment https://forums.phpfreaks.com/topic/183843-spaces-in-php-include/#findComment-970410 Share on other sites More sharing options...
trq Posted December 3, 2009 Share Posted December 3, 2009 Hehe, I hinted at your syntax issue but assumed it was just a typo in your post. Glad its working now though. Link to comment https://forums.phpfreaks.com/topic/183843-spaces-in-php-include/#findComment-970412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.