SriMouni Balantrapu
SriMouni Balantrapu

Reputation: 1

php file is not showing when i uploade into server

this is the php which uploads excel file to my database but when i uploaded this into server when i am clicking on this file its not displaying anything.why is it happening.its not even navigating but showing an empty page

 include 'Excel/reader.php';
        $retailername=$_SESSION['logged_name'];
        //require('SpreadsheetReader.php');
        set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
        include 'PHPExcel/IOFactory.php';


        if(isset($_POST['submit']))
        {
            $filename=$_FILES["csvFile"]["tmp_name"];


             if($_FILES["csvFile"]["size"] > 0)
             {

                $file = fopen($filename, "r");
                 while (($data = fgetcsv($file, 10000, ",")) !== FALSE)
                 {
                    $query = mysql_query("INSERT into chemicalbb(`CATEGORY`,`SUBCATEGORY`, `PRODUCT_DESCRIPTION`, `BRAND`, `PRODUCT_ID`, `QUANTITY`, `PRICE`,`vendor_name`,`PRODUCTNAME`,`EMPTY1`) 
                        values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$retailername','$data[7]','')");
                        mysql_query($query);

                 }
                fclose($file);


             }

            else if($_FILES['excelFile']['size']>0) 
            {

                $filename = basename($_FILES["excelFile"]["name"]);
                move_uploaded_file($_FILES["excelFile"]["tmp_name"], $filename);
                            try {
                                $objPHPExcel = PHPExcel_IOFactory::load($filename);
                                    } catch(Exception $e) {
                                        die('Error loading file "'.pathinfo($filename,PATHINFO_BASENAME).'": '.$e->getMessage());
                                    }
                        $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
                        $arrayCount = count($allDataInSheet); 
                for($i=2;$i<=$arrayCount;$i++)
                {
                    $CATEGORY=trim($allDataInSheet[$i]["A"]);
                    $SUBCATEGORY=trim($allDataInSheet[$i]["B"]);
                    $PRODUCT_DESCRIPTION=trim($allDataInSheet[$i]["C"]);
                    $BRAND=trim($allDataInSheet[$i]["D"]);
                    $PRODUCT_ID=trim($allDataInSheet[$i]["E"]);
                    $QUANTITY=trim($allDataInSheet[$i]["F"]);
                    $PRICE=trim($allDataInSheet[$i]["G"]);
                    $PRODUCTNAME=trim($allDataInSheet[$i]["H"]);
                    $query = mysql_query("INSERT into chemicalbb(`CATEGORY`,`SUBCATEGORY`, `PRODUCT_DESCRIPTION`, `BRAND`, `PRODUCT_ID`, `QUANTITY`, `PRICE`,`vendor_name`,`PRODUCTNAME`,`EMPTY1`) 
                        values('$CATEGORY','$SUBCATEGORY','$PRODUCT_DESCRIPTION','$BRAND','$PRODUCT_ID','$QUANTITY','$PRICE','$retailername','$PRODUCTNAME','')");
                        mysql_query($query);
                }


        }
        echo "<script type=\"text/javascript\">
                            alert(\" File has been successfully Imported.\");
                            window.location = \"landing.php\"
                        </script>";
        }
        if(isset($_POST['delete']))
        {
            mysql_query("DELETE FROM chemicalbb where vendor_name='$retailername'");
        }


    <div class="control-group">
                                <div class="control-label">
                                    <label>Select CSV File</label>
                                </div>
                                <div class="controls">
                                    <input type="file" name="csvFile" class="input-large">
                                </div>
                            </div>
                            or
                            <div class="control-group">
                                <div class="control-label">
                                    <label>Select Excel File</label>
                                </div>
                                <div class="controls">
                                    <input type="file" name="excelFile" class="input-large">
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="controls">
                                <button type="submit" id="submit" name="submit" class="btn btn-primary button-loading" data-loading-text="Loading...">Upload</button>
                                </div>

Upvotes: 0

Views: 59

Answers (1)

Jaswant Singh
Jaswant Singh

Reputation: 21

There's a syntax error. You must close PHP tag as below in last line

close php tag after

if(isset($_POST['delete']))
    {
        mysql_query("DELETE FROM chemicalbb where vendor_name='$retailername'");
    }
?>   //  Close Php Tag here

Upvotes: 1

Related Questions