Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Parse error: Parse error: syntax error, unexpected $end
Old 04-24-2005, 09:50 AM Parse error: syntax error, unexpected $end
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
I get this error message:

Quote:
Parse error: syntax error, unexpected $end in C:\webserver\htdocs\login\dologin.php on line 55
Here is my code

PHP Code:
<?php    // Login script

// In case register_globals is turned off
$username $_POST['username'];
$password crypt($_POST['password']);    // Apply crypt function on all passwords as passwords in database are encrypted

if ( empty($username) && (empty($password)) ) {    // Check if username and password fields were empty

    
header ('Location: index.php?page=login&loginfail=true');
    exit();

} else {    
// username and password field filled in

    // Connect and select the database
    
mysql_connect('localhost''username''password'); // username and password removed for security reasons
    
mysql_select_db('users');

    
// Define a query to check if the submitted username is found in the database
    
$check_user "SELECT `username` FROM `accounts` WHERE `username` = $username;";

    
$r mysql_query($check_user);    // Run the query

    
if (!$r) {    // If query unsucessful, username not found, redirect to login form
        
header ('Location: index.php?page=login&loginfail=true');
        exit();

    } else {    
// username found, check password

    // Define a query to check if the password is correct for the username
    
$check_pass "SELECT `password` FROM `accounts` WHERE `username` = $username && `password` = $password;";

    
$r mysql_query($check_pass);    // Run the query

    
if (!$r) {    // If query unsucessful, password is not cirrect for username, redirect to login form
        
header ('Location: index.php?page=login&loginfail=true');
        exit();

    } else {    
// username and password correct, do session stuff

        
session_start();
        
$_SESSION['username'] = $_POST['username'];
        
$_SESSION['loggedin'] = time();

        
// Redirect to home page (for now, will be redirected to account page in future)
        
header ('Location: ../index.php');
        exit();

    }

}    
// End of main IF

// Close database connection
mysql_close();

?>
Also, check my SQL queries, i dont think theres anything wrong with them, but I'm new to php/SQL so, better check :P

Last edited by HitRaj47; 04-24-2005 at 09:55 AM..
HitRaj47 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-24-2005, 09:55 AM
Bloodsyne's Avatar
Skilled Talker

Posts: 52
Trades: 0
I don't think I can help you with this one, but I will say this:

Instead of using if(empty($blah)), you can also use if(!$blah). It checks for the same thing, I think.

(unless empty() also checks for blank space? I don't know if ! will cover that.)
Bloodsyne is offline
Reply With Quote
View Public Profile
 
Old 04-24-2005, 10:02 AM
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
the empty() function checks to see if a given variable has a value other than 0 or an empty string.

that was from the book i am using

EDIT: i could also apply the trim() function to the username and passwords, that would get rid of any blank spaces, but ive gone off topic here

Last edited by HitRaj47; 04-24-2005 at 10:05 AM..
HitRaj47 is offline
Reply With Quote
View Public Profile
 
Old 04-24-2005, 10:05 AM
Bloodsyne's Avatar
Skilled Talker

Posts: 52
Trades: 0
I guess it's more than ! does, but not by much. I guess I never considered it, but I need to prevent people from being able to enter " " and get away with it, then.
Bloodsyne is offline
Reply With Quote
View Public Profile
 
Old 04-24-2005, 10:06 AM
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
Quote:
Originally Posted by Bloodsyne
but I need to prevent people from being able to enter " " and get away with it, then.
heh read the edit in my previous post
HitRaj47 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Parse error: Parse error: syntax error, unexpected $end
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14940 seconds with 12 queries