Results 1 to 8 of 8

Thread: PHP help

  1. #1
    TOO KEWL NoWAyItZTOMmY's Avatar
    Join Date
    Jul 2006
    Location
    where ever my car drives me to
    Age
    32
    Posts
    2,451
    Rep Power
    21

    Default PHP help

    okay need some help with php. i am trying to create a link '/index.php?id=dvd'
    where dvd would be the page with the info, but i am getting

    Warning: include(.txt) [function.include]: failed to open stream: No such file or directory in

    and i am using the code '<?php include ("$id.txt"); ?>' for this

    what code do i use to have id=dvd pull up that file

  2. #2
    Senior Member
    Join Date
    Aug 2005
    Location
    Atlanta, GA
    Age
    40
    Posts
    3,275
    Rep Power
    22

    Default

    Well it looks like you are trying to use $id as a variable. Is that variable being passed from another page? Basically what you would have to do is pass the variable to this search result basically telling $id = (Whatever id number you put in the search bar).

    Hope this helps.

  3. #3
    TOO KEWL NoWAyItZTOMmY's Avatar
    Join Date
    Jul 2006
    Location
    where ever my car drives me to
    Age
    32
    Posts
    2,451
    Rep Power
    21

    Default

    okay i have a site with the main page index.php with a blank section, then when i click link
    <a href="index.php?id=1">lala</a>

    id=1 would open the same index.php but with the info it calls for from 1, 2, 3, ect ect.

    what code would it be to use, i thought it would be
    <?php include ("$id.txt"); ?>

  4. #4
    Senior Member
    Join Date
    Aug 2005
    Location
    Atlanta, GA
    Age
    40
    Posts
    3,275
    Rep Power
    22

    Default

    Oh ok I see now.

    Try to single quote it.

    so <?php include('$id.txt') ?>

    PHP can be retarded sometimes...

    Let me know if that works for you.

  5. #5
    TOO KEWL NoWAyItZTOMmY's Avatar
    Join Date
    Jul 2006
    Location
    where ever my car drives me to
    Age
    32
    Posts
    2,451
    Rep Power
    21

    Default

    naw didnt happen

  6. #6
    Senior Member
    Join Date
    Aug 2005
    Location
    Atlanta, GA
    Age
    40
    Posts
    3,275
    Rep Power
    22

    Default

    Hrm its not passing the variable for some reason.

  7. #7
    BYAAAAAAAHHH!!! threehundred's Avatar
    Join Date
    Nov 2002
    Location
    22" off the ground
    Age
    44
    Posts
    2,712
    Rep Power
    24

    Default

    You have to first grab the $id variable from the URL using the GET function.

    Near the top of the page (preferably in the <head> tags) add this:

    <?php
    $id = $_GET['id'];
    $id = $id . ".txt";
    ?>


    Then down where you want the content to be you do the include. The include should be structured this way (assuming the files to be included are something like 1.txt or 2.txt):


    <?php
    include($id);
    ?>
    05 Chrysler 300 - Kitted on 22s
    06 Quad Cab Dodge Ram 1500

  8. #8
    Senior Member
    Join Date
    Aug 2005
    Location
    Atlanta, GA
    Age
    40
    Posts
    3,275
    Rep Power
    22

    Default

    Quote Originally Posted by threehundred View Post
    You have to first grab the $id variable from the URL using the GET function.

    Near the top of the page (preferably in the <head> tags) add this:

    <?php
    $id = $_GET['id'];
    $id = $id . ".txt";
    ?>


    Then down where you want the content to be you do the include. The include should be structured this way (assuming the files to be included are something like 1.txt or 2.txt):


    <?php
    include($id);
    ?>

    Shows how long I haven't messed with PHP, I was at least right about it not retrieving the variable. Just forgot about the GET command

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
ImportAtlanta is a community of gearheads and car enthusiasts. It does not matter what kind of car or bike you drive, IA is an open community for any gearhead. Whether you're looking for advice on a performance build or posting your wheels for sale, you're welcome here!
Announcement
Welcome back to ImportAtlanta. We are currently undergoing many changes, so please report any issues you encounter with the site using the 'Contact Us' button below. Thank you!