I'm having a bit of trouble getting this update script to update the database. This part of the form displays the record as it already exists:
<?
$id=$_GET['id'];
$username="xxxxx";
$password="xxxxx";
$database="xxxxx";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query=" SELECT * FROM play WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$pic=mysql_result($result,$i,"pic");
$album=mysql_result($result,$i,"album");
$artist=mysql_result($result,$i,"artist");
$reviewer=mysql_result($result,$i,"reviewer");
$description=mysql_result($result,$i,"description");
?>
<form action="updated.php" method="post">
<input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
Album cover file name (you can cut and paste this from above once you've uploaded the picture). Leave this as the default value if you don't have a picture: <br><input type="text" name="ud_pic" value="<? echo "$pic"?>"><br>
Artist: <br><input type="text" name="ud_artist" value="<? echo "$artist"?>"><br>
Album: <br><input type="text" name="ud_album" value="<? echo "$album"?>"><br>
Description (You can use html to spice this up if you know how): <br><textarea rows="10" cols="50" name="ud_description"><? echo "$description"?></textarea><br>
Reviewer: <br><select name="ud_reviewer" value="<? echo "$reviewer"?>">
<option value="Daniel">Daniel</option>
<option value="Caroline">Caroline</option>
<option value="Germ">Germ</option>
<option value="Jeremy">Jeremy</option>
<option value="Johnny">Johnny</option>
<option value="Shane">Shane</option>
<option value="Ziemniak">Ziemniak</option>
</select>
<input type="Submit" value="Update">
</form>
<?
++$i;
}
?>
And when I call the following script I get the confirmation message but nothing is changed in the database:
<?
$ud_id=$_POST['ud_id'];
$ud_pic=$_POST['ud_pic'];
$ud_artist=$_POST['ud_artist'];
$ud_album=$_POST['ud_album'];
$ud_description=$_POST['ud_description'];
$ud_reviewer=$_POST['ud_reviewer'];
$username="xxxxx";
$password="xxxxx";
$database="xxxxx";
mysql_connect(localhost,$username,$password);
mysql_query(" UPDATE play SET pic='$ud_pic', artist='$ud_artist', album='$ud_album', description='$ud_description', reviewer='$ud_reviewer' WHERE id='$ud_id'");
echo "Record Updated";
mysql_close();
?>
I'm pretty new to all this, so perhaps I'm missing something very easy. Anyone have any ideas why this wouldn't be working?
Daniel