Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2008
    Posts
    1

    Unanswered: Php code, mysql database error pls guide

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mahahind/public_html/admin.php on line 11

    Warning: Cannot modify header information - headers already sent by (output started at /home/mahahind/public_html/admin.php:11) in /home/mahahind/public_html/admin.php on line 18

    page code is
    <?php
    session_start();
    include('connect.php');
    $loginid=$_POST['loginid'];
    $pass=$_POST['password'];

    $query="select * from registration where loginid='$loginid' and password='$pass'";
    $res=mysql_query($query);
    $num=mysql_num_rows($res);
    if($num==1)
    {
    $_SESSION['name']=$loginid;
    header('Location:home.php?succ=1');
    }
    else
    {
    header('Location:index.html');
    }


    ?>

    please help

    *************

    connect.php (code)

    <?php
    $con=mysql_connect("localhost","mahahind_root","") ;

    if(!$con)
    {
    die("Could not connect database");
    }
    mysql_select_db("mahahindustan");

    ?>

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    I'm guessing here (because I can't see it in an IDE) but your connect.php has a space character after the closing "?>". Even a space will get output to the browser causing the header error you are getting.

    Thus, in summary, remove any whitespace before or after your "<?" and "?>" tags.

    This is the most common form of header error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •