How to fix this syntax error, please help me [closed] - syntax

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
when i run file its appear with error
Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/beddings/public_html/mybabystore.com.au/admin/categories.php on line 2364
here is my code
$contents[] = array(
'align' => 'center',
'text' => '<br><a href="' .
tep_href_link(
FILENAME_CATEGORIES,
'&cPath='. $cPath.'&cID='.$cID.'&checkall=1')
. '" onClick="setCheckboxes('mainForm', true); return false;">[Check All Products]</a> <a href="'
. tep_href_link(FILENAME_CATEGORIES, '&cPath='. $cPath.'&cID='.$cID)
. '" onClick="setCheckboxes('mainForm', true); return false;">[Un Check All]</a>'
);

The error is here, you need to escape your single quotes
setCheckboxes(\'mainForm\', true);
^----------^
//You are using this twice so escape the other one too

Try this You need to escape the single quotes
$contents[] = array('align' => 'center', 'text' => '<br>[Check All Products] [Un Check All]');

Try this one :
$contents[] = array('align' => 'center', 'text' => '<br>[Check All Products] [Un Check All]');

Related

Very strange error with Carbon and Laravel

I'm using Laravel for one of my project. Everything is just fine, but I can't solve a strange error.
I'm sending duration in years from my front end (Vuejs).
If client is on any active plan then plan start should be the current plan end date else set to now().
Add years in start time and set as plan end.
Now when I do this in actual code, I see same start and end date generated according to plan end.
$start = Carbon::parse($client->plan_end) ?: Carbon::now();
$end = $start->addYears($request->planDetails['duration']);
return response([
'start' => $start,
'end' => $end,
]);
This is plan_end timestamp in database -- 2022-05-09 09:15:19
This is response I receive.
{
"start" : "2024-05-09T07:15:19.000000Z",
"end" : "2024-05-09T07:15:19.000000Z"
}
So carbon is mutable which means that when you do ->addYears() it will alter the original start date time. You can use the ->copy() function before adding the years so it would look like this.
$end = $start->copy()->addYears($request->planDetails['duration']);
Using ->copy() is fine, but using CarbonImmutable as default is likely better as it will avoid similar pain to happen again:
$start = CarbonImmutable::parse($client->plan_end) ?: CarbonImmutable::now();
$end = $start->addYears($request->planDetails['duration']);
return response([
'start' => $start,
'end' => $end,
]);

How do I fix this SQL Syntax error concerning blobs?

i have a new forum up using SMF, and i’m trying to convert the database to UTF-8 now. SMF provides an easy way to do this, but upon doing so, i get this strange sounding error:
you have an error in your sql syntax; check the manual that corresponds to your mariadb server version for the right syntax to use near 'before before blob not null,
change column after after blob not null,
...' at line 6
file: /home/halfmoon/public_html/sources/managemaintenance.php
line: 664
i’m an extreme newbie to coding, especially when it comes to SQL, so i have 0 idea what the error means, other than where to find it and that the line is incorrect. if need be i can also copy and paste the line’s full text here as well- not sure what all is needed!:
line 664 starts at ‘updates_blob’
SQL Vers.:
“
// Change the columns to binary form.
$smcFunc['db_query']('', '
ALTER TABLE {raw:table_name}{raw:updates_blob}',
array(
'table_name' => $table_info['Name'],
'updates_blob' => substr($updates_blob, 0, -1),
)
);
MariaDB Vers.:
// Convert the character set if MySQL has no native support for it.
if (isset($translation_tables[$_POST['src_charset']]))
{
$update = '';
foreach ($table_charsets as $charset => $columns)
foreach ($columns as $column)
$update .= '
' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
$smcFunc['db_query']('', '
UPDATE {raw:table_name}
SET {raw:updates}',
array(
'table_name' => $table_info['Name'],
'updates' => substr($update, 0, -1),
)
);
}port for it.”

How to filter {ITEM_TITLE} and {ITEM_DESCRIPTION} osclass keywords before using them in emails?

How to filter {ITEM_TITLE} and {ITEM_DESCRIPTION} osclass keywords before using them in emails?
I want to apply a function on the item_title and item_description before using them in emails.
Ex.
Title: Sell bmw_ x5__
To become
Sell bmw x5
without changing the database values
I have the function
removeunderline(argument) that works, I only need to know from where to call it or where to use it.
(Osclass forums are blocked for new users, that's why I ask here)
/oc-includes/osclass/emails.php
Put removeunderline() at {ITEM_TITLE} and {ITEM_DESCRIPTION} values.
Example:
$words = array();
$words[] = array(
'{ITEM_DESCRIPTION_ALL_LANGUAGES}',
'{ITEM_DESCRIPTION}',
'{ITEM_COUNTRY}',
'{ITEM_PRICE}',
'{ITEM_REGION}',
'{ITEM_CITY}',
'{ITEM_ID}',
'{USER_NAME}',
'{USER_EMAIL}',
'{ITEM_TITLE}',
'{ITEM_URL}',
'{ITEM_LINK}',
'{VALIDATION_LINK}',
'{VALIDATION_URL}',
'{EDIT_LINK}',
'{EDIT_URL}',
'{DELETE_LINK}',
'{DELETE_URL}'
);
$words[] = array(
$all,
removeunderline($item['s_description']), // here
$item['s_country'],
osc_format_price($item['i_price']),
$item['s_region'],
$item['s_city'],
$item['pk_i_id'],
$item['s_contact_name'],
$item['s_contact_email'],
removeunderline($item['s_title']), // here
$item_url,
$item_link,
'<a href="' . $validation_url . '" >' . $validation_url . '</a>',
$validation_url,
'' . $edit_url . '',
$edit_url,
'' . $delete_url . '',
$delete_url
);
Do the same for all {ITEM_TITLE} in this file (10 replacements).
Do the same for all {ITEM_DESCRIPTION} in this file (3 replacements).

Drupal 7 Javascript does not store values

I am getting data through Ajax call. That data has following code that stores some value from PHP to Javascript variables using .data(). I am pretty sure php variable has valuesbut values does not get stored in js. Take a look
So there is ajax method
'#ajax' => array(
'callback' => 'a_e_get_score',
It calls the function that has js code
$out .= '
<script type="text/javascript">
jQuery("#chkso").data("paragraphs",' . json_encode($this->result->data->analysis->so->paragraphs) . ');
jQuery("#chkso").data("domExpression",' . json_encode($this->result->data->analysis->so->paragraphDOM) . ');
jQuery("#chkso").data("tooSimpleColor",' . json_encode($light_blue) . ');
jQuery("#chkso").data("tooComplexColor",' . json_encode($light_orange) . ');
</script>';
return $out;
Now when I try to run
$("#chkso").data('paragraphs');
it says undefined.
How do I really pass these values ? I know there is another way mentioned here but that does not seems to work for me as well.
Please guide
If you use the drupal_add_js() function.
drupal_add_js(array('myModule' => array('key' => 'value')), 'setting');
then in your javascript file you can access your value like this:
Drupal.settings.myModule.key
If you want to send data to javascript from your module file only, you don't need to use this
'#ajax' => array(
'callback' => 'a_e_get_score',
Thank all for the help. drupal_json_encode did the trick for me. Following code works with no problem.
$out .= '<script type="text/javascript">
var tooSimpleColor = ' . drupal_json_encode($light_blue) . ';
var tooComplexColor = ' . drupal_json_encode($light_orange) . ';
var domExpression = ' . drupal_json_encode($this->result->data->analysis->so->paragraphDOM) . ';
var paragraphs = ' . drupal_json_encode($this->result->data->analysis->so->paragraphs) . ';
</script>';
Regards,

What's wrong with this code? SimpleXMLElement [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
$fn = $Cache_Path . '/n' . $Node . '.xml';
$store = file_get_contents( $fn );
SimpleXMLElement;
$xml = new ( $store );
$link = '';
Error:
Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '$' in.....
You probably mean:
$fn = $Cache_Path . '/n' . $Node . '.xml';
$store = file_get_contents( $fn );
$xml = new SimpleXMLElement ( $store );
$link = '';

Resources