Results 1 to 3 of 3

Thread: passing variables in a PHP include

  1. #1
    Join Date
    Jun 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default passing variables in a PHP include

    I have called a php include as follows but it doesnt seem to work...

    <?php
    include '../cms/blog.php?id=41234';
    ?>

    quite confused because the link within a href works fine... eg

    <a href="www.site,com/cms40/blog.php?id=41234">article</a>

    Can someone put me right ... Cheers

    i tried to use $_GET['id']=

    but no success..
    any help appreciated.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Try include ('../cms/blog.php?id=41234'); with the parentheses.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Jan 2015
    Posts
    78
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default

    An include/require statement reads the file through the file system (unless you specify a url using a protocol wrapper like http:// or ftp://). In this case, there are no $_GET variables from the end of the url, because this isn't a url, it's a file system path.

    Any variable that's present in the main file will be available in the included/required file. Where is the 41234 value coming from now?

Similar Threads

  1. setTimeout not passing variables
    By Oziam in forum JavaScript
    Replies: 3
    Last Post: 02-03-2011, 03:12 AM
  2. Passing RTE variables to PHP
    By steagu_ro in forum PHP
    Replies: 5
    Last Post: 09-22-2010, 12:05 AM
  3. passing variables without refresh
    By kat32 in forum JavaScript
    Replies: 1
    Last Post: 01-29-2009, 07:39 AM
  4. Passing variables to functions
    By city_coder in forum PHP
    Replies: 1
    Last Post: 05-27-2008, 01:59 PM
  5. Passing forward variables
    By Hannes in forum JavaScript
    Replies: 2
    Last Post: 03-29-2005, 09:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •