Nothing is being updated because $id is empty and in fact is not even set.
You need to pass the id via a hidden form variable in order to get the
results you expect.
In the future I suggest always debugging your scripts by echoing your
variables so that you can determine if they contain what you think they
Chris Janes <[EMAIL PROTECTED]> wrote in message
> Ok, this may well turn out to be a total newbie question. But it's got me
> I'm trying to create a small, simple news system for a personal website.
> I've gotten sections to insert the news into the database. but I can't
> to get it to update itself.
> So far I have
> (This is a login script to authenticate users, so they cannot access pages
> by merely typing the address into the address bar.
> It references the database connection script, so that I shouldn't need to
> call that again. Is that right?)
> mysql_query ("UPDATE news SET subject='$newsubject', content='$newcontent'
> WHERE id='$id'");
> The $newsubject and $newcontent variables are taken from the results of a
> form on an earlier page. when the script is run through in full, I get no
> errors, but the database is not updated.
> The table has the following format
> id, date, subject, content, user
> I can get the correct news entry displayed in the forms on previous
> where the altering takes place. (code for the form is below)
> <form name="news" method="get" action=alternews.php>
> <input type="hidden" name="user" value="<?=$username?>">
> <input type="text" name="newsubject" maxlength="120"
> <textarea name="newcontent" rows="6"
> <p align="right">
> <input type="submit" name="Submit" value="Submit">
> <input type="reset" name="reset" value="Reset">
> The variables are passed through to the page that actually performs the
> update, but the update never takes place. I don't get an error from MySQL,
> or a parsing error from PHP, all the pages display as if the update had
> taken place.
> Can anyone see what I'm doing wrong?
> This all seemed like a good way of learning PHP and MySQL, it's just
> to further hair loss!
> Oh, and I'm sorry if this really should go to another list, but this was
> first one that leapt to mind.
> Chris Janes
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]