Web Hosting Forums

Results 1 to 7 of 7

This is a discussion on Parse Errors in the Hosting Talk & Chit-chat forum
I can get this code to work, it seems to produce parse errors at the HTML part of the form, line 21 onwards. <?PHP $name ...

  1. #1
    Loyal Client
    Join Date
    Nov 2001
    Location
    South East UK
    Posts
    14

    Exclamation Parse Errors

    I can get this code to work, it seems to produce parse errors at the HTML part of the form, line 21 onwards.


    <?PHP

    $name = $HTTP_GET_VARS['admin'];
    $pass = $HTTP_GET_VARS['pass'];
    $act = $HTTP_GET_VARS['act'];

    include('Header.php');

    $filename = "/home/maxitest/public_html/users/admin/$admin";

    if (file_exists($filename))
    {
    $fp = fopen($filename, "r");
    $passc = fread ($fp, filesize ($filename));
    fclose ($fp);

    if ($pass==$passc)
    {
    if ($act==0)
    {
    echo "<form method="get" action="Admin.php">";
    echo "<b><center>Username";
    echo "<input type="text" name="uname"><p>";

    echo "Add Admin<br>";
    echo "<input type="radio" value="1" name="act"><br>";

    echo "Remove Admin<br>";
    echo "<input type="radio" value="2" name="act"><br>";

    echo "Remove User<br>";
    echo "<input type="radio" value="3" name="act"><p>";

    echo "View Server Details (Support)<br>";
    echo "<input type="radio" name="act" value="4"><p>";

    echo "<input type="hidden" value=$admin name="admin">";
    echo "<input type="hidden" value=$pass name="pass">";

    echo "<input type="submit" name="Submit">";

    }
    if ($act==1)
    {
    $uname = $HTTP_GET_VARS['uname'];
    if (file_exists("/home/maxitest/public_html/users/admin/$uname)
    {
    echo "<center>User is allready set to admin status";
    echo "<br><a href="Admin.php?admin=$admin&pass=$pass" >RETURN</A><center>";
    } else
    {
    $fp = fopen("/home/maxitest/public_html/users/admin/$uname", "w");
    fputs($fp, $pass);
    fclose($fp);
    echo "<center><b>ADMIN ADDED</b>";
    echo "<br><a href="Admin.php?admin=$admin&pass=$pass" >RETURN</A></center>";
    }
    }
    if ($act==2)
    {
    echo "<center><br><a href="Admin.php?admin=$admin&pass=$pass" >RETURN</A><c/enter>";
    }
    if ($act==3)
    {
    echo "<center><br><a href="Admin.php?admin=$admin&pass=$pass" >RETURN</A></center>";
    }
    if ($act==4)
    {
    include('Server.txt');
    echo "<center><br><a href="Admin.php?admin=$admin&pass=$pass" >RETURN</A></center>";
    }
    }else
    {
    echo "<center><b>Incorrect Password</b></center>";
    }
    }else
    {
    echo "<center><b>Your username is not set to admin status</b><center>";
    }

    include('Footer.php');

    ?>


    Please can someone take a look at it for me. Its pretty simple what its doing.

    Thanx
    Mike

  2. #2
    Loyal Client
    Join Date
    Sep 2001
    Posts
    3
    inside your all your echo statements

    example
    PHP Code:
    echo "<form method="get" action="Admin.php">"
    you need to escape your " marks

    example

    PHP Code:
    echo "<form method=\"get\" action=\"Admin.php\">"

  3. #3
    Loyal Client JoJo's Avatar
    Join Date
    Sep 2001
    Location
    Brazil
    Posts
    36

    Question

    Anyone knows how to avoit this? (using \")

    In PERL we have this:

    $data = qq( <tr bgcolor="$color">\n);




    tks
    JoJo
    ..:: Nothing Else to Say ::..

  4. #4
    Loyal Client Pawel Kowalski's Avatar
    Join Date
    Sep 2001
    Location
    Albuquerque NM
    Posts
    1,446
    Yes, you can close the php processing before this line by adding ?> . After this you can add any html you like. When you are ready to start php again just add <? and end it off with ?>
    Good Luck,
    Paul

  5. #5
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    5,884
    You can also use a single quote instead of the double quotes:

    PHP Code:
    echo 'Hello "world"'
    Note that in order to use a variable in the output, though, you'll need to end the quotes before you use the variables (sorry, I can't come up with a bette way of explaining this right now, just look at the example )

    PHP Code:
    echo 'Hello ' $world
    with double quotes you can just use "Hello $world" to get the same result, as you did in your example.

    Hope this helps...

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  6. #6
    Loyal Client JoJo's Avatar
    Join Date
    Sep 2001
    Location
    Brazil
    Posts
    36

    Arrow

    But I can't do this:

    $myvar = ?> <a href="/index.php">HOME</a> <?;

    I have seen a dif. code, but I didn't get it, it's like PERL:

    Code:
    print <<EOF;
    
    You can ADD anything here: " ' , 
    but if u write eof ( like the begining eof )
    you end your precedure;
    
    EOF
    Tks

    JoJo
    JoJo
    ..:: Nothing Else to Say ::..

  7. #7
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    5,884
    What you are actually doing when you put something outside of the <? ... ?> is telling php to print it to the browser. You are essentially using a print() or echo() statement for everything that appears outsides the code blocks.

    Since $var = echo("<A HREF=test.php>"); isn't a valid statement, neither is the example you posted.

    The perl style code you mentioned is possible in PHP, although I don't think I've enver used it, and I don't know if the syntax is exactly the same or not.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

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
  •