Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:55:13+00:00 2026-06-01T12:55:13+00:00

I have a problem with my search on my site I don’t understand why

  • 0

I have a problem with my search on my site I don’t understand why it give me this error

this is my form code

<form action="index.php?cat=search_results&learn_id=1" method="post">
      <div id="topSearchBodyStyle">
        <input type="text" name="search" class="topSearchTextBackground" />
      </div>
      <div id="topSearchButtonStyle">
        <input type="submit" name="submit" class="topSearchButtonBackground" value="" />
      </div>
    </form>

and this is the page which have the php code

<?php 

    $getSearch = $_POST['search'];
    trim($getSearch);

    if(!get_magic_quotes_gpc()) {
        $getSearch = addslashes($getSearch);
        }

    $connectToDb = "select * from tutorials where tutorial_title like '%.$getSearch.%'"; 
    $searchResults = $db->query($connectToDb) or die($db->error);
    if ($searchResults){
        $numResultas = $searchResults ->num_rows;
        echo "<p>Found : " . $numResultas . "</p>";
        while($row = mysqli_fetch_array($searchResults)) {

            echo $row['tutorial_title'];    
        }
    }else{
        echo "cant connect";
        }
?>

any idea why it give me this note about “Undefined index: search”
and why the results come “0”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:55:14+00:00Added an answer on June 1, 2026 at 12:55 pm

    From the code example you’ve given, I don’t see a reason you are getting Undefined index: search, however, are you sure that $_POST['search'] is actually set? If this is part of some framework or other project, I have seen some that unset $_POST and $_GET and you have to access them another way.

    Is it possible that undefined index error is coming from a different line in your code?

    If you are getting a value through $_POST['search'], the reason you are getting 0 results is because you have an error in your SQL statement.

    Should be: "select * from tutorials where tutorial_title like '%".$getSearch."%'"

    Finally, you should be using mysql_real_escape_string instead of addslashes, or better yet prepared statements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TYPO3 site with Indexed Search Engine extension... The problem is that
so here's the problem I have one form, it outputs search results after submit,
In short, the problem is this: we have a news site that has a
URL: www.Wyler.com Problem: If you go to this site look at the inventory search
I have a problem and search for a solution on Google but can't find
I have a problem with a search query I am using my data contains
I have a problem with my search query, $s_query. The user can search a
I have a problem with my self-made search page. There is 2 tables: **name
I am trying to implement an efficient algorithm for nearest-neighbour search problem. I have
The problem I have is to pass the chained search of two models to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.