not a valid MySQL result resource

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • studentfromhell
    New Member
    • Apr 2007
    • 1

    not a valid MySQL result resource

    These mesages appeared... what should I do? script is below the error messages...

    Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in c:\phpdev\www\w ebsite\calendar .php on line 29

    Warning: Cannot send session cache limiter - headers already sent (output started at c:\phpdev\www\w ebsite\calendar .php:29) in c:\phpdev\www\w ebsite\calendar .php on line 30

    Warning: Cannot add header information - headers already sent by (output started at c:\phpdev\www\w ebsite\calendar .php:29) in c:\phpdev\www\w ebsite\calendar .php on line 31
    [php]
    <?
    // Use session variable on this page. This function must put on the top of page.
    session_start() ;

    // Logout Section. Delete all session variable.
    session_destroy ();

    $message="";

    // Login Section.
    $Login=$_POST['Login'];
    if($Login){ // if clicked on Login button.
    $uname=$_POST['Uname'];
    $password=$_POS T['password'];

    // Connect database.
    $select=$_POST['select']; // Database name.
    $con = mysql_connect(" localhost",""," ");
    if (!$con)
    {
    die('You are not connected to the database, please try again later. ' . mysql_error());
    }
    mysql_select_db ("my_db",$co n);

    // Check matching of username and password.

    if($select='stu dent'){
    $result="SELECT * FROM $select WHERE password='$pass word' AND username='$unam e'";
    if(mysql_num_ro ws($result)!='0 '){
    session_registe r('Uname'); // Create session username.
    header("locatio n:navigate2.php "); // Re-direct to navigate2.php
    exit;
    }else{ // if not match.
    $message="--- Incorrect Username or Password ---";
    }
    }
    if($select='tea cher'){
    $result="SELECT * FROM $select WHERE password='$pass word' AND username='$unam e'";
    if(mysql_num_ro ws($result)!='0 '){
    session_registe r('Uname'); // Craete session username.
    header("locatio n:navigate3.php "); // Re-direct to navigate3.php
    exit;
    }
    else{ // if not match.
    $message="--- Incorrect Username or Password ---";
    }
    }
    if($message='ad ministrator'){
    $result="SELECT * FROM $select WHERE password='$pass word' AND username='$unam e'";
    if(mysql_num_ro ws($result)!='0 '){
    session_registe r('Uname'); // Craete session username.
    header("locatio n:navigate4.php "); // Re-direct to navigate4.php
    exit;
    }
    else{ // if not match.
    $message="--- Incorrect Username or Password ---";
    }
    }
    } // End Login authorize check.

    ?>

    <?php
    echo "<body bgcolor='#99336 6'>";
    echo $message;?>
    <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
    <h3><font color="#FFFFFF" face="Arial">Ar e you a:</font>
    <select name="select">
    <option selected>Select </option>
    <option value="student" >Student</option>
    <option value="teacher" >Teacher</option>
    <option value="administ rator">Administ rator</option>
    </select>
    </h3>
    <h3><font color="#FFFFFF" face="Arial">Us ername:</font></h3>
    <input type="textbox" maxlength="25" name="Uname"></input>
    <h3><font color="#FFFFFF" face='Arial'>Pa ssword:</font></h3>
    <p>
    <input type="password" name="password" maxlength="15">
    </input>
    <br/>
    <br/>
    <input type="Submit" value="Login" name="Login"/>
    <input type="Reset" value="Clear"/></p>
    <p><strong><fon t color="#66CCFF" face="Arial, Helvetica, sans-serif">Not a member? Please
    <a href="formmain. html" target="frameto "><font color="#33FFFF" >Sign up.</font></a></font>
    </strong></p></form></body>
    </html>[/php]
    Last edited by ronverdonk; Apr 6 '07, 10:37 PM. Reason: enclose code within code tags
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    That first error message usually means your connection to the database does not exist or failed.
    The second two will probably go away once you fix the first one.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Next time you post any code, enclose it within code or php tags!!

      Read the Posting Guidelines befoire you post any further in this (or any other) forum on this site!!

      moderator

      Comment

      Working...