1 Replies - 405 Views - Last Post: 15 May 2011 - 01:26 AM Rate Topic: -----

#1 menukadevinda  Icon User is offline

  • D.I.C Regular

Reputation: -7
  • View blog
  • Posts: 470
  • Joined: 14-April 11

problem in updating database

Posted 15 May 2011 - 12:06 AM

hi,

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Sahansevena_ver1\admin\profile\updAdmiInfo.php on line 49

i got this error.

here is the coding
<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$dbuser="root";
    $dbpswd="****";
    $dbserver="localhost";


$nwuser=$_POST['username'];
$c_pw=$_POST['cur_password'];
$n_pw=$_POST['conf_password'];
//$user=$userName;
//$pass=$password;
//

$dbname="sahansevena";


if($_SERVER['REQUEST_METHOD']=='POST'){

    //get username and password from admin login.php

$con=mysql_connect($dbserver,$dbuser,$dbpswd);


    if(!$con){
        die('coudnt connect db connection prob'.mysql_error());
    }else{
        if($c_pw==$n_pw){

            $uname=mysql_real_escape_string($username);
            $pword=mysql_real_escape_string($n_pw);
           // setDatabase($dbname, $con) ;
           mysql_select_db($dbname, $con);
            //  $result="update admin set username='$uname',password='$pword'" where limit 0;
            $result="update admin set username='$uname' , password='$pword', last_logged_date =CURDATE(), last_log_time=CURTIME() where username='$uname' limit 0";



            //Checked to see if any rows were returned from the database
            // If rows were returned, set a session variable to 1
            $result=mysql_query($result);



            if ($result) {
                $numRow=mysql_numrows($result);
                if($numRow>0){
                    //session_start();

                   //SESSION['admin']="menuka";

echo "data was suaccesfully updated";
                   /// header ("Location:config/menu.php");

                    //mysql_close($con);
                }else{
                    //session_start();
echo " problem in updating ";
                    //$_SESSION['login'] = "";
                    //header ("Location:login.php");

                }




            }
            else {
                trigger_error(mysql_error(), E_USER_ERROR);
            }




        }

    }

}else{
    echo 'error message not post methode';
    include(login.php);
}




?>






please check my code and help me to figur out the error
thx in advance,
menukadevinda

Is This A Good Question/Topic? 0
  • +

Replies To: problem in updating database

#2 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: problem in updating database

Posted 15 May 2011 - 01:26 AM

use var_dump on the values you try to pass to the query.
It seems that the query has some errors in it.
print mysql_error() as well:

var_dump($uname);
var_dump($pword);
..
//run the sql query..
echo mysql_error();

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1