Jump to content

Php Configuration


eon

Recommended Posts

Hi Guys,I've been trying a couple of the PHP/AJAX/XML tutorials and had the same problem with them. I'm using WAMP on my windows install to try these.The tutorials I was looking at are these 2:http://www.w3schools.com/php/php_ajax_xml.asphttp://www.w3schools.com/php/php_ajax_rss_reader.aspThe problem seems to be with the PHP pages when reaching the "->" operator, after it is reached, all the code after it is outputted as text rather than executed.The code

<?php$q=$_GET["q"];$xmlDoc = new DOMDocument();$xmlDoc->load("cd_catalog.xml");$x=$xmlDoc->getElementsByTagName('ARTIST');

(only included the first few lines)Will output

load("cd_catalog.xml"); $x=$xmlDoc->getElementsByTagName('ARTIST'); for ($i=0; $i<=$x->length-1; $i++) { //Process only element nodes if ($x->item($i)->nodeType==1) { if ($x->item($i)->childNodes->item(0)->nodeValue == $q) { $y=($x->item($i)->parentNode); } } } $cd=($y->childNodes); for ($i=0;$i<$cd->length;$i++) { //Process only element nodes if ($cd->item($i)->nodeType==1) { echo($cd->item($i)->nodeName); echo(": "); echo($cd->item($i)->childNodes->item(0)->nodeValue); echo(""); } } ?>

Similarly,

$xmlDoc->load($xml);

Will output

load($xml);

Followed by the rest of the script.I was wondering if anyone who was a bit more familiar with php might have an idea if this is down to a setting somewhere being wrong or an extension not being enabled? I've done a bit of c/c++ and seem to remember -> being used for a pointer, and can be replaced by other notations. I was wondering if this would be the case for php but google ignores those characters so isn't much use there!Thanks,Rob

Link to comment
Share on other sites

Are you sure the PHP is being parsed? Is PHP enabled/installed/supported on your server, and are your pages named with the .php extension? The reason you see everything after the "->" symbol is because the HTML parser in the browser is reading everything up to that point as one big tag.The -> operator in PHP is the member access operator.

Link to comment
Share on other sites

Are you sure the PHP is being parsed? Is PHP enabled/installed/supported on your server, and are your pages named with the .php extension? The reason you see everything after the "->" symbol is because the HTML parser in the browser is reading everything up to that point as one big tag.The -> operator in PHP is the member access operator.
Thanks for the reply. I feel a bit silly now, you were spot on. Viewing the source showed the rest of the php code, it wasn't being parsed as you said. Restarting wamp seems to have fixed everything now. Thanks for the help! :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...