使用TextArea更新SQL - 仅使用短字符串进行更新(Updating SQL with TextArea - only updates with short strings)
我有一个表格的textarea。 提交后,该表单会将一些信息插入数据库。 即使“newsText”是一个longtext,我只能插入短字符串。 我将使用确切的字符数更新此问题。
表格:
<form id="newsForm" action="<?php echo $uploadHandler ?>" enctype="multipart/form-data" method="post"> <div class="managementNewsTitle"> Title<br /> <input id="inputNewsTitle" name="inputNewsTitle" type="text"></input> </div> <div class="managementNewsTitle"> Image<br /> <input id="inputNewsFile" type="file" name="file" onchange="document.getElementById('inputNewsFilename').value = value;"><br /> Name<br /> <input id="inputNewsFilename" type="text"></input> </div> <div class="managementNewsTitle"> Text<br /> <textarea id="inputNewsText" name="inputNewsText"></textarea> </div> <input type="hidden" name="givenFileName" id="givenFileName" value=""> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>"> <input type="hidden" name="newsSubmitValue" id="submitValue" value="no"> <input type="button" id="newsSubmitButton" onclick="newsSubmit()" name="submitButton" value="Save"></input> </form>INSERT:
if($_POST['newsSubmitValue'] === "yes") { $newsTitle = $_POST['inputNewsTitle']; $newsText = $_POST['inputNewsText']; $newsImageURL = $_POST['givenFileName']; mysql_query("INSERT INTO cs_news VALUES (DEFAULT, CURRENT_TIMESTAMP, '".$newsTitle."', '".$newsText."', 'Images/".$newsImageURL."')"); }I have a textarea in a form. That form, upon submit, inserts some information into the databse. Even though "newsText" is a longtext, I am only able to insert short strings. I will update this question with the exact amount of characters.
The form:
<form id="newsForm" action="<?php echo $uploadHandler ?>" enctype="multipart/form-data" method="post"> <div class="managementNewsTitle"> Title<br /> <input id="inputNewsTitle" name="inputNewsTitle" type="text"></input> </div> <div class="managementNewsTitle"> Image<br /> <input id="inputNewsFile" type="file" name="file" onchange="document.getElementById('inputNewsFilename').value = value;"><br /> Name<br /> <input id="inputNewsFilename" type="text"></input> </div> <div class="managementNewsTitle"> Text<br /> <textarea id="inputNewsText" name="inputNewsText"></textarea> </div> <input type="hidden" name="givenFileName" id="givenFileName" value=""> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>"> <input type="hidden" name="newsSubmitValue" id="submitValue" value="no"> <input type="button" id="newsSubmitButton" onclick="newsSubmit()" name="submitButton" value="Save"></input> </form>The INSERT:
if($_POST['newsSubmitValue'] === "yes") { $newsTitle = $_POST['inputNewsTitle']; $newsText = $_POST['inputNewsText']; $newsImageURL = $_POST['givenFileName']; mysql_query("INSERT INTO cs_news VALUES (DEFAULT, CURRENT_TIMESTAMP, '".$newsTitle."', '".$newsText."', 'Images/".$newsImageURL."')"); }最满意答案
问题已经解决了。 它不是字符数量,而是字符的类型。
我在字符串中使用了引号。 这让我的SQL语句提前结束了。
Woops。
The problem has been solved. It was not the amount of characters, but the TYPE of characters.
I used quotes in the string. Which made my SQL statement end prematurely.
Woops.
更多推荐
发布评论