Include Funtion Php Problems - in xammp and php 5.1.1

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #11) by dwayne12 on May 9 2007, 08:24 AM. (Line Breaks Removed)
Someone has already answered this question it's simple.$id".php";You have to seperate the variable value from the actual text.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Include Funtion Php Problems - in xammp and php 5.1.1

sxyloverboy
Hi,
I just recently installed the latest versin of XAMMP on my computer which comes with php5.1.1 and i have been noticing some problems with the include(); funtion. This is a code that worked fine on trap17 hosting so I am thinking it has something to do with the php version of 5.1.1 since trap17 uses 4.3.X.

Now what the actual problem is is using the variables in the include function. If i have a normal include sentence like this one:
CODE
include "hello.php";
then it works fine but as soon as i start using variables it somehow dosent work at all.

I have already tried a variety of diffrent ways to write the include sentence but they all dont work !!
CODE

include("$id.php");
include "$id.php";
include "$id" . ".php";
include ("$id" . ".php");


But they all dont seem to work. The error message im getting is this one:
QUOTE
Warning: include(.php) [function.include]: failed to open stream: No such file or directory in C:\Apache\xampp\htdocs\lasttry\index.php on line 117

Warning: include() [function.include]: Failed opening '.php' for inclusion (include_path='.;C:\Apache\xampp\php\pear\') in C:\Apache\xampp\htdocs\lasttry\index.php on line 117


So it looks like php is completely ignoreing the part with the variable because it tries to load only a stupid file called .php

I set the variable in my url like this ...index.php?id=home


Maybe someone can help me?

 

 

 


Reply

Tyssen
Shouldn't that be include $id.".php" ?

Reply

shadowx
I had almost the same problem. I solved it like this:

QUOTE

$id = $_POST['id'];
include("$id.php");


That worked for me. It was weird because on my previous host it worked without the first line but on my localhosts with a PHP interpreter running it didnt, so I tried that and it worked. You could also try something like

QUOTE

$id = $id + ".php";
include($id);


but im not sure about that. Your PHP script is basically saying that $id is empty so by doing the first thing (using $_POST['id']; ) it should work fine smile.gif

EDIT: I'm using XAMPP too so maybe its the PHP version or just the interpreter

 

 

 


Reply

jlhaslip
Here is a version of a script which I use to set the include from a query string. Notice that I check to see if the file exists and it also checks an array of acceptable values otherwise the include is set to index.txt as a default.

CODE

$submit = $_GET[page];

if( !isset($_GET[page]) ) {
if (file_exists($data_array[0] . '.txt' )) {
include ( $data_array[0] . '.txt' );
}
else {
include ('index.txt');
}
}
elseif (in_array($submit , $data_array)) {
if (file_exists($submit . '.txt' )) {
include ( $submit . '.txt' );
}
else {
include ('index.txt');
}
}
else {
if (file_exists($data_array[0] . '.txt' )) {
include ( $data_array[0] . '.txt' );
}
else {
include ('index.txt');
}
}
?>


Reply

sxyloverboy
hehe cool thanks guys. that really helped. I think that the new version dosent make the _GET variables into normal variables and that the older version does. or maybe theres an option for that i dont know. but there is a technical term for it too.

I know my files are going to exist because this is for a menu and it would be stupid if i had a menu but no sites to go with it tongue.gif. thanks guys biggrin.gif

EDIT: ...IF there is an option for pho to automaticly make the get variables normal variables. does anybody know where i can set it?

Reply

jlhaslip
check out the "extract" function. extract().

Reply

Hamtaro
QUOTE
IF there is an option for pho to automaticly make the get variables normal variables. does anybody know where i can set it?

I think you are talking about auto globals. If you are, in your php.ini file (I'm not sure where it would be for you), there should be something like:
QUOTE
register_globals = Off

If so, just change Off to On, and things like $_POST['test'], $_GET['test'], etc. would be $test.
Once you've changed it, you'll have to restart the server. I've forgotten how XAMPP is set up, so that's all that I can tell you.

Reply

Tyssen
QUOTE(Hamtaro @ Apr 16 2006, 12:47 PM) *

If so, just change Off to On, and things like $_POST['test'], $_GET['test'], etc. would be $test.

I'd only do that if you know you're going to be able to do the same on your live site. No point doing something on your local machine only to find the server you've chosen to host your site won't let you do the same.

Reply

Hamtaro
If the script is going to be used with Trap17, then it wouldn't hurt turning on auto globals on the local machine. Trap17 has auto globals (and a few other things I believe) turned on.

Reply

jlhaslip
But Tyssen's point is work considering. If you can do something without using the Global variables, your site will be more secure. They are set to be off for a reason on most Hosts.

Reply

Latest Entries

dwayne12
Someone has already answered this question it's simple.
$id".php";

You have to seperate the variable value from the actual text.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Similar Topics

Keywords : include, funtion, php, problems, xammp, php, 5, 1, 1

  1. Php Problems
    Clan Web site Problem (3)
  2. Problems With Data Formatting
    (2)
    I have a MySQL database which stores articles. A sample article would look like this: CODE This
    is a body. This is a body.This is a body.This is a body.This is a body.This is a body.This is a
    body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
    is a body.This is a body.This is a body.This is a body. This is a body.This is a body.This is a
    body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
    is a body.This is a body.This is a body.This is a body.This is a body. That'....
  3. Problems With Php
    (5)
    Recently, my system was infected by a Trojan Horse. Since then, I've been finding files missing
    and now my PHP will not work, my Apache server will not display PHP files, i've tried getting
    rid of the files in my C:\Windows and C:\Windows\system32 folders but nothing is
    working. (it comes up with 'file in use') All help greatly appreciated.....
  4. Preg_replace Problems
    (7)
    Sigh... preg_replace is getting very annoying for me. Could sombody tell me what I'm doing
    wrong? Im making a bbcode replace for the forums I made, and preg_replace is being a b****...
    Right now Im working on the tag, and I want to check for valid URL's, because idiots in the
    forum are adding js and stuff in the image tags and messing it all up. So i put a function in the
    array that holds all of the replacements: CODE
    $main_search=array('/\[b\](.*?)\[\/b\]
    /is','/\[i\ ....
  5. Mysql Authentication Problems
    (11)
    I installed the new version of both php and mysql on my computer and I am trying to work on a
    database. The problem is the following. Even though I have the latest version of both php and mysql,
    and I have created users in the new mysql version, I still get the problem that I get an error
    message about authentication problems. I have no clue what I am doing wrong. It did work for a short
    period of time, but somehow it is no longer working. Is there anyone who has a tutorial on how to
    install both php and mysql? I have the feeling that there are a lot of settings in my.in....
  6. Odbc Form Problems
    (0)
    Hy everyone! I am moderately familiar
    with PHP and have been using it for a couple years for various different things.
    Basic information about my system:
    PHP 5 MySQL 4.1 Apache Windows XP Pro I'm using
    PHP/MySQL for a web-based server and have an ODBC set up in my office. I'm running into some
    problems using the ODBC code as opposed to the MySQL code in some scripts I ha....
  7. Phpnuke Newsletter Sending Problems
    (0)
    i have a problem sending newsletters....when i send them no1 receives it...i tried sending to the
    registered users on my site which im in and i didnt recieve it in my mail...i dont know why this is
    happening...it says the newsletter is sent...but we get nothing in our mail... heres the code
    QUOTE /************************************************************************/ /* PHP-NUKE:
    Web Portal System */ /* ===========================
    */ /* ....
  8. Major Problems With Php Script
    Hold on for this one! (8)
    Okay, so I got a php script for my site called php Bible. So I get it and go to install it, and
    then the problems start. You see it uses php, dud, to search and view scripture. So here are the
    instructions: QUOTE 1) Upload the files to a useful place inside your web server's
    document tree. 2) Change the things that look wrong in config.php. 3) Make sure "AcceptPathInfo
    ON" (or analogous) is somewhere in your PHP file section of your web server config. 4) Go over
    steps 2 and 3 again, because you probably missed something for lack of documentation. So....
  9. Problems With Php Form?
    Can you please help? (7)
    I am trying to install a PHP form. I am using a tutorial I found in the tutorials section. It was
    really good, but I have a few problems. Here is the link, if you need it:
    http://www.trap17.com/forums/index.php?sho...ic=8118&hl=form Anyway, so I place the mailform.php
    in an html document on file manager right? So I do that. And I put it in the body: CODE
    <?php $Name = $_POST['Name']; $Subject =
    $_POST['Subject']; $Email = $_POST['Email'];
    $Site = $_POST['Sit....
  10. <? Include ?> Problems
    (4)
    Well, I'm new to PHP, and I get tons of problems when I use the include tags: Let's say my
    site is www.mysite.com, and the menu is www.mysite.com/menu.htm. The site I want to include menu.htm
    in is not in the same folder as menu.htm, but in "folder2": www.mysite.com/folder2/index.php The
    images in menu.htm are located in it's own folder: www.mysite.com/images. However, when I load
    index.php with , the images won't load. Then I try to check the image location and it says that
    the images that didn't load was located in www.mysite.com/folder2/images ....
  11. Browser Problems, Maybe?
    Firefox vs IE (6)
    Alright, I coded something the other day for the game I am working on making, and a few of my
    friends I allowed to get on it and test things out. Well....the ones that were on IE their
    characters were made but the User variable as in which account they were on just stayed blank, while
    with my friends that were on Firefox, everything worked fine and they could play perfectly... So I
    was wondering, with PHP sql codes being sent to the database, is there something special you have to
    do to make it work on both, or could it be a setting on the IE that was messing with it......
  12. Postnuke Install Problems On Subdomains
    (1)
    I'm trying to install PostNuke on a empty server I allready got PostNuke downloaded and uploaded
    the downloaded files to the server but I can't get it to work. I'm trying to do this on 2
    servers both are sub-domains and both support php. One of them has a MySQL database and MyAdmin but
    I can't find them anywhere on the sub-domain. I'm pretty new to this and any advise would be
    more then welcome to me. I tryed looking for a MySQL database to install but when I do I get
    something like 30 different versions and don't know whitch one I need I tryed th....
  13. Php And Gd Tutorial
    I'm having problems (6)
    I am trying to learn PHP and was wondering what is wrong with the tutorals on this site:
    http://www.phpfreaks.com/tutorials/105/1.php I copied the code between the body tages in my site,
    and am returned with an error regarding headers. Does anybody why this is?....
  14. Problems With Apostrophes [ ' ] In Php
    (4)
    Yes I have another problem. I have a blog that I made with php and mysql. It's working just
    fine except for the text being displayed on the page. Everytime there's an apostrophe
    encountered, *something puts a slash before it. It's fine in the database only the page.
    Probably a problem with PHP. I hope you understand what I say. Here's a sample line displayed
    in my blog: -- It\'s Saturday but I\'m still in the office. -- ....
  15. Ftp Script Problems - Authentication Failure
    (3)
    I uploaded the code as a text file because it's pretty big: http://beeseven.trap17.com/ftp.txt
    As I said it can't login. I get this error: Warning : ftp_login(): Authentication failed,
    sorry in /home/beeseven/public_html/ftp.php on line 45 I think it might have something to do
    with character encoding, but I'm not sure. If you think it is, what kind of encoding would work
    as if I typed it directly? I tried putting it in the file, but then I got the missing required
    fields error.....
  16. Mysql Relational Problems
    (3)
    didn't know where to post this but since I build this database with php, I post it here. I have
    to build a relational database 4 a school project. Made a webbased interface and made a database
    with primary&foreign keys and not null fields to preserve the integrety of my database. -When I
    insert an empty field or I just don't give the field where the field has the property NOT NULL
    it just fills in nothing or some default value (it ignores the not null property). -When I insert 2
    rows with the same primary key in the same table it doesn't throw an error but ....

    1. Looking for include, funtion, php, problems, xammp, php, 5, 1, 1

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for include, funtion, php, problems, xammp, php, 5, 1, 1

*MORE FROM TRAP17.COM*
advertisement



Include Funtion Php Problems - in xammp and php 5.1.1



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE