Why is text not being correctly entered into the database after the first space in a PHP news script?

The issue may be due to improper handling of the input data. To solve this, you can use the PHP function `mysqli_real_escape_string` to properly escape the input text before inserting it into the database. This function will ensure that special characters, including spaces, are handled correctly.

// Assuming $conn is your database connection
$text = mysqli_real_escape_string($conn, $_POST['text']);
$query = "INSERT INTO news (text) VALUES ('$text')";
mysqli_query($conn, $query);