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'"; $result=@mysql_query($sql); $rows=mysql_fetch_array($result); ?>S.L | Name | Description | Link | Image |
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…