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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:58:46+00:00 2026-06-04T06:58:46+00:00

Records which contain an ampersand ( & ) are not returned by MySQL (connected

  • 0

Records which contain an ampersand (&) are not returned by MySQL (connected to via PHP), but the same query works fine in phpMyAdmin. I am not sure if it is a collate/charset problem. Here is the sample query:

SELECT distinct(pcs.shop_name) AS shopName 
FROM shops AS ps 
LEFT JOIN category_shop AS cs 
   ON ps.shop_id = cs.shop_id 
WHERE 1=1 
   AND (ps.shop_name LIKE '%P&G%') 
   AND ps.is_active!=2 
ORDER BY ps.shop_display_name ASC

The shop_name I am trying to search for is P&G.

  • 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-04T06:58:47+00:00Added an answer on June 4, 2026 at 6:58 am

    Try this (i guess You are using GET to submit a form if You have problem with ampersand):

    $shop_name = urlencode('P&G');
    

    on Your page for that field values (this means You call urlencode for every field value when generating form). Then after a GET is done, simply do:

    $shop_name = mysql_real_escape_string($_GET['shop_name']);
    $query = "SELECT distinct(pcs.shop_name) as shopName 
        FROM shops AS ps 
        LEFT JOIN category_shop AS cs ON ps.shop_id = cs.shop_id 
        WHERE 1=1 
            AND (ps.shop_name LIKE '%{$shop_name}%') 
            AND ps.is_active!=2 
        ORDER BY ps.shop_display_name ASC";
    

    Does this work for You?

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

Sidebar

Related Questions

I would like to create a query where I select all records which contain
How to select only years from mysql database (but only those years which contain
I want to get all the records from the one table which contain at
I'm creating a cache which is going to contain records in Delphi 2007. Each
Excuse my lack of knowledge. Im creating a a php/mysql website which will store
i have XML files which contain records with the following structure: <xml> <payment contractType=1>
given @comments which can contain 1 or more records. How do I obtain the
I have a database table which could contain many records and I'd like to
I have a need to select a set of records which contain an IsLocked
I have to import a large set of records which can contain duplicates. The

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.