Passing variables errors in a nasty way! Is it PHP settings?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Passing variables errors in a nasty way! Is it PHP settings?

Post by robster »

Hello all, this is my first post.

I've installed many times php, mysql and apache (1.3x and 2.x) on my win2k home machine so I can do my dev testing at home before screwin up my server :)

On my original installation I managed to get it all down well with a foxserv installation but something went wrong, I uninstalled, re-installed (many times) and it kept erroring..

Here is the problem:

I have been using PHP to create a tables based page that has a menu on the left (which is included into a layout) and the content on the right (which is included into the same layout).

The way I do it is to pass a variable from my menu to the layout page which then places the content on the right according to the variable passed.

I presume this is a common way of doing things, as I'm a newby I was greatly impressed with this simple feature alone to make managing large sites simpler...

OK, back to the problem...

Now I've re-installed the software (apache/mysql/php) it all works fine except the ability to pass the variable and accept it to re-generate the page with the appropriate content.

Here is the code I use in my menu:

Code: Select all

<a href="layout.php?id=content.php">Link name</a>
Here is the code I use in my layout that accepts the $id variable. Note: it's placed in a table's cell for layout purposes...
I haven't included <? and ?> in any of these examples, please imagine they exist ;)

Code: Select all

$interview = "$id";
  	  include("$interview");
So that always worked fine.. the menu code would send the $id to the layout area which would turn it into whatever menu item i've clicked...


NOW THOUGH.. this is the error I get:


Warning: Failed opening '' for inclusion (include_path='.;C:/phpdev/php/includes;C:/phpdev/php/class') in c:\phpdev\www\layout.php on line 44


I should note I'm using a pre-setup package called phpdev... BUT, even if I do a full manual install of mysql/php/apache I still get a similar error with different paths...


ssoooooo.... Does any guru out there have an answer? I've wracked my brains, I've searched high and low, I just am about to give up (but can't, seeing as this PHP stuff is so liberating). I'd really appreciate any (ANY) ideas :)

Kindest regards,

Rob
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

1: is your server using wimp? wamp? what?

everything is more stable on a posix system than a windows system. if your sever uses posix you should too. most don't use windows/apache (wa) but windows/iis (wi)

if they have apache on your server, it's probalby linux/apache (la)

i'm far from a php guru, but i wanna say windows is the issue (maybe it's becasue i really dislike windows because i've yet to find a version that has the stability of linux/unix
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

On the webserver they use redhat with apache etc...

The problem I'm having is at HOME... so yes, at home I use apache so that it is the same as my host.

I'm not sure about wimp/wamp etc, I don't even know what that is. I really am a newby but am getting used to editing php.ini etc etc....

I will be sticking with windows as I need it for my other apps (for now ;) ).

Any help would be appreciated re: my question :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you read this:
Before Post Read: Concerning Passing Variables in PHP 4.2+

You probably need to change:

Code: Select all

$interview = "$id"; 
include("$interview");
to

Code: Select all

$interview = $_GET['id']; 
include($interview);
although do be sure that you include some validation of the page to be included else you are going to have a very easy to hack site.

Mac
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

development environment.. i've always seen it abbreviated by:

operating system
webserving software
database (if applicable)
scripting language (if applicable)

so wimp is windows iis mysql php
wamp is windows apache mysql php
lamp (what your host is) is linux apache mysql php

i suggest getting a second computer for your home server, or if your home server and your personal computer are differnt then backing up your sever and reformatting it to what you should have: lamp

always develop int eh delopment environment if possibl. it's easy to find places on the net that refurbish computers. you can get a 300 mhz/400mhz p2/p3 for $100-$200 and you can get red hat 9 for free by dling it. for $100 you can pretty much have your development environment mimic your deployment one. there's no reason not to do that. you'll have it twaeked better and when you do stuff for people that hire you it helps too

redhat will also automatically installl the following as options for the server (i know because i recently dled 9 and did that. i just upgraded parts of an old pentium 1 pre mmx first... like the hard drive and i installed a network card)

apache: 2.0.40
php 4.2.2
mysql 11.18 dist 3.23.56
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

DOH!

I was reading that as you posted your comments..
Thanks so much, your direct reply saved me about half an hour of trial and error.

It worked a charm. Sorry to all that I didn't read it first.

I DO have another problem though...

I have been trying to install misc scripts for news serving (mini slashdot style for my site).

I'm not sure what they are all using in their scripts and if it's related, but all of them give these kind of errors:

Fatal error: Failed opening required 'News/config.php' (include_path='.;C:/phpdev/php/includes;C:/phpdev/php/class') in c:\phpdev\www\news\news.php on line 28


Now is this the same thing? If it is I don't want to go and edit the many many php files that come with these various news scripts I want to trial. If they worked in an older version of php surely there is a setting I can switch to make it work now?

It's just a thought anyway.

Again, I'd REALLY like to thank you all (especially twigletmac) for their help...

Rob
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

twig's popped into a few of my threads.. normally really short but extremely insightful/helpful posts. i'd say he and neilsene are the ones you wanna see appearingin your threads. they both seem to be on top of what's going on here and definitely help a lot of people.
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

quick answer to the second problem of mine...

I didn't have my document serving root in my php.ini file..!! (ggrrrRR)
I added C:/phpdev/php/class to the end of the path and hooray!!! It works.

Thanks so much everyone...
Post Reply