Solved

ERROR MESSAGE OVERLOAD

Posted on 2008-10-20
3
355 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 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

17 Experts available now in Live!

Get 1:1 Help Now