I'm trying to store alot of text inside a database, here is my database code:
CREATE TABLE entries(
ID int NOT NULL AUTO_INCREMENT,
title varchar(255),
post TINYTEXT,
timestamp int(11),
poster varchar(255),
upvotes int(255),
PRIMARY KEY (ID)
);
When I try to enter the text it gives the generic error of checking the MYSQL instructions. When the amount of text is limited however it works even though I am using the type of tinytext which should be able to store alot more information. So what am I missing?
This is my code for entering the information into the database
if (isset($_POST["title"]) and isset($_POST["posttext"])){
$title = $_POST["title"];
$postText = $_POST['posttext'];
$name = $_SESSION["name"];
$upvotes = 0;
date_default_timezone_set('UTC');
$time = time();
$sql = "INSERT INTO entries (title, post, timestamp, poster, upvotes) VALUES ('$title', '$postText', '$time', '$name', '$upvotes')";
if ($conn->query($sql) === TRUE) {
header("Location: ../index.php");
}
else{
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
Any help on using the tinytext or any other type for storing large amounts of information would be helpful.
For those wondering, I know the different amounts of data that can be stored in all the text variants but that still doesn't fix my issue even when I tired all the other options.
Thanks