I'm trying to debug a table update and struggling for the next idea. I extract values from an XML and attempt to update columns with them (row matched on an id).
if ($r2 != false)
Is reached suggesting it doesn't fail but no data is updated. If I run the same query in phpmyadmin it will update no problem. Before each update (because of this issue) I query the db & find the row successfully. I also tried explicitly casting the XML results to (float) as the columns are decimal but no luck :( Larger code example below:
$home_lay = 99.99;
$draw_lay = 99.99;
$away_lay = 99.99;
if(count($home) > 0) {
$home_lay = $home[0]["decimal"];
}
if(count($draw) > 0) {
$draw_lay = $draw[0]["decimal"];
}
if(count($away) > 0) {
$away_lay = $away[0]["decimal"];
}
$q3 = "SELECT * FROM tab4 where match_id = " . $matchid;
$r3 = mysqli_query($dbc, $q);
if (mysqli_num_rows($r3) > 0) {
echo 'THIS ROW EXISTS <br />';
} else {
echo 'NO ROW!!!! <br />';
}
$q2 = 'update tab4 set smark_home = '.$home_lay. ' , smark_draw ='. $draw_lay .' , smark_away ='. $away_lay .'
where match_id='. $matchid;
$r2 = mysqli_query($dbc, $q);
if ($r2 != false) {
echo "Odds updated <br />";
I've been echoing at it goes (cut from code) with output like the following:
match id: 755094
home: 3.90
draw: 3.50
away: 2.38
THIS ROW EXISTS
update tab4 set smark_home = 3.90 , smark_draw =3.50 , smark_away =2.38 where match_id=755094
Edit: Following a now deleted comment I just tried doing a prepared statement with this correct answer example: PHP UPDATE prepared statement with 'dddi' but still no error or update