Hi iam trying to fetch the record from database and need to update the query in database but if iam trying getting errors as below
Notice: Undefined variable: result in C:\xampp\htdocs\index\index.php on line 57 Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\index\index.php on line 57
here is my code:
index.php
<?php
session_start();
?>
<title> Dashboard </title>
</head>
<?php  
$username = $_SESSION['username'];
if($username) 
{ 
?>
<h3> Welcome <?php echo $username; ?></h3>
<?php 
}  
else 
{ 
echo "no"; 
} 
?> 
<body>
    <form method="post" action="personalinfo.php" id="myform">
    <input type='hidden' value="<?php echo $username; ?>" name='email'>
   <div class="box-body table-responsive no-padding">
 <table class="table table-hover">
      <tr>
          <th>ID</th>
          <th>Name</th>
      </tr>
      <tr>
           <?php
                if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
    ?>
              <td><?php echo $row['first_name']; ?></td> 
              </tr>
            <?php
            }
            }
             ?>
   </table>
</div>
   <input type="button" value="Logout" id="logout" onClick="document.location.href='login.php'" />
    </form>
</body>
Personalinfo.php
<?php 
$connection = mysql_connect("localhost", "root", "") or die(mysql_error());
$db = mysql_select_db("accountant", $connection);
$email=$_POST['email'];
$firstname = $_POST['first_name'];
$res = "SELECT * FROM registered WHERE email ='$email' ";
$result=mysql_query($res);//this is for comparing ids
$res1 = "SELECT first_name FROM registered WHERE email ='$email' ";
$result=mysql_query($res1);//this is for getting first_name from database table
$query = mysql_query("UPDATE registered SET first_name='$firstname' WHERE email= '$email'");
 // mysql_query("$query") OR die("Error:".mysql_error());
 if($query)
 { 
    echo "Successfully Registered";    
 }
 else{
    echo "Registration has not been completed.Please try again";
 }
Can anyone help me regarding this.Thanks in advance
 
    