Query was empty

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JimiH
Forum Commoner
Posts: 92
Joined: Thu Jun 15, 2006 6:10 am

Query was empty

Post by JimiH »

Hello

I have a tick box on my form ($commupdate) which decides if extra data is posted to a DB or not.

The code

Code: Select all

if ( $commupdate == 'on' ) {
 
            $sql="update projects set VSI_NUMBER='$VSI_NUMBER',DESC1='$DESC1',Salesman='$Salesman',ENGINEER ='$ENGINEER',Prod_Spec ='$Prod_Spec'
            ,CUSTOMER ='$CUSTOMER',SALESGROUP ='$SALESGROUP',SICCODE ='$SICCODE',Conf_fact ='$Conf_Fact',N_E ='$N_E'
            ,YEARQTY ='$YEARQTY',CHCKLRATIO ='$CHCKLRATIO',VALUEExworks ='$VALUEExworks',COMPET ='$COMPET', DATEIN ='$DATEIN'
            ,COMMENTS ='$COMMENTS',ACTIONDATE ='$ACTIONDATE',Project_Members ='$Project_Members'
            ,Gate ='$Gate',Job_No ='$Job_No',Cata_Number ='$Cata_Number',orderrec ='$orderrec',Produced_at ='$Produced_at'
            ,Status ='$Status',Suspend ='$Suspend',product = '$Product',Comm_Memb ='$Comm_Memb',ECR_NUMB = '$ECR_NUMB' where VSI_NUMBER='$VSI_NUMBER'";
          
               //echo '<pre>sql: '; print_r($sql); echo "\n</pre>\n"; 
            
            
            $sql1="insert into project_comments(ID,DESC1,Comments,ActDate,Proj_Member)
 
                    values('$VSI_NUMBER','$DESC','$COMMENTS','$ACTIONDATE','$Comm_Memb')";
                    
                    //echo '<pre>sql1: '; print_r($sql1); echo "\n</pre>\n"; 
                    
                    $result=mysql_query($sql,$connection) or die(mysql_error());
                        $result=mysql_query($sql1,$connection) or die(mysql_error()); 
 }
 
 else   {
             $sql="update projects set VSI_NUMBER='$VSI_NUMBER',DESC1='$DESC1',Salesman='$Salesman',ENGINEER ='$ENGINEER',Prod_Spec ='$Prod_Spec'
            ,CUSTOMER ='$CUSTOMER',SALESGROUP ='$SALESGROUP',SICCODE ='$SICCODE',Conf_fact ='$Conf_Fact',N_E ='$N_E'
            ,YEARQTY ='$YEARQTY',CHCKLRATIO ='$CHCKLRATIO',VALUEExworks ='$VALUEExworks',COMPET ='$COMPET', DATEIN ='$DATEIN'
            ,COMMENTS ='$COMMENTS',ACTIONDATE ='$ACTIONDATE',Project_Members ='$Project_Members'
            ,Gate ='$Gate',Job_No ='$Job_No',Cata_Number ='$Cata_Number',orderrec ='$orderrec',Produced_at ='$Produced_at'
            ,Status ='$Status',Suspend ='$Suspend',product = '$Product',Comm_Memb ='$Comm_Memb',ECR_NUMB = '$ECR_NUMB' where VSI_NUMBER='$VSI_NUMBER'";
            
            // echo '<pre>sql: '; print_r($sql); echo "\n</pre>\n";                 'Always echo BEFORE result
            
            $result=mysql_query($sql,$connection)or die(mysql_error()); 
            
           
             
 }
Now if the tick box is checked the data is posted no problem, however if the tick box is not checked the mysql displays "Query was empty" but both queries ($sql) are identical?

Hope you can help

Geoff
Post Reply