Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] updating table ?!


[SOLVED] updating table ?!

Reply
  #1 (permalink)  
Old 06-05-08, 09:56 AM
reetha26 reetha26 is offline
Newbie Coder
 
Join Date: May 2008
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] updating table ?!

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"'
    
    
$ext='';
    
$ext=strrchr($filename,'.');
    
$ext=substr($ext,1);
    
$ext_xl=substr($ext,0,2);
    
    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();
        
        }
        else
        {
            echo 
"<font face='Verdana' size='2' color=green><br>Printing pages exceeded coupon value. Plese renew your coupon!</font><br><br><input type='button' value='Return' onClick='history.go(-1)'>";    
            
$word->ActiveDocument->Close();
            
$word->Quit();
        }
                
    }
    

Reply With Quote
  #2 (permalink)  
Old 06-05-08, 10:43 AM
nfriedly's Avatar
nfriedly nfriedly is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
try changing

PHP Code:

 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.
Reply With Quote
  #3 (permalink)  
Old 06-05-08, 12:35 PM
Keyne's Avatar
Keyne Keyne is offline
Newbie Coder
 
Join Date: May 2007
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
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); 
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
updating a table - php Dangar PHP 3 03-28-08 04:19 AM
MYSQL database countll Database 2 06-19-07 04:20 PM
What do you think of my database structure? Oskare100 Database 5 12-27-06 07:43 AM
League Table Updating Script j-a-m-i-n PHP 4 11-24-06 05:17 PM
Pretty simple ( i think) question any help!?!? 0o0o0 PHP 2 04-07-06 10:47 AM


All times are GMT -5. The time now is 07:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.