-1

I am receiving this error: Parse error: syntax error, unexpected in /home/public_html/admin/login.php on line 15

<?PHP session_start();
$users = $_POST['txtuser'];
$passs = $_POST['txtpass'];
$passs= md5($passs);
include('../includes/myconnect.php');

$qry="SELECT * FROM users WHERE username='$users' and password='$passs'";
$res=mysql_query($qry);
$num=mysql_num_rows($res);
if($num>=1)
{
  $_SESSION['adminU']=$users;
  $_SESSION['adminP']=$passs;
  header("Location:emails.php");
}
else{header("Location:index.php?)msg=1";}
?>

if i change change this:

else{header("Location:index.php?)msg=1";}

to this:

else{header("Location:index.php?msg=1");}

then i get this error:

   Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in
 /home/...../public_html/admin/login.php on line 9

    Warning: Cannot modify header information - headers already sent by (output
 started at /home/...../public_html/admin/login.php:9) in
 /home/...../public_html/admin/login.php on line 15
Donato Szilagyi
  • 4,229
  • 4
  • 33
  • 50
  • 1
    **Read the error!** Here's a list of error messages and instructions on troubleshooting them: http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php – Amal Murali Jul 22 '13 at 15:01
  • 5
    You need to learn how to [READ and debug](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) error messages. Everything you needed to solve the problem was in the error message. – Anigel Jul 22 '13 at 15:02
  • 1
    `if(you use an IDE for PHP coding && Format your code properly) Such mistakes will not occur anymore;` – CodeAngry Jul 22 '13 at 15:06
  • 1
    @CodeAngry or at least they will be obvious if they do occur :) – Anigel Jul 22 '13 at 15:07
  • now what you are getting is a MySQL error. can you echo your query statement and run it directly against the database to see if it is correct ? – Maximus2012 Jul 22 '13 at 15:19
  • `echo $qry` and run it manually on the MySQL server. Use MySQL Workbench or another client or PHPMyAdmin. **You don't MySQL escape the `$users` and `$passs` so it makes sense that it does not work.** See how [MySQLi Escaping](https://gist.github.com/CodeAngry/fa0522683e0268ea52fd) is done. – CodeAngry Jul 22 '13 at 15:26
  • sorry guys am lost from all that how i do in phpmyadmin – Andy Coco Koprek Jul 22 '13 at 15:35
  • can any1 fix if i gave host info? – Andy Coco Koprek Jul 22 '13 at 16:57

2 Answers2

3

change this:

else{header("Location:index.php?)msg=1";}

to this:

else{header("Location:index.php?msg=1");}
Maximus2012
  • 1,812
  • 2
  • 12
  • 15
0
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in
 /home/...../public_html/admin/login.php on line 9

This warning may be because your query is returning empty set of result.

Konsole
  • 3,427
  • 3
  • 27
  • 38