Ive been working and debugging this edit script for almost the whole day now...i keep getting an error that reads: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\edit.php on line 60.
I'm pretty new to php, so im not sure if im looking over something obvious...but any help would greatly be appreciated!
<?php
//get the row ID for the item
$get_show_id = $_POST['show_id'];
$get_show_id = mysql_real_escape_string($get_show_id);
$sql = mysql_query("SELECT * FROM ".$_SESSION['SESS_LOGIN']."_shows WHERE show_id='$get_show_id'");
// if form has been submitted
if (isset($_POST['submit'])){
// add slashes if needed
if(!get_magic_quotes_gpc())
{
$show_id = addslashes($show_id);
$title = addslashes($title);
$description = addslashes($description);
}
//update news item
$sql = "UPDATE " .$_SESSION['SESS_LOGIN']."_shows SET title='$title', description='$description', show_date='$date' WHERE show_id='$get_show_id'";
$resultupdate = mysql_query($sql)or die(mysql_error());
$date = $_POST['year'] . $_POST['month'] . $_POST['day'];
// post form data
$show_id = $_POST['show_id'];
$title = $_POST['title'];
$description = $_POST['description'];
echo $date;
}
while ($row = mysql_fetch_object($sql)){
$result_day = mysql_query("SELECT date_format(show_date, '%d') as show_date FROM ".$_SESSION['SESS_LOGIN']."_shows WHERE show_id='$get_show_id'");
$day = mysql_result($result_day, 'show_date');
$result_month = mysql_query("SELECT date_format(show_date, '%m') as show_date FROM ".$_SESSION['SESS_LOGIN']."_shows WHERE show_id='$get_show_id'");
$month = mysql_result($result_month,'show_date');
$result_year = mysql_query("SELECT date_format(show_date, '%Y') as show_date FROM ".$_SESSION['SESS_LOGIN']."_shows WHERE show_id='$get_show_id'");
$year = mysql_result($result_year, 'show_date');
?>
<form action=" <?php $_SERVER['PHP_SELF'] ?> " method="post">
<input type="hidden" name="show_id" value="<?php echo $row->show_id;?>" />
<p><label>Title:</label><br />
<input name="title" type="text" value="<?php echo $row->title;?>" size="50" maxlength="50" />
</p>
<p><label>Description:</label><br>
<input name="description" type="text" value="<?php echo $row->description;?>" size="60" maxlength="100" /></p>
<p><label>Date:</label><br>
<input name="month" value="<?php echo $month;?>" type="text" class="textfield" size="5" /> /
<input name="day" value="<?php echo $day; ?>" type="text" class="textfield" size="4" /> /
<input name="year" value="<?php echo $year; ?>" type="text" class="textfield" size="4" /> <span class="note">(eg, 12/25/1988)</span</p>
<input type="submit" name="submit" value="Update Show">
<?php } ?>