mariadb - Why do i get more results from my mysql query in php then what i ask for? -
i getting return values not exist in current database. if change query return array stays same missing values. how can did wrong? mysql server version 10.0.22 , server gives me correct result. issue must in php.
my code:
$select_query = "select process_state.uid process_state process_state.updatetimestamp > \"[given time]\""; $result = mysql_query($select_query, $link_identifier); var_dump($result);
result:
array(1) { [1]=> array(9) { ["uid"]=> string(1) "1" ["creationtimestamp"]=> null ["updatetimestamp"]=> null ["processstate"]=> null } }
solution: have found code somewhere in program. program used same name ass mine. function turns mysql result array. happens between result view , script. done make result readable.
parent::processupdatedafter($date);
function:
public function processupdatedafter($date) { $result = parent::processupdatedafter($date); $array = array(); if($result != false) { while ($row = mysql_fetch_array($result, mysql_assoc)) { $array[$row["uid"]]["uid"] = $row["uid"]; $array[$row["uid"]]["creationtimestamp"] = $row["creationtimestamp"]; $array[$row["uid"]]["updatetimestamp"] = $row["updatetimestamp"]; $array[$row["uid"]]["processstate"] = $row["processstate"]; } return $array; } return false; }
i edited , script works fine help.
you var_dump
ing database resource handle , not data queried
you must use sort of fetch
ing process retrieve data generated query.
$ts = '2016-09-20 08:56:43'; $select_query = "select process_state.uid process_state process_state.updatetimestamp > '$ts'"; $result = mysql_query($select_query, $link_identifier); // did query work or there error in if ( !$result ) { // query failed, better @ error message echo mysql_error($link_identifier); exit; } // test have results echo 'query produced ' . mysql_num_rows($result) . '<br>'; // in while loop if more 1 row might returned while( $row = mysql_fetch_assoc($result) ) { echo $row['uid'] . '<br>'; }
however have mention every time use the
mysql_
database extension in new code a kitten strangled somewhere in world deprecated , has been years , gone ever in php7. if learning php, spend energies learningpdo
ormysqli
database extensions. start here
Comments
Post a Comment