SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  1. #1
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling in a file

    Hey,

    Having trouble calling in a file through javascript. I don't know any JS, but Wayne helped me out a little.

    I stick this in a page which can go anywhere on the internet:
    Code:
    <script language="JavaScript 1.2" src="http://www.filetrack.com/version.php?currentversion=<?=$currentversion?>"></script>
    And this is in version.php:
    PHP Code:
    <?php
    @include 'version.inc'
    echo 
    "Your Version: $currentversion\n";
    echo 
    "Newest Version: $newestversion\n";
    ?>
    <script language="JavaScript 1.2" type="text/javascript">
    <?php 
    echo ("document.write ('<!-- Version --><table><tr><td align=\"center\" bgcolor=\"#FFFFCC\">');\n");
    if (
    $currentversion != $newestversion) {      
        echo (
    "document.write('<strong>A newer version of FileTrack is now available.</strong>');\n"); 
        echo (
    "document.write('Your version: <strong>"$currentversion ." | </strong>Newest version: <strong>"$newestversion ."</strong>');\n");
        echo (
    "document.write ('&nbsp;<strong><a href=\"http://www.filetrack.com/\">Update Now<a></strong></td></tr></table> <!-- /Version -->');\n"); 
    }
    else { 
        echo (
    "document.write ('Version: <strong>"$currentversion ."</strong></td></tr></table><!-- /Version -->');\n");
    }
    ?>
    </script>
    No error, but the file doesn't get included, either. What gives?

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok...

    your script ouputs this... remember this is being called from a script element so this is not needed / needs to be altered slightly.

    PHP Code:
    Your Version1.0
    Newest Version
    1.1.0
    <script language="JavaScript 1.2" type="text/javascript">
    document.write ('<!-- Version --><table><tr><td align="center" bgcolor="#FFFFCC">');
    document.write('<strong>A newer version of FileTrack is now available.</strong>');
    document.write('Your version: <strong>1.0 | </strong>Newest version: <strong>1.1.0</strong>');
    document.write ('&nbsp;<strong><a href="http://www.filetrack.com/">Update Now<a></strong></td></tr></table> <!-- /Version -->');
    </script> 
    heres a quick example
    PHP Code:
      $latestversion 1.3;

      if ( isset(
    $_GET['version']) && $_GET['version'] != '')
      {
        echo 
    "
              output = 'current version = 
    $version<br />';
              output+= 'latest version  = 
    $latestversion';
             "
    ;

        echo 
    'document.write(output);';
      } 

  3. #3
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Waa?? I have no idea what you're talking about. In addition, there's no form. What's this Get stuff?

    Sorry if I'm ignorant. Just don't see what this has to do with anything.

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    remember your calling your script from this...

    heres the output of your script...

    http://www.filetrack.com/version.php?currentversion=1.0

    <script language="JavaScript 1.2" src="http://www.filetrack.com/version.php?currentversion=<?=$currentversion?>"></script>

    well you are repeating this when you outputing the content of your script ie it looks like this..

    Code:
    <script language="JavaScript 1.2">
    
    Your Version: 1.0
    Newest Version: 1.1.0
    <script language="JavaScript 1.2" type="text/javascript">
    document.write ('<!-- Version --><table><tr><td align="center" bgcolor="#FFFFCC">');
    document.write('<strong>A newer version of FileTrack is now available.</strong>');
    document.write('Your version: <strong>1.0 | </strong>Newest version: <strong>1.1.0</strong>');
    document.write ('&nbsp;<strong><a href="http://www.filetrack.com/">Update Now<a></strong></td></tr></table> <!-- /Version -->');
    </script>
    </script>
    As you can see there is no need to include the "script" element inside "your script" as your calling a your "php script to output javascript directly". Basically your outputting invalid javascript syntax.

    heres the output of my demo...

    http://andrewj.no-ip.com/geiger.html
    http://andrewj.no-ip.com/version.php?version=1.0

    get is basically getting this...

    currentversion=1.0 (http://www.php.net/manual/en/reserve....variables.get)

  5. #5
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Riiiiiiight. So what, exactly, do I need to replace my files with to get it to work?

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this...

    PHP Code:
    <?php
    @include 'version.inc'

    echo (
    "document.write ('<!-- Version --><table><tr><td align=\"center\" bgcolor=\"#FFFFCC\">');\n");
    if (
    $currentversion != $newestversion) {      
        echo (
    "document.write('<strong>A newer version of FileTrack is now available.</strong>');\n"); 
        echo (
    "document.write('Your version: <strong>"$currentversion ." | </strong>Newest version: <strong>"$newestversion ."</strong>');\n");
        echo (
    "document.write ('&nbsp;<strong><a href=\"http://www.filetrack.com/\">Update Now<a></strong></td></tr></table> <!-- /Version -->');\n"); 
    }
    else { 
        echo (
    "document.write ('Version: <strong>"$currentversion ."</strong></td></tr></table><!-- /Version -->');\n");
    }
    ?>

  7. #7
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No difference.

  8. #8
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Jason,

    Get rid of the @ in front of the include and see if it gives you any errors that might be helpful.

    Andrew, am I really seeing you doing PHP?

    Aaron
    Aaron Brazell
    Technosailor



  9. #9
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe, , I've been doing PHP for a long time now... However I only pop my head in the PHP forums every now and then:P It's been very rare for me to be on sitepoint lately as i've been busy with work and various other things, including building a framework in PHP beleive it or not

  10. #10
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    -@ didn't work.

  11. #11
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by geiger
    -@ didn't work.
    Right. I figured it wouldn't. What I figured though, is that it would return some kind of error? Nothing though?

    ~Aaron
    Aaron Brazell
    Technosailor



  12. #12
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sry I'm not looking in close detail, but I doubt it is that... try this quick test to make sure its included... comment out the rest of the code...

    <?php
    error_reporting(E_ALL);
    echo 'alert(\\'BOO!!!\\');';
    ?>

    [edit] damn sketch, you really have nothing better to do than stick around sitepoint do you lol. 5000 odd posts
    Last edited by Andrew-J2000; Feb 18, 2003 at 20:54.

  13. #13
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope. Put it in version.php. Told you it's not including. No alert. No error.

  14. #14
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It does work...

    <script type="text/javascript" src="http://www.filetrack.com/version.php?currentversion=1.0"></script>

  15. #15
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Perhaps taking the language attribute out.

    [EDIT: dang Andrew, don't you have another forum to post in?? ]
    Mike
    It's not who I am underneath, but what I do that defines me.

  16. #16
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [edit] see you have missed me while I have been away then
    Last edited by Andrew-J2000; Feb 18, 2003 at 21:12.

  17. #17
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FINALLY! it worked. I thought I tried every combination known to man, but I guess not. Thanks.

  18. #18
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The last thing you check is always the simplest.
    Mike
    It's not who I am underneath, but what I do that defines me.

  19. #19
    SitePoint Wizard geiger's Avatar
    Join Date
    Jul 2001
    Posts
    2,459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, tried javascript, JavaScript, JavaScript 1.2, taking out the whole statement, adding a type, taking both out, etc.

    As I said, the only combo I didn't try is the one that worked


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
  •