www.webdeveloper.com
Results 1 to 9 of 9

Thread: Noob question re: proper syntax

  1. #1
    Join Date
    Nov 2003
    Location
    L.A.
    Posts
    36

    Noob question re: proper syntax

    Hello, I'm setting up a simple poll on my pages but I need the number ID to change dynamically depending on what page you are on, here's the script:

    Code:
    <?php
    if (!isset($_COOKIE['voted1'])){
    include('poll1.inc.php'); }
    else {
    include('results1.inc.php'); }?>
    The page ID code is:

    Code:
    <?php the_ID(); ?>
    I tried

    Code:
    include('poll<?php the_ID(); ?>.inc.php'); }
    and a million variations to get it right but to no avail. I couldn't do a proper search on this question, I don't quite know how to word the query.

    Any help would be monumentally appreciated. Thanks in Advance!!

  2. #2
    Join Date
    Apr 2005
    Location
    Bathurst, NSW, Australia
    Posts
    3,357
    Your already in the php parser so you dont need to call it again with <?php. Just do this. now obviouly this doesnt actually answer your question to a dynamic number per page thingy - this just pulls a file with whatever number (or string) is returned from that function
    PHP Code:
    include('poll'.the_ID().'.inc.php'); } 

  3. #3
    Join Date
    Nov 2003
    Location
    L.A.
    Posts
    36
    b_g:

    Thank you for the quick and knowledgeable reply - your suggestion was tried but resulted in an odd error:

    Code:
    1
    Warning: main(results.inc.php) [function.main]: failed to open stream: No such file or directory in . . .
    etc., etc.

    What's odd is that the string in question "1" appears just before the warning but does not appear as it should between the include request e.g. results-"1"-.inc.php. Regardless you've taken me one step closer to my goal and I do appreciate it! Do you see an obvious oversight on my part

    Code:
    <?php
    if (!isset($_COOKIE['voted1'])){
    include('poll'.the_ID().'.inc.php'); } 
    else {
    include('results'.the_ID().'.inc.php'); } 
    ?>
    PS, the_ID is the page numbers so this would work perfectly, if . . . it . . . worked . . . perfectly.

  4. #4
    Join Date
    Apr 2005
    Location
    Bathurst, NSW, Australia
    Posts
    3,357
    maybe you can test the file name first by echo it out so that you can see that the the_ID function is returning the correct value.
    echo the_ID();
    If it is correct - does the file exist? eg. poll1.inc.php etc?

  5. #5
    Join Date
    Nov 2003
    Location
    L.A.
    Posts
    36
    Yes, the file is there. Must be Murphy's Law.
    Last edited by BaileyBoy; 10-22-2006 at 09:13 PM. Reason: Moderator took my original comments as a resolved issue, it's not.

  6. #6
    Join Date
    Oct 2005
    Location
    Gold Coast, Australia
    Posts
    2,115
    Marked Resolved.

  7. #7
    Join Date
    Nov 2003
    Location
    L.A.
    Posts
    36

    Exclamation This is not Resolved - can you Undo that Mr. PC Thug?

    I would love if you un[RESOLVED] this. I still require assistance.

  8. #8
    Join Date
    Oct 2005
    Location
    Gold Coast, Australia
    Posts
    2,115
    Sorry, your previous post was very misleading. Marked Unresolved.

  9. #9
    Join Date
    Nov 2003
    Location
    L.A.
    Posts
    36
    Thanks for undoi'g that!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles