Hi,
Ive made a function called editNews($id, $subject, $news)
And im using a form to gather the information of the edited post, then modifying it... problem is im trying to add an 'edited by: <admin nick>' to the bottom of the $news var in the form of:
<br><i>edited by:</i> <a href='index.php?user=$logged_in'>$logged_in</a>
Problem is, it wont update it, sure enough if i delete that whole part, everything functions properly. More intresting I get no error, and the subject re-updates and the posting time updates aswell, just not the news body.
Here is the function aswell as the form code:
function editNews ($id, $subject, $news) {
mysql_connect($this->server, $this->db_user, $this->db_pass);
mysql_select_db($this->database);
$time = time();
$query = mysql_query("UPDATE news SET time='$time' WHERE id='$id'");
$query = mysql_query("UPDATE news SET subject='$subject' WHERE id='$id'");
$query = mysql_query("UPDATE news SET data='$news' WHERE id='$id'");
echo "News has been successfully edited.";
}
function isNews ($id) {
mysql_connect($this->server, $this->db_user, $this->db_pass);
mysql_select_db($this->database);
$query = mysql_query("SELECT id FROM news WHERE id='$id'");
$result = mysql_num_rows($query);
mysql_close();
if ($result < 1) {
return false;
}
else {
return true;
}
}
form code:
if ($edit) {
if ($editnews == "Edit News") {
$edited = "$news <br><i>edited by:</i> <a href='index.php?user=$logged_in'>$logged_in</a>";
$news = "$edited";
$scriptaz->editNews($edit, $subject, $news);
}
else {
$isNews = $scriptaz->isNews($edit);
if ($isNews) {
?>
<form method="post">
Subject: <input type="text" name="subject" value="RE: <? echo "$subject" ?>" class="edit"><br>
News:<br><textarea name="news" rows="8" cols="40" class="edit"><? echo "$news" ?></textarea><br><br>
<input type="submit" name="editnews" value="Edit News" class="button">
</form>
<?
}
else {
echo "No such news ID: #$edit";
}
}
}
the if ($edit) is there because to edit its accessed via news.php?edit=<id of post>
Now i've been racking my brain over this for 3 days now, and no one can help so ive searched for a forum and found this.
If my code is insufficent (you need more information) I will gladly post what you need.
Ive only been coding PHP and using MySQL for 7 days so Im sure its something dumb...
If you can help me at all I will appreciate it greatly, thank you.