I've been trying to incorporate a log of usage on my website. I'm using the following PHP code for it..
<?php
echo "Hello";
$named = new DOMDocument();
echo "is";
$named->loadHTMLFile("html/trial12.htm");
echo "anybody";
$fartele = $named->getElementById("art");
echo "home?";
$value = $fartele->textContent;
echo $value;
$ip = $_SERVER['REMOTE_ADDR'];
$file=开发者_如何学Cfopen("logofusage.out","a+");
fwrite($file,$value);
fwrite($file,",");
fwrite($file,$ip);
fwrite($file,",");
$timevariable = date("l dS \of F Y h:i:s A")."\n";
fwrite($file,$timevariable);
fclose($file);
?>
The echo thing is for debugging. But I can seem to get the script to run on my university's webserver. If I use just some predefined value for "$value" variable, and comment out the top part, I can see that the logofusage file is being populated. But when I use the script as above, I can't get past the "Hello". So I figure the problem is on the "new DOMDocument " line. Can anyone tell me what it could be?
P.S. Just to clarify a bit more, I am using Javascript to accept an input from the user and saving it to a "div" element in the HTML file, and then accessing the text inside the "div" element.
The server uses PHP Version 5.3.1 . And my HTML document has a doctype HTML 4.01 Transitional Thanks for the help. :) AjrockerSo the university server does not have the DOMDocument extension. Guess that's that
Is there any other way to pull data from the HTML file and post it onto the server without AJAX...
if you don't get past
new DOMDocument();
then I guess this extension is not available.
B/c there is not much that could be wrong with your script up to this point.
Check the output of phpinfo() and/or get_loaded_extensions() to see which are available.
Also libxml is required to get DOMDocument do its job.
Check if your DOMDocument extension is enabled (using phpinfo() or cli).
精彩评论