• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

Here it is in a nutshell:


var searchString = 'value';  $.ajax({      type:'POST',      url:'myUrl.php',      data:{          'searchString': searchString      },      async:false,      dataType:'json',      success: function(data){          // do stuff      },      error: function(data){          console.log(data);      }  }); 


$searchString = $_POST['searchString']; 

mysql query:

$q = "SELECT * FROM myTable WHERE searchField LIKE '%" . $searchString . "%'"; 

All of the above works perfectly with one exception: if the searchString variable value is 'grb' it does not produce an error, but also produces no results (and there are 60+ "matching records" that should be found on a 'grb' search).

I can do the exact same query (as shown in $q above) successfully with 'grb' from within phpMyAdmin using the 'Search' option on the 'searchField' selecting the 'LIKE %...%' operator OR clicking on 'SQL' and using:

SELECT * FROM `myTable` WHERE `searchField` LIKE '%grb%' 

The problem seems to only exist when 'grb' is sent via the ajax call. Same ajax call with anything other than 'grb' WORKS properly.

NOTE: THE searchString variable is actually set from a "input" text on a form that is set so that only lower case letters and numbers can be entered.

Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]