非常に具体的な質問がありますが、問題が見つかりません。テキストを更新しようとすると、エラーが発生します。
SQL 構文にエラーがあります。使用する正しい構文については、MySQL サーバーのバージョンに対応するマニュアルを確認してください。1 行目の「= Corfu のイースターは、Gree で最も壮大なお祝いと見なされています」の近くで使用してください。
私のコード:
$arr = explode("|", $id, 2);
$id = $arr[0];
$part = $arr[1]; // in which part of a splited paragraph currently we are
$row = mysql_fetch_array(mysql_query("SELECT * FROM paragraph WHERE id=$id")) or die(mysql_error());
$search = 'insertphotos'; // the string to search for
$string = $row['text_content']; // the string to search
$repetition = substr_count($string, $search); // how many insertphotos exist in paragraph
if ($repetition > $part){
if ($part > 1)
$offset = $part - 1; // how many times to search for word insertphotos
else
$offset = $part;
$start = strposOffset($search, $string, $offset) + 13; // find position of '$offset' occurance of search string
$offset++;
$end = strposOffset($search, $string, $offset) - $start - 1;
$string = substr_replace($string, $value, $start, $end);
}else if ($repetition == $part){
$offset = $part; // how many times to search for word insertphotos
$start = strposOffset($search, $string, $offset) + 13; // find position of '$offset' occurance of search string
$string = substr_replace($string, $value, $start, strlen($string));
}else
$string = "<p>".$value."</p>";
//$value = "<p>".$value."</p>";
mysql_query("UPDATE paragraph SET text_content=".$string." WHERE id='$id'") or die(mysql_error());
//mysql_query("INSERT INTO paragraph (header, text_content, menu_id, sequence) VALUES('<h2>Bella Vista Hotel h2 - Please Change Me</h2>', $string, '15', '2')") or die(mysql_error());
mysql_close($link);
//echo "INSERT PHOTOS REPEATS " .$repetition ." ID =".$id ." PART = ".$part ." WE SEARCH, START AT " .$start ." FINISH AT " .$end ." SEARCH FOR OFFSET = " .$offset ." FINAL STRING " .$string;
echo $string;
すべての変数が機能します。エコーを試みましたが、問題はありません。テキストにinsertphotosが1つ(またはゼロ)しかない場合は機能します。複数あると、このエラーが発生します。理由がわかりません。