Ok, I have already posted how I have been having a problem with this script:
$newsid = $_GET['id'];
$getnews = mysql_query("SELECT * FROM news WHERE newsid='$newsid' LIMIT 1",$conn);
$newscheck = mysql_num_rows($getnews);
$news = mysql_fetch_array($getnews);
//update views LOOK HERE
if($newscheck == 1) {
$views = $news['views'];
$nextview= $views + 1;
$addsql = mysql_query("UPDATE news SET views=$nextview WHERE newsid='$newsid'",$conn);
}
//LOOK ABOVE
This was suppose to add one 'view' to the news article [counting views for popularity], but it was adding two.
I realized that a rewriterule was the problem.. here is the rule:
RewriteRule news/([0-9a-zA-Z#]+)/([0-9a-zA-Z#]+) /news.php?id=$1&title=$2
so:
news/9/mamalike
news.php?id=9&title=mamalike
When I run the file by doing the full path [no rewriterule] by news.php?, the update works perfect by adding '1'. When I do the rewritepath news/9/mamalike, the PHP error begins as it adds '2'.
What gives?
Thanks
Ryan