954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Very bad php errors...

I am getting so much errors in php. I couldn't understand why. I re-checked all code but I am getting strange errors. The code below is provided to you under mit/x11 license for modification and distribution. ALL DERIVATIVES ARE WELCOME! :)
Here is the code:

<html><head><link href="style.css" rel="stylesheet" type="text/css" media="screen" /></head>
<body>
<form action="login.php" method="post">
<h1>Please enter login information</h1>

<div id=login>

<font size=1>Username: </font><input type=text id=username /> 
<font size=1>Password: &nbsp;</font><input type=text id=password />

<input type=submit value=Login size=6 />
</div>
<?php
$debug=true;
if ($debug==true) echo "Preprocessor is OK!";
// Connecting, selecting database
$dbconn = pg_connect("host=localhost dbname=aaaa user=postgres password=qwerty")
or die('Could not connect-- ' . pg_last_error());
echo "Sucess!";
// Performing SQL query
$querys = "SELECT pass FROM login WHERE usrname='Rishi'"// . $_POST("Username");
$result = pg_query($querys) or die('Query failed-- '); // . pg_last_error());
$password = pg_fetch_row($result);
if ($debug==true) echo "Preprocessor is OK! -- Postgresql returned Password=" . $password;
if ($debug==true) echo "Preprocessor is OK! -- HTML form returned Password=" . $_POST("username");
if ($debug==true) echo "Preprocessor is OK! -- HTML form returned Password=" . $_POST("password");
if ($debug==true) echo "Preprocessor is OK! -- Parsing if";
if ($_POST("password") == $password){
if ($debug==true) { echo 'Preprocessor is OK! -- Parsed if -- Sucess'; }s";
setcookie('TestCookie', True);
}
elseif (!$_POST("password")){
echo "<font size=1 color=green>Please enter a username and password</font>";
if ($debug==true) echo "Preprocessor is OK! -- Parsed if -- elseif -- Sucess";
}
else {
echo "<font size=1 color=red>Invalid username or password!</font>";
if ($debug==true) echo "Preprocessor is OK! -- Parsed if -- else -- Sucess";
}
?>
</form>
</body>
</html>


PHP Parser shows:
PHP Parse error: syntax error, unexpected T_VARIABLE in C:\Program Files\Apache
Software Foundation\Apache2.2\htdocs\login.php on line 22

Thank you in advance. :)

Rishikeshan
Newbie Poster
18 posts since Aug 2010
Reputation Points: 10
Solved Threads: 1
 

I am not very experienced with php, but have you tried adding a semi-colon to the end of line 21? When I did this the page seemed to load correctly.

deathsandwich
Newbie Poster
2 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

Also, line 29 has an s and a double quote before the semi-colon, remove them.

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: