Trying Update Record with PDO

前端 未结 2 1984
闹比i
闹比i 2021-01-24 04:33

I updated the question code I am still having issues no errors but does not update the record. also need to figure how to write in record # updated successfully. I am stuck on t

2条回答
  •  无人及你
    2021-01-24 04:45

    This code is a disaster:

    $affected_rows = $db->exec("UPDATE requests SET") . 
                                                   ^^---terminating your query here
                    "lanId =  '" . $lanId . "', ".
    

    So you run a malformed query (UPDATE requests SET), which will either throw an exception of return boolean FALSE. You then concatenate a whole bunch of text (which would've been part of your query) onto that FALSE.

    And even if this code was properly structured, you'd be WIDE OPEN to sql injection attacks.

提交回复
热议问题