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 8249237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:28:04+00:00 2026-06-07T23:28:04+00:00

I need to implement a search in mysql table for a certain word to

  • 0

I need to implement a search in mysql table for a certain word to find in a specific column (type: text).

I thought that the easiest way is to do:

$str = "something"; # let's say passed by POST or GET from a form
$sql = "select lala, textThing from table_name where dudu=1 and textThing LIKE %'$str'%";

This seems to work just fine if doing query manually in mysql, but not on php through web.
It throws

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘%searchedString%’ at line 1

where searchedString is, well, you know, the string I searched for 🙂

First PHP looks like this:

$str = NULL;


echo "<p>Search for a string</p>";
echo "<form name='formSearch' action='result.php' method='post'>";
echo "<input type='text' name='text' size='30'/>";
echo "<input type='submit' name='search' value='Search'/>";
echo "</form>";

The second one is just getting the “text” and doing mysql and supposed to show the data

  • 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-07T23:28:06+00:00Added an answer on June 7, 2026 at 11:28 pm

    You have to put your LIKE clause between quotes. Escape them in your php code like this :

    $sql = "select lala, textThing from table_name where dudu=1 and textThing LIKE \"%".$str."%\""
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What options exist for creating a scalable, full text search with results that need
I have below combo box in mvvm-wpf application. I need to implement Text search
I can search multiple value with mysql. I need to implement SORT BY on
I need implement simple search in small content table: id, name, description, content. Results
I need to implement a Search box on a C# MVC application that I'm
For a real estate website I need to implement a search mechanism that allows
I need to implement a Query Object Pattern in Java for my customizable search
I need to implement the following: There is a table A which is supposed
I am working on a Django project, where I need to implement full text
I need to implement textbox with inplace button (for search or filter purposes). So,

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.