Good Day I've created this edit/update form with assistants of this tutorial http://www.freewebmasterhelp.com/tutorials/phpmysql/7
And when I click the update button I get these two messages
Notice: Undefined index: artist_id in C:\wamp\www\Practical_Project\admin_artist_edit.php on line 2
Warning: mysql_numrows() expects parameter 1 to be resource, boolean given in C:\wamp\www\Practical_Project\admin_artist_edit.php on line 9
I don't understand why I'm getting an error in line 2 since I am passing in an array from another file and I just don't understand what causing the error on line 9 at all. I have attached my code below and any assistance will be appreciated :).
<?php
$id = $_GET['artist_id'];
$conn = mysql_connect ("localhost","root","") or die("Unable to connect to mysql database server");
mysql_select_db("gallery") or die ("Unable to select database");
//Getting the artist where the id match
$query = "SELECT * FROM artist WHERE artist_id = $id";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
//creating an edit form
$i=0;
while ($i<$num){
$firstname=mysql_result($result,$i,"firstname");
$surname=mysql_result($result,$i,"surname");
$bibliography=mysql_result($result,$i,"bibliography");
$phone=mysql_result($result,$i,"phone");
$email=mysql_result($result,$i,"email");
echo '<form action="admin_artist_edit.php" method="post">
<td align="center"><input name="edit_id" type="hidden" value="'; echo $id; echo '"></td></br>
<strong>First Name:</strong><td align="center"><input name="edit_firstname" type="text" value="'; echo $firstname; echo '"></td></br>
<strong>Surname:</strong><td align="center"><input name="edit_surname" type="text" value="'; echo $surname; echo '"></td></br>
<strong>Bibliography:</strong><td align="center"><input name="edit_bibliography" type="text" value="'; echo $bibliography; echo '"></td></br>
<strong>Phone:</strong><td align="center"><input name="phone" type="text" value="'; echo $phone; echo '"></td></br>
<strong>Email:</strong><td align="center"><input name="email" type="text" value="'; echo $email; echo '"></td></br>
<input type="submit" value="Update">
</form>';
++$i;
}
//when the user to submit it will update the database
if( isset($_POST['submit']) && $_POST['submit'])
{
$edit_id = ($_POST['edit_id']);
$edit_firstname=$_POST['edit_firstname'];
$edit_surname=$_POST['edit_surname'];
$edit_bibliography=$_POST['edit_bibliography'];
$edit_phone=$_POST['edit_phone'];
$edit_email=$_POST['edit_email'];
}
if (isset($_POST['submit']) && $_POST['submit'])
{
$query=mysql_query("UPDATE artist SET firstname='$edit_firstname', surname='$edit_surname', bibliography='$edit_bibliography', phone='$edit_phone', email='$edit_email' WHERE artist_id='$edit_id'
");
mysql_query($query);
echo "Record Updated";
mysql_close();
}
?>