Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,666 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,152 people online right now. Registration is fast and FREE... Join Now!




PHP Easy URL Problem

4 Pages V  1 2 3 > »   
Reply to this topicStart new topic

PHP Easy URL Problem

duffsstuff
post 7 Aug, 2007 - 11:03 AM
Post #1


D.I.C Head

**
Joined: 10 Sep, 2006
Posts: 67


My Contributions


I am trying to make a clean URL script for my website and I have coded the base of what I need but I have come accross 3 error and I don't know how to fix them. Here are my errors:

Notice: Undefined index: PATH_INFO in /homepages/cleanurl.php5 on line 57
Notice: Undefined offset: 0 in /homepages/cleanurl.php5 on line 61
Notice: Undefined offset: 1 in /homepages/cleanurl.php5 on line 62

I have put in my code where the errors are. The beginning of the line with an error has: '{{line#}}'

CODE

/*
|---------------------------------------------------------------
| Clean URL's
|---------------------------------------------------------------
|
| Allows the script to make make clean URL's.
|
| Example:
| http://www.domain.com/index.php/pages/home
|
*/    
{{57}}        $path_info = $_SERVER['PATH_INFO'];
    $clean_url = explode('/',$path_info);
    array_shift($clean_url);

{{61}}    $GLOBALS['action']    = $clean_url[0]; // This is our action
{{62}}    $GLOBALS['name']    = $clean_url[1]; // This is our action's name
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 7 Aug, 2007 - 11:24 AM
Post #2


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


With mod_rewrite you can capture http://www.domain.com/index.php/pages/home and forward them to http://www.domain.com/index.php/pages/home....php?u=whatever but in the address bar www.yoursite.com/xmod will be showing (the user wont know they're not at the other URL).With mod_rewrite in the .htaccess file you could add

CODE

RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?u=$1


Now with this instead of typing [http://www.domain.com/index.php/pages/home....php?u=whatever (or whatever you're trying to change to a clean URL) you can type http://www.domain.com/index.php/pages/home and both will take you to the same place.

Remember this is done in .htaccess file

This post has been edited by PsychoCoder: 7 Aug, 2007 - 11:25 AM
User is offlineProfile CardPM

Go to the top of the page

duffsstuff
post 7 Aug, 2007 - 11:33 AM
Post #3


D.I.C Head

**
Joined: 10 Sep, 2006
Posts: 67


My Contributions


I know about the .htaccess file, But I need something that will work with any type of server that runs PHP, like how CI uses URL's.
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 7 Aug, 2007 - 12:21 PM
Post #4


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


Heres some information on using mod_rewrite in IIS

mod_rewrite In IIS

User is offlineProfile CardPM

Go to the top of the page

duffsstuff
post 7 Aug, 2007 - 12:29 PM
Post #5


D.I.C Head

**
Joined: 10 Sep, 2006
Posts: 67


My Contributions


mad.gif I don't want to use mod_rewrite!!!! I want to use PHP!!!

Please help me fix the errors in my script, Please. I don't want to use mod_rewrite. I don't need to hear about how to use something I don't want to use. I know how to use it but don't want to for this script, it just isn't going to work for this script.

Sorry, I usually don't get mad but if I wanted to use mod_rewrite I would of used one of the ten thousand tutorials on the internet.

Can someone please help me with my script and not trying to pull me into something I don't want to use? mad.gif
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 7 Aug, 2007 - 12:31 PM
Post #6


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


QUOTE(duffsstuff @ 7 Aug, 2007 - 01:29 PM) *

mad.gif I don't want to use mod_rewrite!!!! I want to use PHP!!!

Please help me fix the errors in my script, Please. I don't want to use mod_rewrite. I don't need to hear about how to use something I don't want to use. I know how to use it but don't want to for this script, it just isn't going to work for this script.

Sorry, I usually don't get mad but if I wanted to use mod_rewrite I would of used one of the ten thousand tutorials on the internet.

Can someone please help me with my script and not trying to pull me into something I don't want to use? mad.gif


Theres no reason to be an ass! You asked for help, I fucking offered it! mod_rewrite IS THE BEST SOLUTION for what you want.

<edit>Its quite obvious your idea isn't working, otherwise you wouldn't be here asking for help!</edit>

This post has been edited by PsychoCoder: 7 Aug, 2007 - 12:32 PM
User is offlineProfile CardPM

Go to the top of the page

duffsstuff
post 7 Aug, 2007 - 12:37 PM
Post #7


D.I.C Head

**
Joined: 10 Sep, 2006
Posts: 67


My Contributions


I do thank you for the help, but it is not what I am looking for. I am sorry I have been up for about 40 hours working on my program and really just wanted some help. I know that mod_rewrite would be the best answer but I just want to do it in PHP instead. I would like some help fixing the errors in my script. I am sorry that I got mad.
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 7 Aug, 2007 - 12:38 PM
Post #8


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


And I offered you a clean, efficient (actually best solution for your problem) and you jumped down my throat so find your own goddamn solution! If you actually "knew" mod_rewrite you'd KNOW its the best solution for your problem. So have fun finding a solution smile.gif
User is offlineProfile CardPM

Go to the top of the page

duffsstuff
post 7 Aug, 2007 - 12:44 PM
Post #9


D.I.C Head

**
Joined: 10 Sep, 2006
Posts: 67


My Contributions


Thanks for the help? I am sorry. Is there anyone that understands what I want to do that can help? I really just need my errors fixed and I don't know what is wrong with my code other then what the errors gave me and I don't know how to fix it.
User is offlineProfile CardPM

Go to the top of the page

duffsstuff
post 7 Aug, 2007 - 12:51 PM
Post #10


D.I.C Head

**
Joined: 10 Sep, 2006
Posts: 67


My Contributions


So what I want to do is have my PHP script interpret this:
http://www.domain.com/index.php/pages/home

Instead of having:
http://www.domain.com/index.php?action=page&id=home

I have the logic that will get the correct page based on the variables the script I posted returns. If anyone wants to see that logic just ask and I will post it, but it hasn't returned any errors when I tested it and it seems almost independent from what I posted.
User is offlineProfile CardPM

Go to the top of the page

Xmod
post 7 Aug, 2007 - 12:57 PM
Post #11


New D.I.C Head

*
Joined: 19 Jan, 2007
Posts: 35


My Contributions


Use mod_rewrite man! thats the best logic solution....
User is offlineProfile CardPM

Go to the top of the page

duffsstuff
post 7 Aug, 2007 - 01:03 PM
Post #12


D.I.C Head

**
Joined: 10 Sep, 2006
Posts: 67


My Contributions


Thanks, but I really want to use PHP. Can you help me debug my code?
User is offlineProfile CardPM

Go to the top of the page

4 Pages V  1 2 3 > » 
Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:52AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month