dutchman Posted May 30, 2013 Share Posted May 30, 2013 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 Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 30, 2013 Share Posted May 30, 2013 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. Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 30, 2013 Share Posted May 30, 2013 (edited) 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 May 30, 2013 by Psycho Quote Link to comment Share on other sites More sharing options...
dutchman Posted May 31, 2013 Author Share Posted May 31, 2013 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 Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 31, 2013 Share Posted May 31, 2013 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". Quote Link to comment Share on other sites More sharing options...
dutchman Posted June 3, 2013 Author Share Posted June 3, 2013 I had indeed hoped that the code was good now. I'm not very familiar with PHP scripts. Can I upload the entire file somewhere so you can even look at it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.