SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: including file

  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    including file

    I tried including a webpage to my site and i get this error.

    Warning: include(chat/index.html?roomID=1&userName=mike4x4&avatarID=2) [function.include]: failed to open stream: No error in C:\Documents and Settings\Mike\Desktop\xampplite\htdocs\chat\chatharbour\windows.php on line 31

    Warning: include() [function.include]: Failed opening 'chat/index.html?roomID=1&userName=mike4x4&avatarID=2' for inclusion (include_path='.;C:\Documents and Settings\Mike\Desktop\xampplite\php\pear\') in C:\Documents and Settings\Mike\Desktop\xampplite\htdocs\chat\chatharbour\windows.php on line 31

    and this is part of my code:
    <?php
    include "chat/index.html?roomID=1&userName=mike4x4&avatarID=2";
    ?>

    anyone know why
    Animated Chatrooms - www.121chatrooms.net

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Try it without '?roomID=1&userName=mike4x4&avatarID=2'

  3. #3
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that works but i need the ?roomID=1&userName=mike4x4&avatarID=2' to be included in it so my script works properly
    Animated Chatrooms - www.121chatrooms.net

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    An include isn't a redirect. You can't send variables to it. Just define them in your script before you do the include.

  5. #5
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    To make things safe:
    PHP Code:
    <?php
    $GetBackup 
    $_GET;
    $_GET = array('roomID' => 1'userName' => 'mike4x4''avatarID' => 2);
    include(
    'chat/index.html');
    $_GET $GetBackup;
    But you really should have better application organistation - i.e. keeping classes and functions in files and being able to access them throughout the application, not by including a file.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  6. #6
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dosnt really work its liek the java didnt get the parametrs.
    Animated Chatrooms - www.121chatrooms.net

  7. #7
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript? It cannot read php variables.
    It can read the current url in it's own address bar though. If they aren't in the address bar, they don't exist as far as javascript is concerned.

  8. #8
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its not javascript its a java applet that reads from this page

    <HTML>
    <HEAD>
    <TITLE>Applet HTML Page</TITLE>
    <script type="text/javascript" language="javascript">
    var s1 = document.URL.split("?");
    var param = s1[1].split("&");
    var roomID = param[0].split("=")[1];
    var userName = param[1].split("=")[1];
    var avatarID = param[2].split("=")[1];

    document.write('<applet id=TypicalPlayerApplet name=TypicalPlayerApplet code="AvatarClient.class" archive="AvatarClientMike.jar" width=494 height=382>');
    document.write('<param name=roomID value=' + roomID + '>');
    document.write('<param name=userName value=' + userName + '>');
    document.write('<param name=avatarID value=' + avatarID + '>');
    document.write('</applet>');
    </script>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>
    Animated Chatrooms - www.121chatrooms.net

  9. #9
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure how this applet system works though, isn't this possible to have an .php page instead of .html (chat/index.php instead of index.html)? If so you can directly put those values in index.php itself.
    PHP Code:
    <?php
    $roomID 
    1;
    $userName 'mike4x4';
    $avatarID 2;
    ?>
    <HTML>
    <HEAD>
    <TITLE>Applet HTML Page</TITLE>
    <script type="text/javascript" language="javascript">
    document.write('<applet id=TypicalPlayerApplet name=TypicalPlayerApplet code="AvatarClient.class" archive="AvatarClientMike.jar" width=494 height=382>');
    document.write('<param name=roomID value=<?php echo $roomID;?>>');
    document.write('<param name=userName value=<?php echo $userName;?>>');
    document.write('<param name=avatarID value=<?php echo $avatarID;?>>');
    document.write('</applet>');
    </script>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  10. #10
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mike4x4s View Post
    its not javascript its a java applet that reads from this page
    See how your code sais script type="text/javascript"? That would be javascript. Notice how the javascript uses the URL on the first line?

    Yes, eventually this data gets fed to a java applet. But you use javascript to read the url/query string.


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
  •