unable to update database. php mysql

I face the problem::

  • To Insert data
  • to update data

When I go www.myweb.com/cpanel
user:xxxxx
Pass:xxxx
Go

Database>>PhP MyAdmin>>
by this way I can update my database…

*But when I connect by PHP… I failed…
Pls suggest some one…pls !!1

…1. test.php… of a row
Update

2.update.php

<?php $host="localhost"; $username="xxxx"; $pass="xxxx"; $db="xxx"; $tbl="website"; // Connect to server and select database. @mysql_connect("$host", "$username", "$pass")or die("cannot connect"); @mysql_select_db("$db")or die("cannot select DB"); // get value of id that sent from address bar $id=$_GET['id']; // Retrieve data from database $sql="SELECT * FROM $tbl WHERE id='$id'"; [email protected]_query($sql); $rows=mysql_fetch_array($result); ?>
<tr>

  <td bgcolor="#FFFFFF">
  <input type="text" name="id" value="<?php echo $rows["id"] ?>" />
  
  </td>
  <td bgcolor="#FFFFFF"><p align="center">
      <input name="nam" type="text" value="<? echo $rows['nam']; ?>" />
    </p>
      <p>&nbsp; </p></td>
  <td bgcolor="#FFFFFF"><p align="center">
    <input name="desc" type="text"  value="<? echo $rows['desc']; ?>" />
  </p></td>
  <td bgcolor="#FFFFFF"><div align="center">
    <input name="link" type="text" value="<? echo $rows['link']; ?>" />
  </div></td>
  <td bgcolor="#FFFFFF"><div align="center">
    <input name="pic" type="text"  value="<? echo $rows['pic']; ?>" />
  </div></td>

</tr>

<tr>
  <td colspan="5" align="right" bgcolor="#E6E6E6"><input type="submit" name="submit" value="Update" />      </td>
</tr>
S.L Name Description Link Image
<?php mysql_close(); ?>

2.update_ac.php

<? $host="localhost"; $username="xxxx"; $pass="xxxx"; $db="xxx"; $tbl="website"; // Connect to server and select database. @mysql_connect("$host", "$user", "$pass")or die("cannot connect"); @mysql_select_db("$db")or die("cannot select DB"); if ($_POST["submit"]) { $id=$_POST['id']; $nam = $_POST["nam"]; $desc = $_POST["desc"]; $link = $_POST["link"]; $pic = $_POST["pic"]; $sql = " UPDATE website SET id='$id', nam='$nam', desc='$desc', link='$link', pic='$pic' WHERE id='$id' " ; $result = @mysql_query($sql); echo "1 Row Updated"; } else { echo "ERROR"; } if($result) { echo "1 Row Updated"; echo ""; } else { echo ""; echo "ERROR Record Update....."; echo ""; echo ""; } ?>

3.output

1 Row Updated
ERROR Record Update…

Sponsor our Newsletter | Privacy Policy | Terms of Service