Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL query works in phpmyadmin but not through php

Tags:

People also ask

How do I run a PHP query?

If I run my query in my database it returns the value Im looking for. $result is an object representing the result of the query. You'll need to fetch the rows from the $result using one of the command like mysqli_fetch_array. See php.net/manual/en/mysqli-result.fetch-array.php for examples.

How does MySQL work with PHP?

The PHP language provides functions that make communicating with MySQL extremely simple. You use PHP functions to send SQL queries to the database. You don't need to know the details of communicating with MySQL; PHP handles the details. You only need to know the SQL queries and how to use the PHP functions.

Does phpMyAdmin use MySQL?

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB.

How do I run PHP in phpMyAdmin?

Unzip the zip file to store all files into htdocs directory of your Apache server. Open your favorite browser and in the address bar type "http://localhost/phpmyadmin/index.php". If PHP is installed correctly, you should see the phpMyAdmin login page with an error. Open config.


Any ideas would help, I have been on this for a while now and just can't figure out what is wrong.

Problem: query works fine until I added in the multiple word search which you can see bolded below. However, I echoed the sql query and then pasted in phpmyadmin and it worked perfectly but through the php it results with 0 records. It doesn't make any sense and I can't figure out what could be causing a result of 0.

SELECT 
        DISTINCT c.id 
    FROM 
        carpets AS c 
        INNER JOIN carpet_relations AS r1 ON c.id = r1.carpet_id 
        INNER JOIN carpet_relations AS r2 ON c.id = r2.carpet_id
        INNER JOIN carpet_relations AS r3 ON c.id = r3.carpet_id
    WHERE 
        c.active = '1' 



        AND ((c.title LIKE '%north tabriz%') OR **(c.title LIKE '%north%') OR (c.title LIKE '%tabriz%')** OR (c.item_no LIKE '%north tabriz%') OR **(c.item_no LIKE '%north%') OR (c.item_no LIKE '%tabriz%')** OR (c.pattern LIKE '%north tabriz%') OR **(c.pattern LIKE '%north%') OR (c.pattern LIKE '%tabriz%')** OR (c.period LIKE '%north tabriz%') OR **(c.period LIKE '%north%') OR (c.period LIKE '%tabriz%')** OR (c.country LIKE '%north tabriz%') **OR (c.country LIKE '%north%') OR (c.country LIKE '%tabriz%')**)

        AND (c.width_feet BETWEEN '0' AND '22') 
        AND (c.width_inches BETWEEN '0' AND '11') 
        AND (c.height_feet BETWEEN '0' AND '49') 
        AND (c.height_inches BETWEEN '0' AND '11') 
    ORDER BY 
        c.item_no


id  int(11) NO  PRI     NULL    auto_increment
active  int(11) NO      NULL    
title   varchar(250)    NO      NULL    
item_no     varchar(250)    NO      NULL    
country     varchar(250)    NO      NULL    
period  varchar(250)    NO      NULL    
pattern     varchar(250)    NO      NULL    
price   float   NO      NULL    
web_special     float   NO      NULL    
notes   text    NO      NULL    
width_feet  int(11) NO      NULL    
width_inches    int(11) NO      NULL    
height_feet     int(11) NO      NULL    
height_inches   int(11) NO      NULL    
restrict    int(11) NO      NULL    
views_amount    int(11) NO      NULL    
last_modified   datetime    NO      NULL    
modified_by     int(11) NO      NULL