change the mysql query into laravel query [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have the sql query I want to change oit in laravel query
I have tried as
SELECT *
FROM chart
WHERE MONTH(STR_TO_DATE(CONCAT('01-', `month`), '%d-%M-%Y'))
IN (MONTH(meeting_start_date), MONTH(call_start_date));
$query=DB::('chart')->where(DB::raw(MONTH(STR_TO_DATE(CONCAT('01-', `month`), '%d-%M-%Y'))
IN (MONTH(meeting_start_date), MONTH(call_start_date))))->select('id')->get();
but getting Parse error: syntax error, unexpected 'IN' (T_STRING), expecting ',' or ')' error

The DB::raw method takes a string, so just enclose it properly:
$query=DB::('chart')->where(DB::raw("MONTH(STR_TO_DATE(CONCAT('01-', `month`), '%d-%M-%Y'))
IN (MONTH(meeting_start_date), MONTH(call_start_date)))")->select('id')->get();

Related

Laravel blade 3 levels quote issue [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 months ago.
Improve this question
Anyone know what's wrong with the following quote structure?
onclick="showMemberList('{{ $result[\'_id\'] }}')"
I am getting the following error:
syntax error, unexpected '"_id\"]); ?>"' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING)
I thought my structure is correct already where I escaped the ' wrapping _id
It does not need to escape the _id quotes:
onclick="showMemberList('{{ $result['_id'] }}')"

Problem with use 2 translations at 1 function Laravel? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have a function in which I need to make 3 translations for the Russian and English versions. I have done it simply:
'message' => trans('notify.craft_win') .$summa. trans('notify.craft_wumm') trans('notify.craft_chance') .$chance. '%',
but i received error:
Parse error: syntax error, unexpected 'trans' (T_STRING), expecting ']'
% it's static word, without translate.
Where can be my mistake?
Your missing a dot:
// v
'message' => trans('notify.craft_win').$summa.trans('notify.craft_wumm').trans('notify.craft_chance').$chance.'%',

PHP Inline If Syntax error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm trying to make a inline if request.
Here the code
<?=(file_exits($storage.$file.'.md5')) ? file_get_contents($storage.$file.'.md5') : file_put_contents($storage.$file.'.md5', md5_file($storage.$file)?>
The log says
syntax error, unexpected '?>', expecting ',' or ')'
What's the problem?
You've missed a closing bracket ) in the end, just before the ?>
Here is a fixed code:
<?=(file_exits($storage.$file.'.md5')) ? file_get_contents($storage.$file.'.md5') : file_put_contents($storage.$file.'.md5', md5_file($storage.$file))?>

Parse error: syntax error, unexpected '(' [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying, But I get an error
preg_match_all("#href='(.*?)' span class="meta-nav"(.*?)</span>#si",$sonuc[1],$sayfalar);
Parse error: syntax error, unexpected '(' in C:\AppServ\www\wordpress\deneme\deneme.php on line 154
How should I write it?
You have doublequotes inside your regexp, you need to escape them, because they're terminating the string that contains the regexp.
preg_match_all("#href='(.*?)' <span class=\"meta-nav\">(.*?)</span>#si",$sonuc[1],$sayfalar);
Escape your double quotes as :
preg_match_all("#href='(.*?)' <span class=\"meta-nav\">(.*?)</span>#si",$sonuc[1],$sayfalar);

I don't know how to use real path in php [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm trying to use this code but it gives me an error :
// root path defined("ROOT_PATH")
|| define("ROOT_PATH", realpath(dirname(__ FILE__) . DS."..".DS));
this is the error:
Parse error: syntax error, unexpected 'FILE__' (T_STRING) in /opt/lampp/htdocs/op/inc/config.php on line 20
You have an extra space in __ FILE__ , It should be __FILE__.
Not sure if you did that just for formatting here.

Categories