PHP chat

I am working on a PHP based chat for my own web site and I am using the function fread().
I get Error messages saying that fread() needs 2 peramators and I don’t know what the second is.
The Php script is…
[php]<?php
$target_file = “my_file.txt”;
$target_file_data = $_POST[“firstname”] . “”;
$handle = fopen($target_file, “a+”);
fwrite($handle, $target_file_data);
echo fread($handle);
fclose($handle);
?>[/php]
The html…

[code]

Ajax Post to PHP and Get Return Data

Your Comments:

[/code]

The JavaScript XMLhttpRequest Function.
[hr]

function ajax_post(){ var hr = new XMLHttpRequest(); var url = "../php/myphpscript.php"; var fn = document.getElementById("first_name").value; var vars = "firstname="+fn; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if(hr.readyState == 4 && hr.status == 200) { var return_data = hr.responseText; document.getElementById("status").innerHTML = return_data; } } hr.send(vars); document.getElementById("status").innerHTML = "processing..."; }

ThankYou :D.

If you’re unsure of a function’s syntax, just check php.net (php.net/fread)

Basically, you need to specify how much to read - the typical usage is the following:
[php]$content = fread($filehandle, filesize($filename));[/php]

thankyou

Sponsor our Newsletter | Privacy Policy | Terms of Service