Hey guys, im just starting out in php and im attempting to build a login script that works takes info from my table userinfo. The values in userinfo are created from createuser.php.

Here is the error i am getting in my code:

[B]Parse error[/B]:  parse error, unexpected T_INC, expecting ')' in [B]c:\link\to\file\backend\login.php[/B] on line [B]37[/B]

And here is my actual code of login.php:

<?php

// login.php
// by Ryan Wood

// TODO: Allow user to login and see his information about his project.

require ($_SERVER["DOCUMENT_ROOT"]."/backend/config.php");
$connection = @mysql_connect($server, $db_user, $db_password) or die("Error: Could not connect to MySQL server");
mysql_select_db($database, $connection);

$name = $_POST["txt_username"];
$password = $_POST["txt_password"];

?>

<html>
<head>
    <title>Login</title>
</head>
<body>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <form action="<?php echo $_SESSION[PHP_SELF]; ?>" method="post">
        Username : <input name="txt_username" type="text" maxlength="64"><br><br>
        Password :   <input name="txt_password" type="text" maxlength="64"><br><br>
        <input value="Submit" type="submit">
    </form><br>
</font>
</body>
</html>

<?php

$query = "SELECT * FROM userinfo";
$result = mysql_query($query, $connection);

for ($i = 0; $i < mysql_num_rows($result); i++)
{
    $name_ck = mysql_result($result, $i, "user_name");
    $pass_ck = mysql_result($result, $i, "user_password");
    
    if ($name == $name_ck)
    {
        if (md5($pass) == $pass_ck)
        {
            echo $name_ck.'<br>';
            echo $pass_ch;
        }
    }
}

?>

The error occurs on line 37, where the for loop is.

Any help is appreciated. Ive searched for T_INC and my other problem with not having a ")" much to my dismay.

Dang, quite obvious what the error was after i stopped staring at it for an hour. I was missing the '$' sign in front of the i++. Damn C++, damn it.

This article has been dead for over six months. Start a new discussion instead.