Welcome Guest, Not a member yet? Register   Sign In
Sending variables via URI string
#1

[eluser]evolutionxbox[/eluser]
Hello all!

I would like to send a controller a url variable via the uri string. I don't know how to do it because the forward slashed ruin the variable.

The anchor href:
"http://example.com/test/play/http://somesite.com/music.mp3"

This doesn't work, can anyone help?

...

Controller:
Code:
<?php

class Test extends Controller {

    function Test()
    {
        parent::Controller();
    }
    
    function index()
    {

    function play($url)
    {
        echo $url;
    }
}

View is blank (using controller to echo).
#2

[eluser]Bart v B[/eluser]
maybe i am wrong or don't understand youre question, but you can try the uri and the base_url() helper.

Code:
echo base_url().$this->uri->segment(3);

Or is it from an external site??
#3

[eluser]danmontgomery[/eluser]
You can't stick a URL in another URL, you have to encode it.

http://php.net/manual/en/function.urlencode.php
#4

[eluser]evolutionxbox[/eluser]
[quote author="noctrum" date="1271462617"]You can't stick a URL in another URL, you have to encode it.

http://php.net/manual/en/function.urlencode.php[/quote]

I thought so... but now it is flat out telling me the page doesn't exist.

An example url:
http://example.com/test/play/http://feed...1apr10.mp3

(Actual url of a real mp3 file encoded).
#5

[eluser]evolutionxbox[/eluser]
Example url was meant to be this:
Code:
http://example.com/test/play/http%3\A%\2F%\2Ffeedproxy.google.com%\2F%\7Er%2\Fcccpodcast%2\F%\7E5%\2F0BI0tSuWaJM%\2F11apr10.mp3

This forum keeps un-encoding the url... argh (remove the backslashes for the true url)!
#6

[eluser]evolutionxbox[/eluser]
Seriously I have no idea what to do.
#7

[eluser]Matthieu Fauveau[/eluser]
Try editing the config/routes.php and add something like :

Code:
$route['test/play/:any'] = 'test/play';

That should help Wink
#8

[eluser]evolutionxbox[/eluser]
[quote author="Matthieu Fauveau" date="1271482346"]Try editing the config/routes.php and add something like :

Code:
$route['test/play/:any'] = 'test/play';

That should help Wink[/quote]

I added:
Code:
$route['test/play/:any'] = 'test/play';

To the routes.php config file but nothing has happened, it comes up with:

Code:
Object not found!
...
Error 404
example.com
17/04/2010 01:35:43
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
#9

[eluser]Matthieu Fauveau[/eluser]
For your Apache error, see this : http://stackoverflow.com/questions/31180...gniter-app

Beside, I've just looked at your controller code again and what you've written would not output the URL anyway. You need something more like :

Code:
function play() {
echo $this->uri->segment(3);
}

Hope this is helping !
#10

[eluser]evolutionxbox[/eluser]
Thank you, you are helping... I will update this thread after making the changes tomorrow.




Theme © iAndrew 2016 - Forum software by © MyBB