php - MySQL REPLACE is not working if we store query into a variable -
this question has answer here:
my query this:
<?php $sql = "update macs_temp set home_page_heading='$home_page_heading', home_page_sub_heading='$home_page_sub_heading', home_page_description='$home_page_description', about_us_heading='$about_us_heading', about_us_description='$about_us_description', business_description='$business_description', we_do_description='$we_do_description', video_description='$video_description', photography_description='$photography_description', music_description='$music_description', web_and_app_description=replace($web_and_app_description, '\'', '') id=1"; if ($conn->query($sql) === true) { // echo "record updated successfully"; header("location: index.php"); exit; } else { echo "error updating record(contact system admin): " . $conn->error; echo "inside else error..!"; } ?>
gives error as: error updating record(contact system admin): have error in sql syntax; check manual corresponds mysql server version right syntax use near ''j, '\'', '') id=1' @ line 1inside else error..!
note: form contains 11 field any/more of field may contains apostrophe, apostrophes want update data in mysql database.
try need enclose $web_and_app_description
in ''
can consider string
$sql = "update macs_temp set home_page_heading='$home_page_heading', home_page_sub_heading='$home_page_sub_heading', home_page_description='$home_page_description', about_us_heading='$about_us_heading', about_us_description='$about_us_description', business_description='$business_description', we_do_description='$we_do_description', video_description='$video_description', photography_description='$photography_description', music_description='$music_description', web_and_app_description=replace('$web_and_app_description', '\'', '') id=1";
Comments
Post a Comment