Jump to content

Stupid Search Problem easy fix.


Gayner

Recommended Posts

if (isset($_POST['search']) AND $_POST['search'])
$search_string = strtolower( str_replace( "*" , "%", $_POST['search'] ) );
$search_string = preg_replace( "/[<>\!\@£\$\^&\+\=\=\[\]\{\}\(\)\"';\.,\/]/", "", $search_string );
echo $search_string;

 

But whenever I DONT USE MY SEARCH BUTTON I GET UNIDENTIFIED ERROR cause it's underneath a IF function..

 

How do i stop the error if no1 is pressing my search button :) from $_POST['search'] on my form

Link to comment
https://forums.phpfreaks.com/topic/183360-stupid-search-problem-easy-fix/
Share on other sites

if (isset($_POST['search']) AND $_POST['search'])
$search_string = strtolower( str_replace( "*" , "%", $_POST['search'] ) );
$search_string = preg_replace( "/[<>\!\@£\$\^&\+\=\=\[\]\{\}\(\)\"';\.,\/]/", "", $search_string );
echo $search_string;

 

But whenever I DONT USE MY SEARCH BUTTON I GET UNIDENTIFIED ERROR cause it's underneath a IF function..

 

How do i stop the error if no1 is pressing my search button :) from $_POST['search'] on my form

 

lol i will just use this unless easier way?

 

error_reporting(E_ERROR | E_WARNING | E_PARSE);

your code should be

 

if (isset($_POST['search'])) {
    $search_string = strtolower( str_replace( "*" , "%", $_POST['search'] ) );
   $search_string = preg_replace( "/[<>\!\@£\$\^&\+\=\=\[\]\{\}\(\)\"';\.,\/]/", "", $search_string );
   echo $search_string;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.