I am Getting a syntax error, while installing yeesoft/yii2-yee-core through composer.
ERROR: Parse error: syntax error, unexpected ';', expecting ']' in C:\new\htdocs\mysite.com\common\config\main.php on line 19
Code Snippet:
code snippet part1 and
code snippet part2
On line 19 you have:
'rules' => array[
This is syntactically incorrect. You should change this to:
'rules' => [
Since you typically define an array in either one of two ways:
$array = ['value_one', 'value_two'];
$another_array = array('value_one', 'value_two');
See Array Syntax in the PHP documentation.
In my case it was a syntax error, with a bracket at a location missing.
If you have any other points to add, please do.
Related
I want to use openweather in my app.
It works good to write directly api_key.
However I introduce ENV, It won't work.
Anyone konws how to fix it?
quesiton is bellow
static_pages_controller.rb
...
uri = URI.parse('http://api.openweathermap.org/data/2.5/weather?q=Tokyo&appid=ENV['OPEN_WEATHER_API_KEY']')
json = Net::HTTP.get(uri)
res = JSON.parse(json)
#wind = res['wind']['speed']
#humidity = res['main']['humidity']
#clouds = res['clouds']['all']
...
.env
OPEN_WEATHER_API_KEY=20ab....
error code
/Users/sy/env2/ji-boys/app/controllers/static_pages_controller.rb:19:
syntax error,
unexpected tCONSTANT, expecting ')' ...appid=ENV['OPEN_WEATHER_API_KEY']') ... ^~~~~~~~~~~~~~~~~~~~
/Users/sy/env2/ji-boys/app/controllers/static_pages_controller.rb:19:
syntax error, unexpected ')', expecting end ...d=ENV['OPEN_WEATHER_API_KEY']') ... ^
I think ...appid=ENV['OPEN_WEATHER_API_KEY'].. is wrong.
Searching for how to write code, but can't find that.
Anyone knows this, please teach me how to fix it.
Thank you for reading this.
You need to do string interpolation to embed value
URI.parse("http://api.openweathermap.org/data/2.5/weather?q=Tokyo&appid=#{ENV['OPEN_WEATHER_API_KEY']}")
I'm playing with lua, using the following link: https://www.lua.org/pil/8.html and got confused about this syntax error.
So, the file foo.lua is as the following:
function foo (x)
print(x)
end
Then,
~$ f = loadfile("foo.lua")
bash: syntax error near unexpected token `('
Any comments are greatly appreciated.
this code return an error
db[:zips].find(city: {$lt: 'd'}).limit(2).to_a.each{|r| pp r}
syntax error, unexpected '}', expecting end-of-input
However, this code works well
db[:zips].find(city: {:$lt=> 'd'}).limit(2).to_a.each{|r| pp r}
Why can not use :$lt like the first one?
You can't use the JSON-like {key: value} syntax in this case , because the key starts with $. Either use the older hash syntax or, since ruby 2.2,
{'$lt': 'd'}
I couldn't find a reference for when quoting is required (emojis are OK for example) - I suspect you would have to delve into the ruby source for this.
So I made my own habbo retro, and everything was done. But when I went to check it out, I got this error:
Parse error: syntax error, unexpected T_STRING in C:\Program Files\xampp\htdocs\app\management\config.php on line 37
I checked it out, and this is what I have
/*
*
* Hotel management - All URLs do not end with an "/"
*
*/
$_CONFIG['hotel']['name'] = 'Habbeen'; // Your Hotel's Name
$_CONFIG['hotel']['desc'] = 'If you're bored, come here to feed your hunger.'; //Hotel's description
That is line 37 above this sentence. Why is that error coming up?
I don't know what a habbo retro is but your problem is because of the apostrophe in the "you're", you should escape it like this:" "you\'re"
I am getting a strange SytaxError with JSLint
I have a file with no code except:
var a = function(){
if(isChecked())
{ }
};
And I get this error:
SyntaxError: missing ; before statement
if(isChecked())
......^
I made another file with only if(Math.Round()) { alert('here');}, and I get
SyntaxError: missing ; before statement
if(Math.Round()) { alert('here');}
....................^
I built jslint for Ubuntu and the error does not appear on the online lint site. I just need to ignore this error, but /jsl:ignore/ does not work (maybe because it is a syntax error.
It appears that there is some kind of encoding error. If I write this code myself, there is no error, but if the code is copy and pasted from a document which had an error, then these errors ensue.
The solution is to re-type the code and save the file.