Php mysqli gives no results

lost in binary

Basically my problem is that mysql in php in some cases returns an empty array with no error.

I am getting all products from table 'newproducts' where the name is the same as it was in the url that was called.

So when I call: http://domain.com:9090/db/product/3-Acetyl-5-bromopyridine

the query that is being called is (after url_decode):

SELECT * FROM `newproducts` WHERE `name` = '3-Acetyl-5-bromopyridine' LIMIT 1

which returns all products correctly.

But if I call: http://domain.com:9090/db/product/%5B3aa,4a%28E%29,5b,6aa%5D-4-%5B4-%283-Chlorophenoxy%29-3-oxo-1-butenyl%5Dhexahydro-5-hydroxy-2H-cyclopenta%5Bb%5Dfuran-2-one after I do urldecode the query is this (using var_dump in browser):

SELECT * FROM `newproducts` WHERE `name` = '[3aa,4a(E),5b,6aa]-4-[4-(3-Chlorophenoxy)-3-oxo-1-butenyl]hexahydro-5-hydroxy-2H-cyclopenta[b]furan-2-one' LIMIT 1

which returns NO results (empty array) with no error.

Also the above exact query in phpmyadmin correctly gives back the result.

Lastly, I have tried using the below lines before I run the query with no luck:

mysqli_set_charset($con, "utf8");
mysqli_real_escape_string($con, $name);

Thanks in advance!

the code of the query:

function getOneResFromDB($con, $text) {
    mysqli_set_charset($con, "utf8");
    mysqli_real_escape_string($con, $text);

    $query = "SELECT * FROM `newproducts` WHERE `name` = '" . $text . "' LIMIT 1";

    $result = mysqli_query($con, $query) or die(mysqli_error($con));

    $array = array();
    while ($row = mysqli_fetch_assoc($result)) {
        $array[] = $row;
    }

    return $array;
}
lost in binary

I had to use html_entity_decode as well. The result seemed the same but it wasnt even with var_dump as some characters were automatically converted by the web browser. html_entity_decode solved it.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

PHP Getting Random Gives Blank Results

분류에서Dev

PHP mySqli not updating table

분류에서Dev

PHP mysqli empty array

분류에서Dev

PHP Error with mySQLi

분류에서Dev

MySQLi, SELECT FROM, PHP

분류에서Dev

mysqli_fetch_array not showing results correct

분류에서Dev

mysqli queries not returning results inside function

분류에서Dev

Kubectl config view gives empty results

분류에서Dev

Healpy: Rotator function gives different results

분류에서Dev

Code Coverage Results periodically gives: Empty results generated

분류에서Dev

PHP MySQLi 준비 문

분류에서Dev

mysqli 및 PHP 오류

분류에서Dev

PHP mysqli 문 오류

분류에서Dev

PHP-Mysqli 오류

분류에서Dev

PHP mysqli_query() expects parameter 1 to be mysqli, null given in

분류에서Dev

mysqli 동적 쿼리 bind_results

분류에서Dev

PHP Sorting of Database Results

분류에서Dev

Tensorflow 2.0 `tf.multiply` method gives unexpected results

분류에서Dev

SimpleDateFormat parse and format on same date string gives different results

분류에서Dev

Bitwise shift and byte cast gives different results in Java and C#

분류에서Dev

PHP MySQLi 이메일 양식

분류에서Dev

OOP PHP 통합 mysqli_query

분류에서Dev

PHP-MySQLi 준비 문

분류에서Dev

PHP는 MySqli 쿼리 실행

분류에서Dev

PHP MySQLi 준비된 문-SELECT

분류에서Dev

PHP mysqli_insert_id () 오류

분류에서Dev

php - MySQli row count always returning 0?

분류에서Dev

PHP 검색 기능 [MySqli]

분류에서Dev

함수 PHP의 mysqli 연결