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

  • Home
  • SEARCH
  • 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 7872941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:22:00+00:00 2026-06-03T02:22:00+00:00

<?php $search_input = $_POST[search_input]; include_once(connection_to_db.php); if(!isset($search_input)) { print(Nothing to search !); return; } //Queries

  • 0
<?php
$search_input = $_POST["search_input"];

include_once("connection_to_db.php");

if(!isset($search_input))
{
    print("Nothing to search !");
    return;
}

//Queries products where the search input is similiar to the title, artist or format of a product
$query_search = "SELECT * FROM waxItem WHERE title OR artist LIKE  '%".$search_input."%'";

$query_search_result = mysql_query($query_search)
 or die(mysql_error());

$num_rows_search = mysql_num_rows($query_search_result);

?>        

The code above does not work when i add “OR artist”.

The code does work and search results are displayed when only one field is compared to the database records.

What am i doing wrong?

  • 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-03T02:22:02+00:00Added an answer on June 3, 2026 at 2:22 am

    You cannot state the same LIKE criteria for multiple fields. You have to specify it per field. Even though you can do this but this is definitely not a recommended approach due to SQL Injection Attacks. Please read this SQL Injection

    You have to change

        $query_search = "SELECT * FROM waxItem WHERE title OR artist 
    LIKE  '%".$search_input."%'";
    

    to

            $query_search = "SELECT * FROM waxItem WHERE title 
    LIKE '%".$search_input."%' OR artist LIKE  '%".$search_input."%'";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a search input which sends data from an input to a php
search.php $text = $mysqli->$_POST['term']; $query = SELECT name FROM males WHERE name LIKE '%
I want to print the input value in flex to PHP. My Flex Code...
I do have a search form. <form method=get id=searchform action=<?php bloginfo('siteurl');?>> <div class=search_bx1><input type=text
How to test my php search engine project ? Client side Minimum browser requirement
I have a PHP search script which I've altered slightly and works well for
I need to create a php search function for names and need to change
I need to modify a php search script so that it can handle multiple
Given: Url - http://www.contoso.com/search.php?q= {param} returns: -html- --body- {...} ---div id='foo'- ----div id='page1'/- ----div
Is it possible to use php to search a string for a file path

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.