This question is a bit basic and have been covered many times but I'm not sure why my code doesn't do anything. it doesn't update string at all.
this is my code:
$fineImage = "users_fav/".$_GET['id']."/$newname";
$icon = "<img src='images/icon.png' height='70' width='70' />";
$sql = "UPDATE $lchat SET user_message = replace(user_message, '$icon', '$fineImage')";
$query = mysqli_query($db_conx, $sql);
the problem is that if I change the '$icon', '$fineImage' to something like 'david', 'mark'. it works fine and it will replace the david with mark...!
so why doesn't it work the way i do it?
mysqliyou should be using parameterized queries andbind_paramto add user data to your query. DO NOT use string interpolation to accomplish this because you will create severe SQL injection bugs. You're probably having some kind of quoting issue here due to your use of string concatenation.$lchatin your queries. Does this table name change? If not, put it in directly. Every variable you have in your query creates an opportunity for problems you do not want to have.