Hi All,
Im currently working on 'localhost'. Whenever i run the following all i get is
<br /><b>Notice</b>: Undefined variable: myrow in <b>C:\wamp\www\testbin\edit\edit.php</b> on line <b>59</b><br />
<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","----","----");
//select which database you want to edit
mysql_select_db("silverlink");
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the news
$result = mysql_query("select * from indexinfo WHERE id = 1");
//run the while loop that grabs all the news scripts
//make the title a link
echo "<a href='edit.php?cmd=edit&id=$id'>$Title - Edit</a>";
echo "<br>";
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = 1;
$sql = "SELECT * FROM indexinfo WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="edit.php" method="post">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">
Title:<INPUT TYPE="TEXT" NAME="Title" VALUE="<?php echo $myrow["Title"] ?>" SIZE=30><br>
Subtitle:<INPUT TYPE="TEXT" NAME="Subtitle" VALUE="<?php echo $myrow["Subtitle"] ?>" SIZE=30><br>
Content:<TEXTAREA NAME="Content" ROWS=10 COLS=30><? echo $myrow["Content"] ?></TEXTAREA><br>
Author:<INPUT TYPE="TEXT" NAME="Author" VALUE="<?php echo $myrow["Author"] ?>" SIZE=30><br>
Date:<INPUT TYPE="TEXT" NAME="Date" VALUE="<?php echo $myrow["Date"] ?>" SIZE=30><br>
<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
</form>
<? } ?>
<?
if ($_POST["$submit"])
{
$Title = $_POST["Title"];
$Subtitle = $_POST["Subtitle"];
$Content = $_POST["who"];
$Author = $_POST["Author"];
$Date = $_POST["Date"];
$sql = "UPDATE indexinfo SET Title='$Title',Subtitle='$Subtitle',Content='$Content', Author='$Author', Date='$Date' WHERE id=$id";
$result = mysql_query($sql);
echo "Thank you! Information updated.";
}
}
?>