My first question: PHP won't update MySQL
| From: | Timothy D. Arnold | Date: | Wed, 28 Mar 2001 17:19:23 +0000 |
| Subject: | My first question: PHP won't update MySQL | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7939@lists.php.net to get a copy of this message | ||
Hello,
I am new to PHP as well as this list. I have taken another page that does work and tried to modify
it to use
a new MySQL table ("story"). I haven't made any major changes, but the new page does
not work.
Here is the page that works: http://phenon.com/nothing/favorite_color.php
Here is the page that does not: http://phenon.com/nothing/story_edit.php
I believe that the problem is in the following batch of code...
Thanks,
Tim
arnold@phenon.com
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
if ($id) {
echo "<b>Edit Story:</b><br><br>";
$sql = "SELECT * FROM story WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["id"];
$title = $myrow["title"];
$body = $myrow["body"];
?>
<input type=hidden name="id" value="<?php echo $id ?>">
<?php
}
?>
<table border=0>
<tr valign=top>
<td>
<font face=verdana size=2>Title</font></td>
<td>
<input type="Text" name="title" value="<?php echo $title
?>" size=35></td>
</tr>
<tr valign=top>
<td>
<font face=verdana size=2>Story:</font></td>
<td>
<textarea name="body" ROWS=10 COLS=65 WRAP=on><?php echo $body
?></textarea></td>
</tr>
<tr>
<td>
</td>
<td>
<input type="Submit" name="submit" value="Enter
Information"></td>
</tr>
</table>
</form>