last day (14 days later) » 

9:55 AM
0
A: Internal Server Error when trying to check url

Tirthraj BarotYou can simply use explode() function to break the string... .Or else $_SERVER[REQUEST_URI] shall give you the data after the host name... But for the data after the last '/' explode function will work the best.. This will work. $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $x = ex...

 
Still the same 500 error. Thanks for trying though :)
 
I ain't getting that error in your code as well... Try to comment the if statement completely.. I suspect its because of that require statement.
 
I need the if statement to check the $data. EDIT: If I comment out the require it still throws the error
 
Oh certainly... just comment it to check for debugging purpose... because i suspect the error to be somewhere else.. and not in this codesnippet you posted as well..
 
It shows the $data perfectly fine. It just doesn't work with an if statement?
 
9:55 AM
I guess the error lies in your require_once VIEW_ROOT . '/cp/dashboard_view.php';
 
Like I said, if I comment out the require_once it still throws the error
 
Can you try to make a new different file?
 
Sure, hold on
Alright, I think that the issue is a little different
 
whats happening?
 
I'm trying to pass data after the trailing slash to the file before the trailing slash.
I think that the file before the trailing slash is not even loaded to get the data
 
9:59 AM
cause I tried it in php fiddle and its working without error...
see...
<?php
$url = "http://www.google.com/name/tirthraj";
$x = explode('/',$url);
$data = $x[sizeof($x)-1];
echo $data;

?>
I wrote it in phpFiddle.org and tested it..
It returns tirthraj in $data
 
I know, that works.
 
Is that not what you wanted Chris?
 
But when I try to go to the url MYURL/file/data to then show 'data' it doesn't
That's what I need
So, when the url is MYURL/file it should just show the normal page
 
what architecture are you using?
 
And when the url is MYURL/file/data the 'file' file should get that 'data' variable and show a different page
OOP
 
10:02 AM
codeigniter?
 
I don't know what that is
 
alright.. .there are 2 approaches in programming... Procedural and Object Oriented....
 
Right I'm using OO
 
And framework is something where in you code under certain bounded environment..
 
Aha, you mean my IDE
 
10:04 AM
So if you are a fresher in php you should go for code igniter or yii
nope... The frameworks...
 
Ahh, nvm
 
Because the kind of need you just put up in the question... is exactly what these frameworks provide
that makes your work more modularized and easy..
 
Aha, well I check that then
Thanks
 
and without that, this kind of approach that you are following... the '/' thing, its called the RESTful APIs..
 
Aha
 
10:06 AM
and in our core php environment, the data shall be passed as MYURL/file.php?var1=data1&var2=data2
and you get them in your page as $_GET['var1'] $_GET['var2']
which i suppose you will certainly have the knowledge of..
 
Jup
 
Alright Chris... Kindly vote me up or mark me correct if you feel that i helped well or if i deserve...
 

last day (14 days later) »