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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:10:11+00:00 2026-05-11T20:10:11+00:00

Ive been programming a search form with three fields, and the one that is

  • 0

Ive been programming a search form with three fields, and the one that is giving me trouble is the one that use the “LIKE” clause in sql.

Here is the code:

            <form method="post" action="<?php $_SERVER['PHP_SELF']?>">
             <p>

             <label for="nome">Nome Empresa:</label>
             <input type="text" name="nome"  id="nome"/>

             <label for="concelho">Concelho:</label>
                <select name="concelho">
                        <option id="" selected="selected" value="">Seleccione o Concelho</option>
                          <option value="1" id="1">Um</option>
                          <option value="2" id="1">Dois</option> 
                 </select>

             <label for="actividade">Actividade:</label>
                <select name="actividade">
                        <option id="" selected="selected" value="">Seleccione a actividade</option>
                          <option value="1" id="1">Actividade Um</option>
                          <option value="2" id="1">Actividade Dois</option>    
                 </select>   
             </p>
             <p>
             <input type="submit" name="pesquisar" value="Pesquisar"/>
             </p>
            </form>

// the sql (not all)

                    $nome = mysql_real_escape_string($_POST['nome']);



                // Pesquisa a partir da form
                if (isset($_POST['pesquisar'])) {

                $queryStr = 'SELECT * FROM ';
                if(!empty($nome)){
                    $queryStr .= 'tbl_clientes  WHERE nome LIKE '%'$nome'%'';
                }

Why does it give me this error twice?

Warning: Division by zero in .. on line ..

Warning: Division by zero in .. on line ..

I’m not making a Division…am i?

Thanks in advance

  • 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-11T20:10:11+00:00Added an answer on May 11, 2026 at 8:10 pm

    Yes, you do. The % signs used by LIKE are outside the string, and hence interpreted as the modulo operator. Remove the additional ‘ signs.

    $queryStr .= "tbl_clientes WHERE nome LIKE '%$nome%'";
    

    (Here I used a mixture of single and double quotes to sove the problem. Eoin Campbell’s solution of escaping the inner single quotes is just as valid. You will often find that you will need to use (a combination of) these techniques when programming in PHP.)

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

Sidebar

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To capture actions performed on one Activity within another requires… May 12, 2026 at 12:30 am
  • Editorial Team
    Editorial Team added an answer Very odd...I have cscope 15.6 installed in /usr/bin on MacOS… May 12, 2026 at 12:30 am
  • Editorial Team
    Editorial Team added an answer You can use <link rel="stylesheet" type="text/css" href="style.css" /> in the… May 12, 2026 at 12:30 am

Related Questions

Folks, Please, what's a good way of writing really big XML documents (upto say
I've been using usenet searches since about 1995 to get programming information, mostly for
I'm totally new to both java and java Server worlds... But I've a good
I've been reading Bruce Eckel's Thinking In Java and in the chapter on generics,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.