Jump to content

[SOLVED] unexpected ; (impossable?)


freddyw

Recommended Posts

Im really not sure why I'm recieving this error.

 

heres the code im working on

 

<?      $username = (isset($_POST['username']) ? pg_escape_string($_POST['username']) : "";
        $password = (isset($_POST['password']) ? pg_escape_string($_POST['password']) : "";
        $referer = (isset($_SERVER['HTTP_REFERER']) ? 
        $_SERVER['HTTP_REFERER'] : "noreferer";
        
        #this will make user return to login page if a field is left empty
            if ( ( !$username ) or (!$password) )
                {
                header ( "location:$referer" );
                exit();
                }
        
                
                $conn = @pg_connect("connection details hidden");
                
                $psql="select * from users where username =\"$username\" and password = password (\"$password\")";
                
                $rs = @pg_query ($psql,$conn)
                    or die ("could not execute query");
                    
            #get number of rows that match username and password
                $num = pg_num_rows($rs);
            
            #if there is a match log in successful
            if ( $num !=0 )
                {
                $msg = "Welcome $username - You are logged in";
                }
            else #return to log in page
                {
                header ( "location:$referer" );
                exit();
                }
        
?>

<html>
    <head><title>You are logged in</title></head>
        <body>
            <? echo ( $msg );
            ?>
        </body>
<html>        

 

any ideas why im recieving the error. I checked the whole code and cant see a ; out of place anywhere.

 

 

EDIT: i changed the short tag to <?php

the html is now shoing up with the log in from. however once the details are entered, it switched to the php page and is just blank

Link to comment
Share on other sites

Haha, thanks.

 

just to confirm. Should it be...

<?      $username = (isset($_POST['username'])) ? pg_escape_string($_POST['username']) : "";
        $password = (isset($_POST['password'])) ? pg_escape_string($_POST['password']) : "";
        $referer = (isset($_SERVER['HTTP_REFERER'])) 

 

I think im right with the first 2 lines.

Just the referer line im unsure of.

Link to comment
Share on other sites

Thanks. Thats cleared up the blank page.

Sorry if I'm being a a pain but im now recieving this error.

 

Parse error: syntax error, unexpected T_VARIABLE in /home2/webusers/07/344740/public_html/sporticket/login.php on line 4

 

<?php      $username = (isset($_POST['username'])) ? pg_escape_string($_POST['username']) : "";
        $password = (isset($_POST['password'])) ? pg_escape_string($_POST['password']) : "";
        $referer = (isset($_SERVER['HTTP_REFERER'])) 
        $_SERVER['HTTP_REFERER'] : "noreferer";
        
        #this will make user return to login page if a field is left empty
            if ( ( !$username ) or (!$password) )
                {
                header ( "location:$referer" );
                exit();
                }

 

Id appreciate your help

Link to comment
Share on other sites

You have this statement:

$referer = (isset($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] : "noreferer";

 

That should be:

$referer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : "noreferer";

 

Note that statements are only terminated by ; or ?>. Going to a new line doesn't mean it's a new statement.

 

I would recommend reading Language Reference in the manual.

Link to comment
Share on other sites

I would love to click the solve to this topic. I thought u helped me to that point Daniel.

 

I appreciate yor help so far. I'm greatful for it.

 

The script is working, However im recieving "could not ececute query."

 

I made a change to my original script, and still recieve the error. I changed line 15 to read

$psql="select * from users where username =\"$username\" and password =\"$password\"";

 

rather than

$psql="select * from users where username =\"$username\" and password = password (\"$password\")";

 

and it still wont execute. Is this something obvious that I'm missing.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.