phpmysqlcodeigniterpayumoney

payumoney integration with codeigniter


I am integrating payu money in my website.After successful transfer, the page is giving following error

A PHP Error was encountered Severity: Notice

Message: Undefined variable: company

Filename: controllers/Company_Controller.php

Line Number: 1308

A Database Error Occurred Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'limit 1' at line 1

SELECT comp_name, comp_email FROM company where comp_id= limit 1

Filename: models/Common_model.php

Line Number: 187

This is my order my controller

public function OrderSuccess()
    {
        if ($this->Common_model->Is_Company_Logged()) 
        {
            if(isset($_POST['status']) && $_POST['status']=='success' && $packid=$_POST['udf1']>0)
            {
                //---------------- Generate Order ----------------------//
                $packid=$_POST['udf1'];
                $sql_pack="SELECT package_title, package_price, package_month, package_jobs FROM package where package_id=".$packid." limit 1";
                $pack=$this->Common_model->get_data_by_query($sql_pack);
                $sql_comp="SELECT comp_name, comp_email FROM company where comp_id=".$company['id']." limit 1";
                $comp=$this->Common_model->get_data_by_query($sql_comp);
                print_r($pack); exit;
                $data=array();
                //------------------ Insert in Order Table -------------------//
                $ordercode=$this->Common_model->Generate(8, 'both');
                $tax=($pack[0]->package_price*18)/100;
                $total=round($pack[0]->package_price+$tax);
                $order['order_code']=$ordercode;
                $order['order_package']=$packid;
                $order['order_company']=$company['id'];
                $order['order_cost']=$pack[0]->package_price;
                $order['order_tax']=$tax;
                $order['order_total']=$total;
                $order['order_date']=date('Y-m-d H:i:s');
                $order['order_note']='';
                $order['order_paid']=1;
                $order_insert=$this->Main_model->insertQuery('company_orders',$order);
                if($order_insert)
                {
                    $order_id=$this->db->insert_id();
                }
                //---------------- Insert In company pack table --------------//
                $cpack['cpack_package']=$packid;
                $cpack['cpack_orderid']=$order_id;
                $cpack['cpack_company']=$company['id'];
                $cpack['cpack_validfrom']=date('Y-m-d');
                $cpack['cpack_validto']=date('Y-m-d', strtotime('+'.$pack[0]->package_month.' month'));
                $cpack['cpack_months']=$pack[0]->package_month;
                $cpack['cpack_jobs']=$pack[0]->package_jobs;
                $cpack['cpack_date']=date('Y-m-d H:i:s');               
                $cpack_insert=$this->Main_model->insertQuery('company_pack',$cpack);    
                //-------------------------------------------------------------//
                $maildata['package']=$pack[0]->package_title;
                $maildata['comp_name']=$comp[0]->comp_name;
                $maildata['comp_email']=$comp[0]->comp_email;
                $this->EmailNotifications->SendEmail(3, $maildata);
                $this->EmailNotifications->SendEmail(4, $maildata);
                $this->session->unset_userdata('company_cart');
                //------------------------------------------------------//
                $this->load->view('company/header');
                $this->load->view('company/success_order');
                $this->load->view('company/footer');
            }
            else
            redirect('company/');
        }
        else 
        {   
            redirect('company/');
        }       

    }

I will be gratefulfor your guidance.


Solution

  • I forgot to declare variable company

    $company=$this->session->userdata('company_logged_in');