-1

誰か助けてください、値としてデータベースに改行ありのHTMLテキストを挿入したいのですが、改行を追加するとクエリが失敗します。これはmysqlがhtml改行をサポートしていないためだと思います

改行でテキスト構造を維持し、クエリを機能させる方法を誰かに教えてもらえますか。

問題を引き起こしている値は「コンテンツ」です。

$query="INSERT INTO ptb_messages (id,
from_user_id, to_user_id, subject, content)
VALUES('NULL',
'1',
'".$_SESSION['user_id']."',
'Welcome...',
'Hi There :D,<br/><br/>
Welcome to your brand new, sparkling profile. We're so excited to have you with us! We just wanted to check in on you to see how you were getting on, and to let you know that if you have any questions or comments for us then please do not hesitate to get in touch at Support@fixstructure.com.<br/><br/>
fixstructure.com is a fun, friendly and clean community, please help us keep it this way. We want you to enjoy your new profile to the maximum but there are a few do's and dont's, for more information checkout our Terms and User Policy under the help link in your Account Settings menu.<br/><br/>
That's pretty much everything, so thanks once again for joining the fixstructure.com community and we look forward to seeing more of you and watching your new profile grow in the future.<br/><br/>Regards,<br/>The fixstructure Team'
)";
mysql_query($query) or die('error');
4

2 に答える 2

0

コンテンツを変数に入れます。

$content = "Hi There :D,<br/><br/> Welcome to your brand new, sparkling profile. We\'re so excited to have you with us! We just wanted to check in on you to see how you were getting on, and to let you know that if you have any questions or comments for us then please do not hesitate to get in touch at Support@fixstructure.com.<br/><br/> fixstructure.com is a fun, friendly and clean community, please help us keep it this way. We want you to enjoy your new profile to the maximum but there are a few do\'s and dont's, for more information checkout our Terms and User Policy under the help link in your Account Settings menu.<br/><br/> That\'s pretty much everything, so thanks once again for joining the fixstructure.com community and we look forward to seeing more of you and watching your new profile grow in the future.<br/><br/>Regards,<br/>The fixstructure Team";

それから電話する

$res=addslashes($content);

$resの挿入ステートメントで値として使用できるようになりましたcontent

于 2013-03-25T03:56:46.543 に答える
-1

一重引用符をエスケープします。また、 と の使用を交換し""ます''

    $query='INSERT INTO ptb_messages (id,
from_user_id, to_user_id, subject, content)
VALUES("NULL",
"1",
"'.$_SESSION['user_id'].'",
"Welcome...",
"Hi There :D,<br/><br/>
Welcome to your brand new, sparkling profile. We\'re so excited to have you with us! We just wanted to check in on you to see how you were getting on, and to let you know that if you have any questions or comments for us then please do not hesitate to get in touch at Support@fixstructure.com.<br/><br/>
fixstructure.com is a fun, friendly and clean community, please help us keep it this way. We want you to enjoy your new profile to the maximum but there are a few do\'s and dont\'s, for more information checkout our Terms and User Policy under the help link in your Account Settings menu.<br/><br/>
That\'s pretty much everything, so thanks once again for joining the fixstructure.com community and we look forward to seeing more of you and watching your new profile grow in the future.<br/><br/>Regards,<br/>The fixstructure Team"
)';
mysql_query($query) or die('error');
于 2013-03-25T03:51:44.723 に答える