0

I am using http://www.000webhost.com/ as a web server. My code works perfectly on the localhost but online I am getting this error

Parse error: syntax error, unexpected T_STRING in /home/a1582910/public_html/setcore/create.php on line 1

and I cannot fix it because I do not understand the problem because as you know the code is in one line all of it is in line one :D so

after searching i found that the names of the variables is case sensitive so i made it all in small letters and i still having the same error.

Can any one help?

I am using WAMPSERVER (32 BITS & PHP 5.4) create.php contains the following

<html>
<head>
 </head>
 <body>
 <?php
 class invoice {

 function addninvoice ($i) {

 require_once 'PHPExcel_1.7.9_doc/Classes/PHPExcel.php';
 /** PHPExcel */require_once 'PHPExcel_1.7.9_doc/Classes/PHPExcel/IOFactory.php';

  $excel2 = PHPExcel_IOFactory::createReader('Excel2007');
  $excel2 = $excel2->load('try.xlsx');

   $excel2->setActiveSheetIndex(0);
   echo"".$excel2->getActiveSheet()->getHighestRow()."";
   $psheet = $excel2->getActiveSheet();

   $excel22 = PHPExcel_IOFactory::createReader('Excel2007');
    $excel22 = $excel22->load('try.xlsx');
   $psheet->setTitle($i);
   $psheet->setCellValue('G7', $i);


   $excel22->addSheet($psheet);
  $obr = PHPExcel_IOFactory::createWriter($excel22, 'Excel2007');
  $obr->save('try1.xlsx');                           

  $excel222 = PHPExcel_IOFactory::createReader('Excel2007');
  $excel222 = $excel222->load('try1.xlsx');

  $o = PHPExcel_IOFactory::createWriter($excel222, 'Excel2007');
  $o->save('try.xlsx');

                    }       

                    }   

 $p=new invoice;
 $in = $_GET['in'];

  require_once 'PHPExcel_1.7.9_doc/Classes/PHPExcel/IOFactory.php';
  $excel2 = PHPExcel_IOFactory::createReader('Excel2007');
  $sna = $excel2->listWorksheetNames("try.xlsx");
  $df=0;
  foreach($sna as $id => $name ){ 

  if($name==$in){ $df++; }

        }

   if($df != 0){

   echo"this invoice already exist
   you can not create two invoices with the same name
   if you want to edit it just click on it from the left menu in the home page" ;

   }else{

   $p->addninvoice($in);
   ?><meta http-equiv="Refresh" content="0; url=fa.php"><?php

    }

   ?>
   </body>
   </html>

fa.php

  <html>
  <head>
  <script>
  function validateForm()
  {
  var x=document.forms["numrownamche"]["in"].value;
  if (x==null || x=="")
    {
    alert("Invoice Name Must Be Filled Out");
    return false;
    }
  }
  </script>
  </head>
  <body bgcolor="silver">
  <img src="image/Logo.gif" alt="Setcore" width="199">
  <b>create new invoice</b>



  <form name="numrownamche" action="create.php" onsubmit="return validateForm()"                                method="get">
   <br/><small>invoice number:</small> <input type="text" name="in">
   <input type="submit" value="Create">
     </form>




   <?php
   require_once 'PHPExcel_1.7.9_doc/Classes/PHPExcel/IOFactory.php';
   $excel2 = PHPExcel_IOFactory::createReader('Excel2007');
   $sna = $excel2->listWorksheetNames("try.xlsx");
   foreach($sna as $id => $name ){ 


    ?>

   <a href="fb.php?shtid=<?php echo $id; ?>" target="fb"><?php echo "".$name."<br/>";?>                        </a>




    <?php

            }

        ?>

        </body>
      </html>
4

3 に答える 3

0

空を追加してみてください

<?php
?>

<html>タグの前のファイルの先頭に。理由はわかりませんが、PHP/HTML が混在する問題が修正されていることに気付きました。

さらに、ファイルのエンコーディング/使用するエディター/コピー & ペーストなどによっては、開始タグの前に null バイトやその他の目に見えない文字が忍び寄る場合があります。最初の行全体を削除して再入力し、問題が解決するかどうかを確認してください。

于 2013-08-09T04:37:42.167 に答える
0

セミコロンのようなものが抜けていませんか;

このファイルの前にデータベース接続機能がある場合は、それも確認してください。

于 2013-08-09T03:53:36.113 に答える
0

PHPのバージョンが原因かもしれません。000webhost には php 5.2.17 があり、コードを実行できない可能性があります。

http://server12.000webhost.com/phpinfo.php

于 2013-08-09T04:16:31.133 に答える