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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:36:56+00:00 2026-06-14T04:36:56+00:00

Getting this error mysql_fetch_assoc() expects parameter 1 to be resource, boolean given when I

  • 0

Getting this error mysql_fetch_assoc() expects parameter 1 to be resource, boolean given when I return my query

$query = mysql_query("SELECT * FROM tempusers
    WHERE 'firstname' LIKE '%$data%' 
    OR 'lastname' LIKE '%$data%'
    OR 'description' LIKE '%$data%'
    OR 'title' LIKE '%$data%'");

if (! $query){
    echo'Database error: ' . mysql_error();
}
while($row=mysql_fetch_assoc($query)){
    $description = $row['description'];
    echo $description;
}

Specifically, the while loop. Not understanding why I’m getting. I’m thinking it’s because of my use of LIKE, I am unsure if I am using the wildcard's %% correctly with my query. I would appreciate knowing how to rid of this error and why it happened

  • 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-14T04:36:58+00:00Added an answer on June 14, 2026 at 4:36 am
    • use CONCAT() function
    • use backtick instead of single quote on column names (but in this case it is not required since your column name is not a reserved keyword or it does not contain invalid characters on it)

    query,

    SELECT * FROM tempusers
    WHERE  `firstname` LIKE CONCAT('%', '$data', '%')
        OR `lastname` LIKE CONCAT('%', '$data', '%')
        OR `description` LIKE CONCAT('%', '$data', '%')
        OR `title` LIKE CONCAT('%', '$data', '%')
    

    one more thing, your query is vulnerable with SQL Injection, please take time to read the article below,

    • How can I prevent SQL injection in PHP?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: mysql_fetch_array() expects parameter 1 to be resource, boolean given in select When
Possible Duplicate: PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given I
Possible Duplicate: PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given I
here is my code for the query in php: $query3 = mysql_query(SELECT * FROM
to is not defined [Break on this error] setTimeout('updateChat(from, to)', 1); I'm getting this
I am getting this error when I execute my page: Warning: mysql_fetch_assoc() : supplied
The Error I keep getting is: stripslashes() expects parameter 1 to be string, array
I am getting this error here is my code if(isset($_POST['submit'])) { $projTit=mysql_escape_string($_POST['projecttitle']); $projCat=mysql_escape_string($_POST['projectcategory']); $budget=intval(mysql_escape_string($_POST['budget']));
I am getting this error when I run db:migrate Mysql2::Error: Table 'sample_app_development.microposts' doesn't exist:
I'm using prepared statements and MySQLi, and am currently getting this error. PHP Catchable

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.