Adriano-KF 0 Newbie Poster

Hi there!

I suspect you have an error in your SQL query. You could insert an echo $sql."<br>"; right before your mysql_query to check, if the query is correct.

Maybe the problem lies with the session, did you call session_start() beforehand?

Hope that helps somewhat. Happy coding! :)

Adriano-KF 0 Newbie Poster

Hi!

When executing a query which alters the table (UPDATE, INSERT, etc...), mysql_query returns TRUE on success and FALSE on error.

So your if-clause should read

if ($result == TRUE) {

or simply

if ($result) {

Hope that helps!

Happy coding! :)

Adriano-KF 0 Newbie Poster

Hi there!

In your output part you need to escape the inner double-quotes like this:

if ($result){
print "<meta http-equiv=\"refresh\" content=\"0;URL=messagesent.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=messagenotsent.html\">";
}

A more in-depth explanation is given in the PHP documentation on strings.

Happy coding! :)

Adriano-KF 0 Newbie Poster

You could also use

$newtext = nl2br($text);

which has been around since PHP 4 for this purpose.

BTW this problem - if I get it correctly - does not originate from echo 's behaviour, but rather from HTML, which does ignore all whitespace by default. So you have to substitute all \n with <br /> in order to have the line breaks in your HTML output, too (e.g. by using your preg_replace solution or nl2br ).

Happy coding! :)