简体   繁体   中英

query works on firefox but not on ie and chrome

I have this query right here:

$query_1 = "select * from test.users where app_id='$app_id' and user_id='".$user_id."'";
    $resource_1 = mysql_query($query_1);
    $result_1 = mysql_fetch_object($resource_1);

    var_dump($result_1);

For some weird, strange reason, the query above output the correct result in Firefox, but on IE and chrome it outputs false like the following:

<pre class='xdebug-var-dump' dir='ltr'><small>boolean</small> <font color='#75507b'>false</font>

Any idea what is causing this to happen? It doesn't make any sense to me at all.

Thanks for any help

Your code has way to many flaws to be able to properly debug.
It probably works on Firefox because the page is cached, but it should not work in either browser.
Try the following:

<?php
$sql = "select * from test.users where app_id=:app_id and user_id=:user_id;";

$dbh = new PDO('mysql:dbname=yourDBname');

$sth = $dbh->prepare($sql);
$sth->bindValue(':app_id', $appId, PDO::PARAM_INT);
$sth->bindValue(':user_id', $userId, PDO::PARAM_INT);
$sth->execute();

Also, try looking into PHP PDO because it will help you avoid quite a few problems.

http://www.php.net/manual/en/book.pdo.php

Hope it helps, Denis

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM