Velocity Reviews

Velocity Reviews (
-   Software (
-   -   PHP MySQL UPDATE ( 12-05-2012 09:41 AM

Can anyone help me with correcting this page so it works?

Seems to have a problem with this line esp, $id=($_GET["id"]);

echo '<html>
<title>Edit a Record from MySQL Database</title>
<form method="post" action="update_ac.php">';

$con = mysql_connect("localhost","root","");
if (!$con)
die('Could not connect: ' . mysql_error());

mysql_select_db("my_db", $con);

// get value of id that sent from address bar

// Retrieve data from database
$sql="SELECT * FROM persons WHERE id='$id'";


echo "<table border='1'>

while ($row = mysql_fetch_array($result)){
$id = $row['id'];
$FirstName = $row['FirstName'];
$LastName = $row['LastName'];
$Age = $row['Age']; //we will echo these into the proper fields

echo '<tr><td><input type="text" value="<?php echo $id;?>" name="id" disabled/><br/> </td
<td>First Name:<br/><input type="text" value="<?php echo $FirstName;?>" name="FirstName"/> <br/> </td
<td>Last Name:<br/><input type="text" value="<?php echo $LastName;?>" name="LastName"/> <br/> </td
<td>Age:<br/><input type="text" value="<?php echo $Age;?>" name="Age"/> </br>
<input type="submit" value="submit changes"/></td</tr>';
echo "</table>";

// close connection

echo "</form>

heff 01-03-2013 05:43 PM

You've probably solved this by now, but here goes anyway.
Your GET request should be $id=$_GET['id'];

All times are GMT. The time now is 06:50 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.