使用TextArea更新SQL

编程入门 行业动态 更新时间:2024-10-27 14:32:22
使用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.

更多推荐

本文发布于:2023-08-04 06:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1412761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:TextArea   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!