Mysql php result returns incorrectly every time from php but works fine in sql pro and phpmyadmin

The following statement returns 1 in php. I serialize and issue the result and all other credentials, and it does this on three separate requests. When I run the query in sqlpro or phpmyadmin, I get the result as 8. Please tell someone has a bright idea.

$numRFPsSwitch = 0;
$bquery = " SELECT COUNT(rp.id) AS 'NumRFPs'

   FROM  rfp_proposal rp

   WHERE rp.vendor_id = 1 AND rp.id IN(13,15,16,23,24,26,4,9) ";

$bresult = mysql_query($bquery, $connection); 
$XMLFormatedString .= 'NumRFPs="'; 
while ($brow = mysql_fetch_object($bresult)){ 

$XMLFormatedString .= $brow->NumRFPs; 
$numRFPsSwitch = 1; 
} 
+3
source share
4 answers

Perhaps you could do SELECT *(to return all the rows involved) and then do mysql_num_rows(...)as a result to find out the number of rows. If this returns the same result, then at least you can be sure that it is not the query or concatenation that is to blame.

$query = "SELECT ...";
echo mysql_num_rows(mysql_query($query, $connection));
0

1? $numRFPsSwitch, 1?:) $XMLFormatedString , .

+1

The result will always be one line. Thus, the loop should be replaced with if. About the problem: did you check yours $connection?

+1
source

Are you sure you are using the correct credentials to log into mysql_connect () and mysql_selectdb ()?

Also: if you use the correct credentials, are you sure that you have the rights to select / update / delete, etc.

0
source

Source: https://habr.com/ru/post/1774172/


All Articles