hiya there again!!! problem again with updating. I am confused where my code went wrong. It shows no error though i have added mysql.error()..but the value is not updated in the database. Why?
PHP Code:
function print_file($filename, $coupon)
{
// path to your adobe executable
$adobe_path='"C:/Program Files/Adobe/Acrobat 6.0/Reader/AcroRd32.exe"';
if ($ext=='pdf')
{
shell_exec ($adobe_path.' /t '.$filename);
}
else if ($ext=='doc'||$ext=='rtf'||$ext=='txt')
{
$word = new COM("Word.Application");
$word->visible = true;
$word->Documents->Open($filename);
$wdStatisticPages = 2; // Value that corresponds to the Page count in the Statistics
$word->ActiveDocument->ComputeStatistics($wdStatisticPages);
$page = $word->ActiveDocument->ComputeStatistics($wdStatisticPages);
echo "<BR/>";
echo "Total Page(s) uploaded for printing : ". $page;
echo "<BR/>";
echo "<BR/>";
echo "Total Page(s) available in Coupon : ". $coupon;
echo "<BR/>";
$balance = $coupon - $page;
if($balance >0)
{
//this is where i need to update the table=quota set column Page_Count= balance
mysql_query("UPDATE quota SET Page_Count='$balance' WHERE Student_Id='$_SESSION[Student_Id]'") or die ("Error inserting Data!". mysql_error());
echo "Coupon Updated.<BR/>";
$result2 = mysql_query("SELECT Page_Count FROM quota WHERE Student_Id='$_SESSION[Student_Id]'")or die("Error!". mysql_error());
$row2 = mysql_fetch_assoc($result2);
$value2= $row['Page_Count'];
echo "You have Balance : ". $value2;
echo "<BR/>";
echo "<font face='Verdana' size='2' color=green><br>Uploaded.</font><br><br><input type='button' value='Return' onClick='history.go(-1)'>";
$word->ActiveDocument->PrintOut();
$word->ActiveDocument->Close();
$word->Quit();
mysql_query("UPDATE quota SET Page_Count='$balance' WHERE Student_Id='$_SESSION[Student_Id]'") or die ("Error inserting Data!". mysql_error());
to
PHP Code:
echo $query = "UPDATE quota SET Page_Count='$balance' WHERE Student_Id='$_SESSION[Student_Id]'";
mysql_query($query) or die ("Error inserting Data!". mysql_error());
and see what it spits out. Sometimes the error suddenly becomes completely obvious.
When this happen, the best way is print the query to test directly in the data base.
I have one sugestion about your problem, try this:
PHP Code:
//this is where i need to update the table=quota set column Page_Count= balance mysql_query("UPDATE quota SET Page_Count='".$balance."' WHERE Student_Id='".$_SESSION['Student_Id']."'") or die ("Error inserting Data!". mysql_error()); echo "Coupon Updated.<BR/>"; $result2 = mysql_query("SELECT Page_Count FROM quota WHERE Student_Id='".$_SESSION['Student_Id']."'")or die("Error!". mysql_error()); $row2 = mysql_fetch_assoc($result2);