Solved

ERROR MESSAGE OVERLOAD

Posted on 2008-10-20
3
361 Views
Last Modified: 2012-05-05
I am getting 5 seperate error messages when I execute my login page in Internet explorer. I am completly flumuxed by this. I've attached the code as well as all 5 error messages. Sorry for making so much work!

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Inetpub\wwwroot\strictly-invite.co.uk\strictlyinvite files\html\website\login.php:4) in C:\Inetpub\wwwroot\strictly-invite.co.uk\strictlyinvite files\html\website\login.php on line 13

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Inetpub\wwwroot\strictly-invite.co.uk\strictlyinvite files\html\website\login.php:4) in C:\Inetpub\wwwroot\strictly-invite.co.uk\strictlyinvite files\html\website\login.php on line 13

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\strictly-invite.co.uk\strictlyinvite files\html\website\login.php on line 22

Warning: include(loginhtml) [function.include]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\strictly-invite.co.uk\strictlyinvite files\html\website\login.php on line 24

Warning: include() [function.include]: Failed opening 'loginhtml' for inclusion (include_path='.;C:\php5\pear') in C:\Inetpub\wwwroot\strictly-invite.co.uk\strictlyinvite files\html\website\login.php on line 24

<?php
$dbhost = "localhost";
$dbname = "users";
$dbuser = "root";
$dbpass = "pass";
 
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
 
session_start();
 
$username = $_POST[username];
$password = md5($_POST[password]);
 
$query = "SELECT * FROM users where username= $'username' and password= $'password'";
 
$result = mysql_query($query);
 
if (mysql_num_rows($result) != 1) {
$error = 'Bad Login';
    include login.html;
 
} else {
    $_SESSION[username] = '$username';
    include welcome.php;
}
 
?>

Open in new window

0
Comment
Question by:rafique12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 22756671
Multiple Syntax errors: including:
* Misplaced quote errors
* Concatenation errors

Hope this revision helps you out.
<?php
$dbhost = "localhost";
$dbname = "users";
$dbuser = "root";
$dbpass = "pass";
 
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
 
session_start();
 
$username = $_POST["username"];
$password = md5($_POST["password"]);
 
$query = 'SELECT * FROM users where username= ' . $username . ' and password= ' . '$password';
 
$result = mysql_query($query);
 
if (mysql_num_rows($result) != 1) {
$error = 'Bad Login';
    include login.html;
 
} else {
    $_SESSION["username"] = $username;
    include welcome.php;
}
 
?>

Open in new window

0
 
LVL 19

Accepted Solution

by:
NerdsOfTech earned 500 total points
ID: 22756677
Correction on SQL Statement
<?php
$dbhost = "localhost";
$dbname = "users";
$dbuser = "root";
$dbpass = "pass";
 
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
 
session_start();
 
$username = $_POST["username"];
$password = md5($_POST["password"]);
 
$query = 'SELECT * FROM users where username= ' . $username . ' and password= ' . $password;
 
$result = mysql_query($query);
 
if (mysql_num_rows($result) != 1) {
$error = 'Bad Login';
    include login.html;
 
} else {
    $_SESSION["username"] = $username;
    include welcome.php;
}
 
?>

Open in new window

0
 

Author Closing Comment

by:rafique12
ID: 31507790
That seems to have worked. Thanks guys!
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question