Solved

ERROR MESSAGE OVERLOAD

Posted on 2008-10-20
3
354 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
  • 2
3 Comments
 
LVL 19

Expert Comment

by:NerdsOfTech
Comment Utility
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
Comment Utility
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
Comment Utility
That seems to have worked. Thanks guys!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now