Jump to content

Parse error: syntax error, unexpected 'INSERT' (T_STRING)


dutchman

Recommended Posts

Hello everyone,
 
I've been a few days working on solving this problem.
My compatriots unfortunately can not help me.
 
Which one of you can help me?
 
Parse error: syntax error, unexpected 'INSERT' (T_STRING) in / homepages/28 / ************* / htdocs / ********** the ftp /.. idealcheckout / install.php on line 85

 

install.php

Link to comment
Share on other sites

Hmm, based on the file you provided, I don't see a problem on line 85, but I do see a problem on lines 101, 130, 159, 188, 217 and 246

 

Line 101

 

            $sql = "INSERT INTO `" . $aIdealCheckout['database']['prefix'] . "payment_cost` SET `payment_cost_id` = NULL, `payment_id` = '" . $iPaymentId . "', `payment_geo_zone` = '0', `payment_country_code` = NULL, `payment_type_value_from` = '0.00', `payment_type_value_to` = '0.00', `payment_price` = '0.0000', `payment_cost_discount` = '0', `payment_cost_percent` = '0', `payment_allowed` = '1';

 

There needs to be a closing double quote at the end of the strings. Get yourself an editor that does textual highlighting of the code and these errors will be readily apparent. Also, I didn't read through all of that code, but there are plenty of "problems" and it seems to be much more complicated than it should be.

 

For example this:

 

    // Insert plugins
    $sql = "INSERT INTO `" . $aIdealCheckout['database']['prefix'] . "plugin_products` SET `plugin_id` = NULL, `name` = 'iDEAL Checkout - iDEAL', `version` = '1.0.0', `description` = 'iDEAL Checkout Gateway', `url` = 'https://www.ideal-checkout.nl', `plugin_status` = '1', `code` = 'xt_idealcheckoutideal', `type` = 'payment';";
    if(idealcheckout_database_query($sql))
    {

$sql is just a query defined as a string. It isn't executed. So that if() condition will always be true.

 

Also, you appear to be running the same processes over and over with only slight differences. Create a loop or function to run ONE process and change the parameters accordingly.

Link to comment
Share on other sites

OK, I didn't see that you were actually executing the query int he if() condition. So, that would be valid. I prefer to execute my queries and assign them to a variable - then check the variable. Gives me more flexibility. Anyway, based upon what I see you repeat the same process seven times only changing the values for the name and code within the queries. So, you can just build an array of those values and write the logic once and just repeat for each pair of values.

 

Also, instead of defining a lot of the values for the INSERT queries, you can define defaults for those fields in the database so you can remove those fields from the SET part of your queries. For example, if 'payment_price" should always default to 0.000 for new records (unless otherwise defined), just set that as the default for the field in the database. Then, when creating a new record you don't have to include that field in the INSERT statement if you want it to have the default value. You would only need to include the field in your INSERT statemetns if you want it to have a value that is not the default. Doing that would greatly clean up the code.

 

But, here is a rewrite that creates a loop to run the same queries with different values that would remove a couple hundred lines of code and maker the script less likely to have errors.

    $paymentTypes = array(
        'iDEAL Checkout - iDEAL'            => 'xt_idealcheckoutideal',
        'iDEAL Checkout - MisterCash'       => 'xt_idealcheckoutmistercash',
        'iDEAL Checkout - Direct E-Banking' => 'xt_idealcheckoutdirectebanking',
        'iDEAL Checkout - Credit Card'      => 'xt_idealcheckoutcreditcard',
        'iDEAL Checkout - MiniTix'          => 'xt_idealcheckoutminitix',
        'iDEAL Checkout - PayPal'           => 'xt_idealcheckoutpaypal',
        'iDEAL Checkout - PaySafeCard'      => 'xt_idealcheckoutpaysafecard'
        );

    // Insert plugins
    $PREFIX = $aIdealCheckout['database']['prefix'];
    foreach($paymentTypes as $paymentName => $paymentCode)
    {
        $sql = "INSERT INTO `{$PREFIX}plugin_products`
                SET `plugin_id` = NULL, `name` = '{$paymentName}', `version` = '1.0.0', `description` = 'iDEAL Checkout Gateway',
                    `url` = 'https://www.ideal-checkout.nl', `plugin_status` = '1', `code` = '{$paymentCode}', `type` = 'payment';";
        if(!idealcheckout_database_query($sql))
        {
            $query_html .= "<b>Query:</b> {$sql}<br><b>Error:</b> " . idealcheckout_database_error() . "<br><br><br>";
        }
        else
        {
            $iPluginId = idealcheckout_database_insert_id();
            $sql = "INSERT INTO `{$PREFIX}payment`
                    SET `payment_id` = NULL, `payment_code` = '{$paymentCode}', `payment_dir` = '{$paymentCode}', `payment_icon` = NULL, `payment_tax_class` = '1',
                        `payment_tpl` = NULL, `status` = '1', `sort_order` = '1', `plugin_required` = '0', `plugin_installed = '{$iPluginId}';";
            if(!idealcheckout_database_query($sql))
            {
                $query_html .= "<b>Query:</b>{$sql}<br><b>Error:</b> " . idealcheckout_database_error() . "<br><br><br>";
            }
            else
            {
                $iPaymentId = idealcheckout_database_insert_id();

                $sql = "INSERT INTO `{$PREFIX}payment_description`
                        SET `payment_id` = '{$iPaymentId}', `language_code` = 'nl', `payment_name` = 'iDEAL';";
                idealcheckout_database_query($sql);

                $sql = "INSERT INTO `{$PREFIX}payment_description`
                        SET `payment_id` = '{$iPaymentId}', `language_code` = 'en', `payment_name` = 'iDEAL';";
                idealcheckout_database_query($sql);

                $sql = "INSERT INTO `{$PREFIX}payment_cost`
                        SET `payment_cost_id` = NULL, `payment_id` = '{$iPaymentId}', `payment_geo_zone` = '0', `payment_country_code` = NULL,
                             `payment_type_value_from` = '0.00', `payment_type_value_to` = '0.00', `payment_price` = '0.0000',
                             `payment_cost_discount` = '0', `payment_cost_percent` = '0', `payment_allowed` = '1'";
                idealcheckout_database_query($sql);
            }
        }
    }
Edited by Psycho
Link to comment
Share on other sites

Hello Psycho,

 

Thanks in advance for your help.
The script that you created, and thank you, I get the following error message:
 
Fatal error : Call to undefined functie idealcheckout_database_query () in / homepages/**/************/htdocs/ftp.*******.de/idealcheckout/install.php on line 20
 
Please can you help me?
 
Thanks,
 
Kind regards,
 
Dutchman
Link to comment
Share on other sites

The script that you created, and thank you, I get the following error message:

 
Fatal error : Call to undefined functie idealcheckout_database_query () in / homepages/**/************/htdocs/ftp.*******.de/idealcheckout/install.php on line 20
 
Please can you help me?

That function was referenced in your original code, but I don't know what the function is, where it is located, or how it was initiated in your original code. How can I help you? Did you simply copy/past the code I provided and try to execute it? Did you include all the other necessary code from your original script (such as the include file?). The code I provided was only meant to replace the large section of code related to the comment "// Insert plugins".

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.