-2

I keep getting the following error for this function.

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

I don't get it. I can't find any syntax errors before I start defining / declaring the $tempsql. What am I over looking? Below is a copy of the entire file.

<?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 Answers1

0

Good evening ID10T ERROR,

I had a similar issue not too long ago. The problem was, my FTP (FileZilla) started uploading my files in BINARY MODE instead of ASCII MODE. This causes the file being uploaded to get condensed. This causes a problem for code following single-line comments, such as the one presented in your code above.

Take this piece of code for example:

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

That is two simple, well-written lines of PHP! But what happens if the FTP condenses those lines into one? You get something like this:

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

Notice, now the $tempsql variable is commented out, making it inaccessible (Or unexpected.) In your specific situation, it's being blocked by that first comment. If this is, indeed, your issue, there's two main things you can do to fix it. See below.

1. Turn single-line comments into block comments

Okay, this is really more of a work-around than a real fix, but if this works, you know that this is your issue! Simply turn all of your single-line comments into block comments like below.

<?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. Change FileZilla (or related FTP) from Binary to ASCII mode.

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!

I hope this was useful! If not, please leave a comment and we can try to figure something else out!

Regards,

Timothy

Timothy Bomer
  • 504
  • 5
  • 21
  • 1
    if you are right you are magician – arif_suhail_123 Dec 10 '16 at 03:57
  • 1
    frankly i dont think random guessing is a good idea –  Dec 10 '16 at 06:17
  • 1
    @Dagon People who get a similar problem will at least see one solution that another person has already figured out. This answer (although it might not solve the OP's problem) is still a correct answer to the question that the OP posed in other cases. +1 from me – Daidon Dec 10 '16 at 06:34
  • Good afternoon, do you believe this was an off-topic answer? I believed that it was definitely a plausible solution as OP's variable is not being recognized. My solution above shows that the code being condensed would cause the variable to be hidden, which in turn, would cause the error OP presented us with. Please correct me if I am wrong though, I don't want to be giving out false information. Thank for for the +1 Daidon! – Timothy Bomer Dec 10 '16 at 16:54