code not working, PHP says it is!!!
Posted: Wed Mar 10, 2004 2:54 am
ok, its a simple PHP script to insert data based on a condition being met
for some godforesaken reason that i cant see it wont work, if anyone can see an error here (which i cant) then please share it
i even call affected_rows() which returns a value of 1, so it is working#
but when i go into MySQLFront and PHPmyAdmin both havent changed
any ideas?
for some godforesaken reason that i cant see it wont work, if anyone can see an error here (which i cant) then please share it
i even call affected_rows() which returns a value of 1, so it is working#
but when i go into MySQLFront and PHPmyAdmin both havent changed
any ideas?
Code: Select all
<?php
require ("dbhandler.php");
// ill create a dummy var just so the script thinks it's set
$add_article = "Yes";
// first we'll run a query to find out the value of the items in the database
$query = "SELECT Articles, Downloads, Comments FROM stats" or die(mysql_error());
$statvalues = mysql_query($query);
$values = mysql_fetch_array($statvalues, MYSQL_ASSOC) or die(mysql_error());
// now lets make the newly created variables look nicer
$old_articles = $values['Articles'];
$old_downloads = $values['Downloads'];
$old_comments = $values['Comments'];
// now we need to add 1 to the current value and then reinsert it into the database
// lets create a function so i dont have to constantly write out the same script for each
// condition
if (isset($add_article))
{
// this is run only if someone has added an article to the database
$new_article_result = ($old_articles + 1);
// now we have the new value we will run an update statement
$update = "UPDATE stats SET Articles='$new_article_result' WHERE Articles='$old_articles' AND Downloads='$old_downloads' AND Members=$old_members AND Comments=$old_comments'" or die (mysql_error());
$affectedrows = mysql_affected_rows();
print "Added Successfully!\n The New Value of Articles Is --> $new_article_result ";
// this script is not working for some stupid reason, MYSQL
// is not throwing up an error and my conditional print statement is printing
// it even tells me how many rows it has just affected (1)
// however when i check the database its not updated it
// any ideas?
}
else
{
print " var not set";
}
?>
<?php
print "
Old Articles = $old_articles\n
Old Downloads = $old_downloads\n
Old Comments = $old_comments\n
New Articles = $new_article_result\n
The query has affected $affectedrows rows
"
?>