2016-12-10 15 views
-2

この機能では、次のエラーが発生します。基本的なphp関数で構文エラーが発生しました。

Parse error: syntax error, unexpected '$tempsql' (T_VARIABLE) in /home/vps20119/public_html/outlet/admin/internal/dcOrderFunctions.php on line 6

私はそれを取得しません。私は、$ tempsqlの定義/宣言を始める前に、構文エラーを見つけることができません。私は何を見ていますか?以下はファイル全体のコピーです。

<?php 
//A function to extract the QC from the Order number 
function orderGetQC($dropcomOrderID){ 

      //Get the Product ID from the order. 
      $tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'"; 
      //runs the query (above) and puts the resulting data into a variable called $orderInfo. 
      $orderInfo = $conn->query($tempsql); 
      $temprow = $orderInfo->fetch_assoc(); 
      $productID = $temprow['product_id']; 

      //Get the QC from the product ID. 
      $tempsql2 = "SELECT * FROM `multi_quantity_received` WHERE `product_id` = '". $productID ."'"; 
      //runs the query (above) and puts the resulting data into a variable called $productInfo. 
      $productInfo = $conn->query($tempsql2); 
      $temprow2 = $productInfo->fetch_assoc(); 
      if($productInfo->num_rows > 1){ 
       $QC = "multipleQCs"; 
      } else { 
       $QC = $temprow2['qc']; 
      } 

      return $QC; 

} 
?> 
+1

上記のコード –

+2

には、構文エラー、あなたのコードには、構文エラーが彼らではありませんが、あなたが右のコードを掲載しますが、確かに、ありません? –

+0

その行の前のコメントを削除してみてください。これは、ロングショットが、あなたは($ dropcomOrderID)orderGetQCを呼び出すとき – Machavity

答えて

0

こんばんはID10TのERROR、

私はしませんが長すぎる前に同様の問題がありました。問題だった、私のFTP(FileZillaは)代わりにASCIIモードBINARY MODEで私のファイルをアップロードを開始しました。これにより、アップロードされるファイルが圧縮されます。これは、上のコードで提示されているような単一行のコメントに続くコードでは問題を引き起こします。

は、例えば、コードのこの部分を取る:

PHPの2つの簡単な、よく書かれた行である
//Get the Product ID from the order. 
$tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'"; 

! FTPがこれらの回線を1つに集約するとどうなりますか?今の$ tempsql変数は、それがアクセス不能になって、コメントアウトされ、

//Get the Product ID from the order. $tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'"; 

お知らせ特定の状況では、それが最初のコメントによってブロックされています:あなたはこのような何かを得る(または予期しません。)。これが実際にあなたの問題である場合は、それを解決するために2つの主なことがあります。下記参照。

1.電源を入れ、単一の線がブロックコメント

オーケーにコメント、これは本当に回避策実際の修正よりもより多くのですが、この作品ならば、あなたはこれがあなたの問題であることを知っています!単一行のコメントをすべて次のようなブロックコメントに変換するだけです。

<?php 
/*A function to extract the QC from the Order number */ 
function orderGetQC($dropcomOrderID){ 

    /* Get the Product ID from the order. */ 
    $tempsql = "SELECT * FROM `oc_order_product` WHERE `order_id` = '". $dropcomOrderID ."'"; 
    /* runs the query (above) and puts the resulting data into a variable called $orderInfo. */ 
    $orderInfo = $conn->query($tempsql); 
    $temprow = $orderInfo->fetch_assoc(); 
    $productID = $temprow['product_id']; 

    /* Get the QC from the product ID. */ 
    $tempsql2 = "SELECT * FROM `multi_quantity_received` WHERE `product_id` = '". $productID ."'"; 
    /* runs the query (above) and puts the resulting data into a variable called $productInfo. */ 
    $productInfo = $conn->query($tempsql2); 
    $temprow2 = $productInfo->fetch_assoc(); 
    if($productInfo->num_rows > 1){ 
     $QC = "multipleQCs"; 
    } else { 
     $QC = $temprow2['qc']; 
    } 

    return $QC; 

} 
?> 

2. FileZilla(または関連するFTP)をバイナリからASCIIモードに変更します。

1) Open FileZilla.

2) Open the settings menu by clicking 'Edit' on the toolbar, then clicking on 'settings'.

3) Under the 'Transfers' group, click on the option called 'File Types'.

4) Select the box that says 'ASCII'.

5) Press 'OK' and try to transfer the file again. Hopefully it should work!

これは便利だったと思います!そうでない場合は、コメントを残してください。他に何かを見つけようとすることができます!

よろしく、

ティモシー

+1

は、あなたが正しい場合は、私はいけない率直 –

+1

魔術師です笑私たちはすべて推測されており、ちょうど先週、私は同じミスを犯し、今日、私はそれを指摘していますここではありません、ランダム推測が良いと思いますidea –

+1

@Dagon同様の問題を抱える人は、少なくとももう一つの人がすでに考え出した解決策を見ています。この回答(OPの問題は解決しないかもしれませんが)は、OPが他のケースで提起した質問に対する正解です。 +1私から – Daidon

関連する問題