menukadevinda Posted May 15, 2011 Share Posted May 15, 2011 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 Link to comment https://forums.phpfreaks.com/topic/236449-problem-in-updating-data-in-to-the-database-php/ Share on other sites More sharing options...
BrendanMullan Posted May 15, 2011 Share Posted May 15, 2011 You cant use num rows when updating only when selecting. Link to comment https://forums.phpfreaks.com/topic/236449-problem-in-updating-data-in-to-the-database-php/#findComment-1215623 Share on other sites More sharing options...
wildteen88 Posted May 15, 2011 Share Posted May 15, 2011 You will want to use mysql_affected_rows rather than mysql_num_rows() when checking to see how many rows was updated by your query Link to comment https://forums.phpfreaks.com/topic/236449-problem-in-updating-data-in-to-the-database-php/#findComment-1215654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.