Results 1 to 7 of 7

Thread: Parse error :(

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Parse error :(

    Hi,

    I get a parse error at line 118:
    PHP Code:
    <?php
    include('config.php');
    // connect to the mysql database server.
    mysql_connect ($dbhost$dbusername$dbuserpass);
    mysql_select_db($dbname) or die('Cannot select database');
    if (isset(
    $_COOKIE['BSComputersU']) && isset($_COOKIE['BSComputersP'])) {
        
    header("Location: main.php");
    }else{
    if (
    $_POST['username']) {
    //did they supply a password and username
    $username=$_POST['username'];
    $password=$_POST['password'];
    if (
    $password==NULL) {
    echo 
    "<center>Du har ikke indtastet et kodeord!</center><br>
    <center>
    <h1>Login</h1>
    <form action='check.php' method='POST'>
    <table style='border:1px solid #000000;'>
    <tr>
    <td align='right'>
    Brugernavn: <input type='text' size='15' maxlength='25' name='username'>
    </td>
    </tr>
    <tr>
    <td align='right'>
    Kodeord: <input type='password' size='15' maxlength='25' name='password'>
    </td>
    </tr>
    <tr>
    <td align='center'>
    <input type='submit' value='Login'>
    </td>
    </tr>
    <tr>
    <td align='center'>
    <a href='register.php'>Opret bruger her</a>
    </td>
    </tr>
    </table>
    </form></center>
    "
    ;
    }else{
    $query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
    $data mysql_fetch_array($query);
    if(
    $data['password'] != md5($password)) {
    echo 
    "<center>Du har indtastet forkert brugernavn eller kodeord! Prøv igen<br><center>
    <h1>Login</h1>
    <form action='check.php' method='POST'>
    <table style='border:1px solid #000000;'>
    <tr>
    <td align='right'>
    Brugernavn: <input type='text' size='15' maxlength='25' name='username'>
    </td>
    </tr>
    <tr>
    <td align='right'>
    Kodeord: <input type='password' size='15' maxlength='25' name='password'>
    </td>
    </tr>
    <tr>
    <td align='center'>
    <input type='submit' value='Login'>
    </td>
    </tr>
    <tr>
    <td align='center'>
    <a href='register.php'>Opret bruger her</a>
    </td>
    </tr>
    </table>
    </form></center>
    </center>"
    ;
    }else{
    if (isset(
    $_POST['husklogin'])){
    setcookie('BSComputersU'$usernametime() + 3600 24 365);
    setcookie('BSComputersP'$passwordtime() + 3600 24 365);      
         
    $query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
        
    $row mysql_fetch_array($query);
        
    $_SESSION["s_username"] = $row['username'];
        
    header("Location: index.php");
    }
    }
    }
    ?>
    <script language="javascript" type="text/javascript">
    function createRequestObject()
    {
        var request_o; //declare the variable to hold the object.
        var browser = navigator.appName; //find the browser name
        if(browser == "Microsoft Internet Explorer"){
            /* Create the object using MSIE's method */
            request_o = new ActiveXObject("Microsoft.XMLHTTP");
        }else{
            /* Create the object using other browser's method */
            request_o = new XMLHttpRequest();
        }
        return request_o; //return the object
    }


    var http = createRequestObject();
    function destorySession()
    {
        try
        { 
        http.open('get', 'destroy.php');
        http.send(null);
        }
        catch(Exception)
        {
            http = createRequestObject();
            destorySession();
        }
    }

    window.onunload = destorySession();
    </script>
    But I can't see the prob

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Re: Parse error :(

    The husklogin is a checkbox

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Parse error :(

    Which line is line 118?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Parse error :(

    Ack, don't print out large chunks of html from php just makes things messy. Instead just close the php tags and write the html normally.

    eg
    PHP Code:
    <?

    //loads of php

    ?>

    <!-- loads of html -->

    <?

    //loads more php

    ?>
    This means you won't get parse errors from where you have not escaped a string correctly.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    236

    Re: Parse error :(

    I know, but it's something I've copy-pasted

    The line 118 is where the javascript ends

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Parse error :(

    Quote Originally Posted by sveegaard
    I know, but it's something I've copy-pasted

    The line 118 is where the javascript ends
    I cannot speak for anyone else here. But I am not even going to look at that code until it is properly indented.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Re: Parse error :(

    You're missing some brackets.

    PHP Code:
    <?php 
        
    include('config.php'); 
        
    // connect to the mysql database server. 
        
    mysql_connect ($dbhost$dbusername$dbuserpass); 
        
    mysql_select_db($dbname) or die('Cannot select database'); 
        if ( isset( 
    $_COOKIE['BSComputersU'] ) && isset( $_COOKIE['BSComputersP'] ) ) 
        { 
            
    header"Location: main.php" ); 
        } 
        else 
        { 
            if (
    $_POST['username']) 
            { 
                
    //did they supply a password and username 
                
    $username=$_POST['username']; 
                
    $password=$_POST['password']; 
                if (
    $password==NULL) { 
                    
    // some html
                

                else 
                { 
                    
    $query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); 
                    
    $data mysql_fetch_array($query); 
                    if(
    $data['password'] != md5($password)) 
                    { 
                        
    // some more html
                    
    }
                    else 
                    { 
                        if (isset(
    $_POST['husklogin']))
                        { 
                            
    setcookie('BSComputersU'$usernametime() + 3600 24 365); 
                            
    setcookie('BSComputersP'$passwordtime() + 3600 24 365);       
          
                            
    $query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); 
                            
    $row mysql_fetch_array($query); 
                            
    $_SESSION["s_username"] = $row['username']; 
                            
    header("Location: index.php"); 
                        }
                    } 
                }
            } 
    // $_POST['username']
        
    }
    ?>

Posting Permissions

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



Click Here to Expand Forum to Full Width