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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:43:23+00:00 2026-05-31T19:43:23+00:00

TABLE bcompany companyID | cName | … I have the input field, where user

  • 0

TABLE bcompany

companyID | cName | ...

I have the input field, where user searches for the records including the “input” characters:

<input type="text" class="bigblack" name="srch" />

PHP:

$req="%".mysql_real_escape_string($_POST['srch'])."%";

$query = mysql_query("SELECT companyID, cName FROM bcompany WHERE
companyID OR cName LIKE $req ORDER BY companyID LIMIT 10");

OR

$query = mysql_query("SELECT companyID, cName FROM bcompany WHERE
companyID,cName LIKE $req ORDER BY companyID LIMIT 10");

Both queries return an error:

mysql_fetch_array() expects parameter 1 to be resource….

There is probably something wrong with the MYSQL SELECT.

Can you please help me solve this out?

Thanks in advance 🙂

Rest of the code:

while($res = mysql_fetch_array($query)) {


    echo $res["companyID"];
    echo $res["cName"]."<br>";



}
  • 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-05-31T19:43:24+00:00Added an answer on May 31, 2026 at 7:43 pm

    You query should be:

    $query = mysql_query("SELECT companyID, cName FROM bcompany WHERE
    companyID LIKE '$req' OR cName LIKE '$req' ORDER BY companyID LIMIT 10");
    

    Here are the docs for MySQL LIKE:

    http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html

    Alternatively you could use the MySQL REGEXP in place of LIKE in your queries.

    It looks like mysql_fetch_array is griping when you call it because the query is incorrect and not producing a result which mysql_fetch_array can use.

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

Sidebar

Related Questions

I have the following mapped classes: <class name=Company table=Company> <id name=ID column=CompanyID> <generator class=native/>
I have a SQL table containing customer information (we'll call it CustomerDB ), including
table user: |id|name|employee_priority_id|user_priority_id| table priority: |id|name| As you can see, there are two foreign
Table A has a number of rows, only some of which have (multiple) children
Table is huge. For testing application I want to delete all, except 1000 records
Table: Relatives emp_id dep_id (composite primary key) We have to restrict one employee to
table: user id name ------------- 1 john 2 paul 3 mattew table: nickname id
Table - user_feed column name - date_n_time (type - datetime) How do I write
Table Category (c) has a 1:many relationship with Table Question: a Category can have
Table 1 person_id| location_id | field a | field b |friend_id Table 2 location_id

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.