9, January 2009

anyone familiar with PHP switch, read this - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: anyone familiar with PHP switch, read this
« previous next »
Pages: [1] 2 Print

Author Topic: anyone familiar with PHP switch, read this  (Read 1088 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« on: Dec 20, 2005, 11:59:48 PM »

im using the php switch function to layout some pages of a new website im working on (www.tlove2.com Visit through proxy) which will serve as the placement page for premium hosting members to sign up as well as login.. but the switch function works fine on my website source server, but when i move them to my own server it stops working. i figure this is a problem in the php.ini or apache config files but does anyone have any idea what line should be uncommented?

sry not sure if this goes in PHP or Configuring your Server, believed PHP forum was best as the topic is about the function itself

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #1 on: Dec 21, 2005, 01:04:39 PM »

The problem is with sessions, not with switch. If you can give us some code it will be easier to help

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #2 on: Dec 21, 2005, 06:53:00 PM »

Code:
<?php switch($open) { default: include('home.txt'); 
break; case 
"1": include('test.txt'); 
break; case 
"2": include('http://www.tlove2.com/hosting/new.cgi'); 
break; case 
"3": include('http://www.tlove2.com/hosting/manager.cgi'); 
?>

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #3 on: Dec 21, 2005, 08:12:03 PM »

First of all if the $open varible is GET, you should check if your server has the registered vars enabled.

You can be sure about that by using this line in the beggining of your script :

Code:
<?php
$open 
$_GET['page'];

Another thing that you should check is the path of the includes. Doing something like this may help :


Code:
<?php
include './home.txt';

As a bottom line, I would suggest to enable error displaying in order to help you (or me) to find what the error is.


Code:
<?php
  ini_set
('display_errors'1);

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #4 on: Dec 21, 2005, 08:29:08 PM »

well im sure the paths are correct cus it works on website source server... here is my new php code:

Code:
<?php 
$open 
$_GET['page'];
ini_set('display_errors'1);
switch(
$open) { default: include('home.txt'); 
break; case 
"1": include('test.txt'); 
break; case 
"2": include('/hosting/new.cgi'); 
break; case 
"3": include('/hosting/manager.cgi'); 
?>

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #5 on: Dec 21, 2005, 08:37:40 PM »

The paths may not be correct, as there may be different include_path directive on each server.

Is this showing any errors?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #6 on: Dec 21, 2005, 08:41:55 PM »

not on the website no.. its still only showing the default page and the open pages like id 1 2 and 3 wont work..

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #7 on: Dec 21, 2005, 08:44:39 PM »

Oh. You must propably put the 'default' in the end of your code, like :

Code:
<?php 
$open 
$_GET['page'];
ini_set('display_errors'1);
switch(
$open) { 
 case 
"1": include('test.txt'); 
              break;
 case 
"2": include('/hosting/new.cgi'); 
              break; 
 case 
"3": include('/hosting/manager.cgi'); 
              break;
 default: include(
'home.txt'); 
            break;
?>


Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #8 on: Dec 21, 2005, 08:48:20 PM »

nope still opening default (which its supposed to) but no luck on the other pages

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #9 on: Dec 21, 2005, 08:50:06 PM »

Did you wrote it exactly as I wrote it above?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #10 on: Dec 21, 2005, 09:05:49 PM »

copy & pasted Cheesy

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #11 on: Dec 21, 2005, 09:12:52 PM »

OOopps.

Make this change and it will work :

Code:
<?php
$open 
$_GET['open'];

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #12 on: Dec 21, 2005, 09:27:25 PM »

cool it loads the test.txt file now, but i get these errors on the other 2 pages

Quote
Warning: main(/hosting/manager.cgi) [function.main]: failed to open stream: No such file or directory in C:\www\index.php on line 114

Warning: main() [function.include]: Failed opening '/hosting/manager.cgi' for inclusion (include_path='.;C:\php5\pear') in C:\www\index.php on line 114

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #13 on: Dec 21, 2005, 09:30:39 PM »

That's because you have different root paths in your servers.

Use something like :

include '../file.php';

or like :

include $_SERVER['DOCUMENT_ROOT'] . '/file.php';

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #14 on: Dec 21, 2005, 09:42:06 PM »

now it displays the CGI code instead of the actual page.

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #15 on: Dec 21, 2005, 09:46:43 PM »

You can't run a cgi script through php.

You should redirect the user to the cgi script instead of including the file.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #16 on: Dec 21, 2005, 09:55:46 PM »

this works fine on the WSS server tho, it opens the cgi file inside the layout and it works fine ?

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #17 on: Dec 21, 2005, 10:03:12 PM »

You can propably do this by changing your httpd.conf file, but I don't know how

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #18 on: Dec 21, 2005, 10:04:02 PM »

here is url to non-working CGI included script

http://tlove2.com/index.php?open=3 Visit through proxy

and url to working cgi included script

http://meth0d.justinlove.net/001/index.php?open=3 Visit through proxy
« Last Edit: Dec 21, 2005, 10:07:52 PM by meth0d420 »

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8357
43129 credits
Members referred : 3



« Reply #19 on: Dec 21, 2005, 10:11:23 PM »

What operating systems does those servers have?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=1033
Tags : forums apache linux php.ini httpd.conf Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] 2 Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: anyone familiar with PHP switch, read this
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jan 09, 2009, 07:09:42 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 38.657
Total Topics: 7.772
Total Members: 4.659
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: sardiniasarena

24 Guests, 4 Users online :

15 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2009 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.