On Wed, 28 Nov 2001 14:32, Chris Janes wrote:
> Ok, this may well turn out to be a total newbie question. But it's got
> me stumped.
> 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 seem 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'");
Here is likely your problem; if id is an integer field, it does _NOT_
require quotes around the value to be inserted.
More generally, to debug problems inserting/updating Mysql, use
mysql_error() to return a useful error message from Mysql.
> 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
> screen, 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
> leading to further hair loss!
> Oh, and I'm sorry if this really should go to another list, but this
> was the first one that leapt to mind.
> Chris Janes
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
As a matter of fact, no, I don't have a life.
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]