S
S
s_katala2017-10-20 01:47:24
css
s_katala, 2017-10-20 01:47:24

How to fix Notice: Undefined variable?

What's wrong?
php 7.1

if(stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0')) $xBrowser = 'ie6';
elseif(stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0')) $xBrowser = 'ie7';
elseif(stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.0')) $xBrowser = 'ie8';
if($xBrowser == 'ie6' OR $xBrowser == 'ie7' OR $xBrowser == 'ie8')
  header("Location: /browser.php");

error
Notice: Undefined variable: xBrowser

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Solntsev, 2019-07-20
@LehaRybkoha

Do you need to do the search logic or display ready-made results that you get from the api?
If the second and api are on the same domain, adjax will do. Offhand, without really delving into it, I would do something like this.
On the form, a change handler that sends user input to the search function via ajax.
We get a jason file with the results, put the headings in the tips immediately, and the results are entered and clicked on the search button.
To make direct hints, and not to load the titles of the found articles, you need to implement some kind of storage of search queries on the backend, otherwise where can you get these hints from.

S
Stalker_RED, 2017-10-20
@Stalker_RED

if(stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0')) $xBrowser = 'ie6';
elseif(stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0')) $xBrowser = 'ie7';
elseif(stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.0')) $xBrowser = 'ie8';
else $xBrowser = 'kawabanga!'; // < ----
if($xBrowser == 'ie6' OR $xBrowser == 'ie7' OR $xBrowser == 'ie8')
  header("Location: /browser.php");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question