•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,803 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,419 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 914 | Replies: 2
![]() |
•
•
Join Date: Jun 2006
Posts: 29
Reputation:
Rep Power: 3
Solved Threads: 0
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:
And here is my actual code of login.php:
[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;
}
}
}
?>[/php]
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.
Here is the error i am getting in my code:
Parse error: parse error, unexpected T_INC, expecting ')' in c:\link\to\file\backend\login.php on line 37
And here is my actual code of login.php:
[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;
}
}
}
?>[/php]
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
- "the messaging interface has returned an unknown error." (Windows Software)
- Error, Cannot Complete Cd Writing Wizard (Windows Software)
- The attempt to burn a disc failed.. An unknown error occured. (4450) (Storage)
- Visual Runtime Error, Sound Problem, Disabled Norton and more! (Windows NT / 2000 / XP / 2003)
- Unknown Error when trying to start WindowsXP (Windows NT / 2000 / XP / 2003)
Other Threads in the PHP Forum
- Previous Thread: List Of Free PHP,MYSQL Webhosting Provider
- Next Thread: Sending HTML message to Outlook


Linear Mode