I am retrieving data from the joomla Database.
I am searching for the tag <img alt=''">
in the content and I want the alt tag value as the articles title.
But when I Update the content in database I get the following error.
"Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's, each catering to different testing needs of an organization. It has f' at line 1"
Please Check the Code given below.
$link= "SELECT * FROM as23dc_content LIMIT 1";
$link_result = mysqli_query($conn, $link);
while($row_link= mysqli_fetch_assoc($link_result)) {
$content = $row_link["introtext"];
$add_alt_title = 'alt="'.$row_link["title"].'"';
$content1 = preg_replace('/(alt)=("[^"]*")/i', "$add_alt_title", $content);
//echo $content1;
$sql = "UPDATE as23dc_content SET introtext='".$content1."' WHERE id='".$row_link["id"]."'";
//print_r($sql);
if(mysqli_query($conn, $sql)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
}