Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    $end error on last line

    Hi

    First try at something like this so bear with me...

    My Problem: I don't know how much of my code works because I am getting an $end error on line 75 - the last line of the page. What am I doing wrong? The internet seems to tell me that I have missed a bracket somewhere, but neither Dreamweaver or I can find this....

    My code:
    PHP Code:
    <head>
    <?php session_start();
    $host="localhost";
    $username="****";
    $password="****";
    $db_name="*****";
    $uname mysql_real_escape_string$_session["myusername"] );
    mysql_connect("$host""$username""$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    if (!isset(
    $_SESSION['myusername']) || empty($_SESSION['myusername'])) {;
    include 
    "logout.php";
    }
    if(isset(
    $_COOKIE['ID_mrtg'])) ;

    $username $_COOKIE['myusername']; 
    $password $_COOKIE['mypassword']; 
    $check mysql_query("SELECT * FROM members WHERE username = '$myusername'")or die(mysql_error()); 
    $name mysql_query("SELECT `name` FROM members WHERE username = '$myusername'")or die(mysql_error()); 
    while(
    $info mysql_fetch_array$check )) ;

    if (
    $password != $info['mypassword']);
    header("Location: logout.php"); 
    ?> 
    <br />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>My PHP System</title>
    <style type="text/css">
    body,td,th {
        font-family: DINPro-Medium, Arial;
        font-size: 18px;
        color: #E9D3A2;
        background-color: #A0131B;
    }
    body {
        background-color: #78131B;
        color: #E9D3A2;
        text-align: left;
    }
    .right {
        text-align: right;
    }
    a:link {
        color: #E9D3A2;
    }
    a:visited {
        color: #E9D3A2;
    }
    #userauth {
        text-align:right;
    }
    a:hover {
        color: #E9D3A2;
    }
    a:active {
        color: #E9D3A2;
    }
    </style>
    </head>
    <body> 
    <p>
    </p>
    <a href="\logout.php">Logout</a>
    <p><img src="Header.png" alt="Header" width="449" height="254" align="middle" />
      Welcome <?php echo $myusername ?> ! Thank you for logging in.
    Please click on an option below:</p>
    <p>Option 1</p>
    <p>Option 2</p>
    <p>Option 3</p>
    <p>Option 4</p>
    <p></p> 
    <span class="right">(C) JA 2011</span>
    <p>&nbsp;</p>
    <p><a href="http://LINK TO PHPMYADMIN>Administration</a></p>
    </body>
    </html>
    Any help at all would be very much appreciated

    Thanks
    Last edited by buzz23; 10-29-2011 at 06:58 PM. Reason: BTW, if you could give me a pointer on ' & " s that would be good - what goes around variables?? Thanks

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Unexpected $end means you haven't closed one of your code blocks like this one:
    PHP Code:
    if(isset($_COOKIE['ID_mrtg'])) 

    You need to have a closing curly brace after the end of the code you want this condition to execute. Also, you have semicolons on lines that aren't terminating or assignment. See the difference?
    PHP Code:
    $password $_COOKIE['mypassword']; // end of the statement "<something> equals <something>" -- assignment
    if ($password != $info['mypassword']); // NOT the end of the statement; "if <something> does not equal <something> then..." -- beginning of conditional statement 

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,332
    Thanks
    60
    Thanked 526 Times in 513 Posts
    Blog Entries
    4
    I've found some problems in your code:
    PHP Code:
    if (!isset($_SESSION['myusername']) || empty($_SESSION['myusername'])) {;
    include 
    "logout.php"
    You have a semicolon ; after an opening brace - remove it.

    PHP Code:
    if(isset($_COOKIE['ID_mrtg'])) ; 
    Sei colon before the opening brace - remove it.

    PHP Code:
    <?php echo $myusername ?>
    No semicolon at all - put one in.

    You might also like to look at the link in my signature about coding styles and $end errors as it may be useful to you.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    buzz23 (10-30-2011)

  • #4
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks very much to both of you for your helpful answers. Together they have solved my problem, and tangoforce's tutorial has been really helpful!

    Thanks


  •  

    Tags for this Thread

    Posting Permissions

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