Questions tagged [undefined-variable]
66 questions
4
votes
1 answer
Visual Studio Code is not showing an error for undefined variables PHP
I noticed that Visual Studio Code is not showing an error about undefined variables.
For example:
2) {
echo 'hi';
}
?>
If I run the code above, I would expect an error for undefined variable $test, but it’s not…

celalk38
- 81
- 8
4
votes
2 answers
How to differentiate between false and defined values in Template Toolkit for perl
This is a question about Template Toolkit for perl.
I render my templates with a little command-line utility that has the following option enabled
DEBUG => Template::Constants::DEBUG_UNDEF,
The syntax is render var1 val1 var2 val2…

az5112
- 590
- 2
- 11
3
votes
1 answer
pylint and "referenced before assignment"
For the following code
"""Test pylint on undefined variable"""
import random
def main():
"""Use undefined variable"""
if random.randint(0, 10) == 6:
thing = "hi"
print(thing)
if __name__ == '__main__':
main()
PyCharm…

Tobias Hermann
- 9,936
- 6
- 61
- 134
3
votes
2 answers
Julia UndefVarError
for i in 1:2
if i == 2
print(x)
end
if i == 1
x = 0
end
end
UndefVarError : x not defined
Why does the code gives that error instead of printing 0 in julia?
While in python the following code print 0?
for i in…

Erik Garcia
- 88
- 1
- 6
3
votes
2 answers
Python - Writing to CSV files and for loops
EDIT The approved answer is correct and all of my data appears in the file, however since it is looping through and writing each piece of information to a new row, the data is unorganized and appears in a cascading pattern. At this point it is just…

nikki_c
- 117
- 1
- 3
- 7
2
votes
4 answers
Undefined variable in laravel blade file
I am new to laravel kindly help me out to solve this error.
This is my controller function "edit"
public function edit($id)
{
$user = User::find($id);
return view('users.edit-profile',['user'=>$user]);
}
This is my view…

Timothy
- 69
- 7
2
votes
1 answer
Check if arguments passed into a function are defined or not in r?
I want to know how the existence of a variable passed into a function can be checked before applying more operations on them inside the function. So that if a variable is not found, it could be ignored using an if-else statement. Here is a sample…

Mahrokh
- 93
- 1
- 5
2
votes
1 answer
Laravel 7: Undefined variable in foreach loop
I want to display to select the campus from the campuses table in my budget allocation create.blade.php template but it displays an error.
create.blade.php
2
votes
1 answer
ReferenceError: hash is not defined in node.js
i am making a login system and using bcrypt to hash passwords. But now when i try to login i got this error that says that ReferenceError: hash is not defined.I will be thankful if anyone can help me and tell me where and how to declare hash.
This…

palo
- 159
- 2
- 12
2
votes
1 answer
Laravel - Undefined variable: request
My http://localhost:8888/VGL/public/category/18?sty=3
When dd($request->sty); equal 3
however I put $request->sty in the whereHas is
Undefined variable: request
public function show(Request $request, $id)
{
$products =…

Hao Phung
- 99
- 1
- 3
- 11
1
vote
1 answer
How to fix error "undefined variable:sin" in plotting in gnuplot?
I am plotting in 2D on gnuplot through Ubuntu. When defining my equation for 'radius of curvature' a function of theta=x of variables sin and cos functions, respectively, I get an error message saying 'undefined variable: sin' or cos. I am simply…

ldcapes
- 13
- 2
1
vote
0 answers
How can I solve the variable is not defined error in jupyter notebook
Error in this statement that auth is not defined after i already defined it.
You can check the code.
import tweepy
consumer_key = 'xxx'
consumer_secret = 'xxx'
callback_url = 'ooo'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret,…

Juice
- 11
- 2
1
vote
2 answers
Why is my code showing this error: Undefined Variable
I am trying to migrate my foreign key and display the list of employees in company form. for that:
1.My CompaniesController
public function index(){
$cat = Company::all();
return view(view:'company/index')->with ('cat', $cat);
}
This…

Barshu Mhzn
- 11
- 1
1
vote
1 answer
How can I resolve Undefined name 'currency' in Flutter for-in loop?
Background
While following London App Brewery's Bitcoin Ticker project, and I got stuck trying to create DropdownMenuItems via a for-in loop. The warning that the Dart Analysis gave me was Undefined name 'currency'. Here's the code that produced the…

chemturion
- 283
- 2
- 16
1
vote
4 answers
Trying to use the return value from one function in another but getting undefined variable instead
I have this code:
class Pet(object):
def __init__(self,name=""):
self.name = name
self.kind = "Unknown"
self.toys = []
def add_toys(self,toys):
new_list = []
for toy in self.toys:
if…

Håkan Mjölk
- 73
- 4