Hey all, The other day I got my script to update perfectly using the code below and since I have asked my host to turn off resgister globals but now my script doesn't work. Can anyone tell me why? I added the mysql_affected_rows() code to it and it updates 0 please help if you can. Sorry for the messy code but thats the whole editarticle.php file. I get it to display the article in the fields so it can be edited. Like I said worked fine before I turned off register globals.
if ($_GET['action'] == 'edit')
{
$_POST['name'];
$_POST['descrip'];
$_POST['group'];
$_POST['article'];
if ($lookat->foundErrors())
{
echo 'There was a problem with: <br>'.$lookat->listErrors('<br>');
}else{
$edit = "UPDATE articles SET name = '$name',descrip = '$descrip',group = '$group',article = '$article' WHERE ID = '$ID'";
if ($found = $connect->query($edit))
{
echo 'Article edited. <a href="articles.php">Back to articles index</a><br>';
printf ("Updated records: %d\n", mysql_affected_rows());
}else{
exit('There was an error saving to the database');
}
}
}
{
$found = $connect->query("SELECT ID,name,descrip,group,article FROM articles WHERE ID = ".$_GET['ID']);
while ($row = $connect->fetchArray($found))
{
$ID = $row['ID'];
$name = $row['name'];
$descrip = $row['descrip'];
$group = $row['group'];
$article = $row['article'];
echo "<form method=post action=editArticles.php?action=update&ID=$ID>";
echo "<table border=0 cellspacing=0 cellpadding=5><tr><td width=110>Article:</td>
<td><input type=text size=25 ID=name name=name value=\"$name\"></td></tr>";
echo "<tr><td>Article:</td><td><input type=text size=50 ID=descrip name=descrip value=\"$descrip\"></td></tr>";
echo "<tr><td>Group:</td><td><select name=group ID=group value=$group>";
$found = $connect->query('SELECT ID,name FROM sections ORDER BY name');
while ($row = $connect->fetchArray($found))
{echo '<option value="'.$row['ID'].'">'.$row['name'].'</option>';}
echo "</td></tr>";
echo "<tr><td valign=top>Article Text:</td>
<td><textarea rows=18 cols=50 ID=article name=article>$article</textarea></td></tr>";
echo "<tr><td></td><td align=right><input type=reset value=Clear Form>
<input name=submit type=Submit value='Update Article'></td></tr></table></form>";
}
}
?>
I have been trying to sort it out the past 6 hours 🙁