Undefined Variable title in Laravel [duplicate] - php

This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 4 years ago.
This error I am getting in Laravel. Can I know what exactly can be the issue. I have spent my full day into this.

you should pass all your variables you use in view, if you use $title as a title for each page in your website you should pass it from your controller function to the view like this:
return View::make('home.index')->with('title', 'your title here');
and in your view you can make a condition to display public title to all pages don't have a title like this:
#if(isset($title)){{$title}} #else {{'Default title here'}} #endif

Check your Controller. If in controller variable $title is empty and you manipulate with it then you will get similar error.

your $title variable is null .
Make sure that $title is not null
try this in your blade
#if(isset($title)){{$title}}#endif

Related

"Undefined variable" error in PHP Simple HTML DOM [duplicate]

This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed last year.
I want to extract the information on this page using a script PHP Simple HTML DOM,
Here is part of the code I wrote:
$html = file_get_html('https://www.digikala.com/product/dkp-7475119/');
foreach ($html->find('p.color-900') as $e) {
$color = $e->outertext;
echo $color ;
break;
}
But unfortunately the output I receive is Undefined variable
As #Kevin Y said in his comment, you are searching for something that isn't there... yet.
Visit view-source:https://www.digikala.com/product/dkp-7475119/ and search for <p>
The page hasn't loaded the extra elements onto it yet like the <p> tag you are looking for. This is likely because the page is loading them in after-the-fact using JavaScript so you will need to find a way to get the html after the page has loaded its contents that are added in later.

Undefined Variable in Laravel PHP [duplicate]

This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 4 years ago.
I'm new to Laravel and I'm very struggling with it. Please help me. I want to retrieve data from database to display on web page. But It alert message:
ErrorException (E_ERROR)
Undefined variable
display.blade.php
#foreach ($displays as $display)
{{ $display->first_name }}
{{ $display->last_name }}
#endforeach
DisplayController.php
public function index(){
$displays = Info::where('id', 1)->get();
return view('display', compact("display"));
}
you have a typo in your displaycontroller.php
return view('display', compact("display"));
should be
return view('display', compact("displays"));
you are missing the s behind display

I'm getting syntax error when trying to send password in form [duplicate]

This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 4 years ago.
I'm very new at php. I get these errors when I write these codes.
check to see if islem was passed in before trying to access it
if (isset($_POST['islem']) {
// your code here
}
Otherwise you won't be able to load the page up initially in order to submit the form. Also notice that I used _POST here, this is because you used the POST method in your form.
You are using the method POST in the form and getting the variables with GET
Either Try method : GET or try $_POST["islem"];

PHP Problems related to Undefined index error [duplicate]

This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 6 years ago.
Can you help me with this errors. I am actually trying to generate an invoice. However, my generated invoice having some problems as you can see as the image below.
Here is the image of my coding.
$oid = ( isset($_GET['oid']) ) ? $_GET['oid'] : null;
Also I believe line 38 should come before line 37. bindParam calls a variable defined after it.
You use variable $oid which it's data is $_GET['oid'], in your query before you actually declare/store data to it.
Move line 38 -> $oid = $_GET['oid']; after opening try/catch, that means to line 29, before stating the query. You should implement #fie answer too, to be sure that $oid is not null and that data actually exists.
Also something is wrong with line 73 but we can't see it.

PHP cookies to pass variables between two pages [duplicate]

This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 6 years ago.
I am aware that I can use sessions and GET/ POST method but I would like to achieve this using cookies. My code on page1.php is :
$_COOKIE['varname'] = $id;
and on page2.php is:
$id = $_COOKIE['varname'];
I get the following notice on my browser: Undefined index $id
What is the problem with my code?
Try using setcookie('varname', $id) then
if (isset($_COOKIE['varname']){ echo $_COOKIE['varname']; }
To set a cookie you need to use setcookie(). And it has to be done prior to any output.
setcookie("mycookie", "myvalue" , $validtime); // validtime is a integer.

Categories