pake10
09-04-2009, 08:04 PM
Make up coding this code, but when runnig this code, php says this:
Parse error: syntax error, unexpected T_STRING in /home/jiminet/www/chat.php on line 6
Code:
<?php
include("check.php");
$_POST['message'];
$file = fopen("messages.txt","w");
$line = $tunnus | $message
fwrite($file, $line);
fclose($file);
header("Location: http://jiminet.jouluserver.com/chat.html")
?>
How to fix this problem?
My english is bad, when live in Finland.
tomws
09-04-2009, 08:31 PM
<?php
include("check.php");
$_POST['message'];
$file = fopen("messages.txt","w");
$line = $tunnus | $message; /*** <<< ***/
fwrite($file, $line);
fclose($file);
header("Location: http://jiminet.jouluserver.com/chat.html")
?>
_Aerospace_Eng_
09-04-2009, 10:33 PM
There needs to be quotes in there on this line.
$line = $tunnus." | ".$message;
The_Return
09-04-2009, 11:05 PM
I think he frogot the " ; " on header("Location: http://jiminet.jouluserver.com/chat.html")
_Aerospace_Eng_
09-04-2009, 11:06 PM
The last ; before the closing ?> tag isn't necessary though it is good habit.
mOrloff
09-04-2009, 11:52 PM
So, to put everyone elses great suggestions all together:
<?php
include("check.php");
$_POST['message'];
$file = fopen("messages.txt","w");
$line = $tunnus." | ". $message; <-------<<< 2 fixes
fwrite($file, $line);
fclose($file);
header("Location: http://jiminet.jouluserver.com/chat.html"); <-------<<< 1 fix
?>
pake10
09-05-2009, 10:27 AM
So, to put everyone elses great suggestions all together:
<?php
include("check.php");
$_POST['message'];
$file = fopen("messages.txt","w");
$line = $tunnus." | ". $message; <-------<<< 2 fixes
fwrite($file, $line);
fclose($file);
header("Location: http://jiminet.jouluserver.com/chat.html"); <-------<<< 1 fix
?>
Now says this:
Warning: fwrite(): supplied argument is not a valid stream resource in /home/jiminet/www/chat.php on line 6
Warning: fclose(): supplied argument is not a valid stream resource in /home/jiminet/www/chat.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at /home/jiminet/www/chat.php:6) in /home/jiminet/www/chat.php on line 8
How to fix?
abduraooft
09-05-2009, 10:45 AM
Add ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting (E_ALL); at the top of your code and see if there's any error message.
pake10
09-05-2009, 10:52 AM
Add ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting (E_ALL); at the top of your code and see if there's any error message.
Says this:
Parse error: syntax error, unexpected T_STRING in /home/jiminet/www/chat.php on line 9
How to fix?