Jump to content

WriteGreatCode

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Posts posted by WriteGreatCode

  1. The example you provided is running fine.

     

    However, I want to display the contents of a file. :(

     

    <?php
    $fh = fopen("example.txt", "r");
                  while (!feof($fh))
                  {
                           $line = fgets($fh);
                           $file = $file . $line;
                  }
                    fclose($fh);
    echo "<script type='text/javascript'>alert('{$file}');</script>";
    ?>
    

     

    but the alert box is not appearing...can u suggest sumthin?  :'(

     

    It seems that it only works if there's only one line in the file. Maybe the hidden \r\n character (it is used in edit controls in the C++ Win32 API, which is what Notepad.exe was made in, for a new line) in the text is messing it up. Because I can echo it to the screen fine:

     

    <?php
    $fh = fopen ("example.txt", "r");
    while (!feof ($fh))
    {
         $file = $file . fgets ($fh) . "</br>";
    }
    fclose ($fh);
    echo $file;
    ?>

     

    Just not use the alert function =/

     

    So, not sure on this one, maybe someone else can help you out.

  2. does alert function have to defined in the php page? :shrug:

     

    alert is pre-defined rite?

     

    echo "<script type='text/javascript'>alert('{$variabl}');</script>

     

    the alert box does not appear...

     

    alert if a Java Script function, so it doesn't have to be defined on the PHP page. And what he said works fine besides the fact that he forgot the ending quote after </script>

     

    <?php
    $Text = "Hello World!";
    echo "<script type='text/javascript'>alert('{$Text}');</script>"
    ?>

     

    haha we both messed up, you forgot a ; at the end..

     

    sorry btw @OP I can't really see too well you have to pardon my crappy help :)

     

    <?php
    $Text = "Hello World!";
    echo "<script type='text/javascript'>alert('{$Text}');</script>";
    ?>

     

    Ooops, well that's embarrassing :P

  3. does alert function have to defined in the php page? :shrug:

     

    alert is pre-defined rite?

     

    echo "<script type='text/javascript'>alert('{$variabl}');</script>

     

    the alert box does not appear...

     

    alert if a Java Script function, so it doesn't have to be defined on the PHP page. And what he said works fine besides the fact that he forgot the ending quote after </script>

     

    <?php
    $Text = "Hello World!";
    echo "<script type='text/javascript'>alert('{$Text}');</script>"
    ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.