Hi, I've installed the software, and I am trying to learn to use it through the examples.
So far, I receive this error on every example script that I try
Parse error: syntax error, unexpected T_VARIABLE in /home/content/../../eyebeam.php on line 3
The script is what was generated from the MagicParser demo. It seems to work well on the MagicParser demo page, but not when moved to my own host.
Thank you for whatever assistance you can offer.
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
// This is where you write your code to process each record, such as loading a database
// You can display the record contents using PHP's internal print_r() function:
print_r($record);
// The following code will print out each field in your sample data:
print $record["ENTRY"];
print $record["TITLE"];
print $record["LINK"];
print $record["LINK-REL"];
print $record["LINK-TYPE"];
print $record["LINK-HREF"];
print $record["MODIFIED"];
print $record["ISSUED"];
print $record["ID"];
print $record["CREATED"];
print $record["SUMMARY"];
print $record["SUMMARY-TYPE"];
print $record["AUTHOR"];
print $record["AUTHOR/NAME"];
print $record["AUTHOR/URL"];
print $record["CONTENT"];
print $record["CONTENT-TYPE"];
print $record["CONTENT-MODE"];
print $record["CONTENT-XML:LANG"];
print $record["CONTENT-XML:BASE"];
}
MagicParser_parse("http://www.eyebeam.org/reblog/atom.xml","myRecordHandler","xml|FEED/ENTRY/");
?>
Both scripts you suggested work fine. The errors only seem to start when I try to use the examples or demo code.
<?php
require("MagicParser.php");
?>
Also, I did try re-unzipping the file, and I can view the contents just fine with my text editor.
Hello Matt,
Does the error occur when trying to run MagicParserTest.php that is included in the distribution (it must be run from the same folder as MagicParser.php)?
Although my responses may be delayed over this Christmas period I will try to get you working - but if of course you decide not to use Magic Parser I will of course refund your purchase...
Cheers,
David.
David, thanks for the speedy reply. I certainly understand if you don't respond right away over Christmas, and I appreciate your help sorting this problem out.
Here is what I see when I visit MagicParserTest.php using my browser:
Array ( [DEMO] => [MESSAGE] => If you can read this message your Magic Parser installation is working! )
Hello Matt,
Could you perhaps try modifying MagicParserTest.php to simulate your code, by changing:
$result = MagicParser_parse("MagicParserTest.xml","myRecordHandler");
To:
$result = MagicParser_parse("http://www.eyebeam.org/reblog/atom.xml","myRecordHandler","xml|FEED/ENTRY/");
I'm somewhat confused as the test script works OK, but an empty file with nothing but require("MagicParser.php") gives the error, so i'm not sure what's going on but let's see what happens this time. The next step will be to replace myRecordHandler function with your record handler, which should then be back pretty much to your original script...
Cheers,
David.
Hi, I did what you suggested and changed MagicParserTest.php file to include
$result = MagicParser_parse("http://www.eyebeam.org/reblog/atom.xml","myRecordHandler","xml|FEED/ENTRY/");
Hi Matt,
If you have been able to modify MagicParserTest.php as described, the script should now be extremely close the original version you posted at the top of this thread.
Could you try now copying the code from within the myRecordHandler from the original post into the same function in MagicParserTest.php?
If there error returns, could you then post both versions so that I can try to understand the difference....
Cheers,
David.
Well, I did as you suggested. The MagicParserTest.php script works with the code from myRecordHandler on the original post. Here is the content from MagicParserTest.php:
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
print_r($record);
// The following code will print out each field in your sample data:
print $record["ENTRY"];
print $record["TITLE"];
print $record["LINK"];
print $record["LINK-REL"];
print $record["LINK-TYPE"];
print $record["LINK-HREF"];
print $record["MODIFIED"];
print $record["ISSUED"];
print $record["ID"];
print $record["CREATED"];
print $record["SUMMARY"];
print $record["SUMMARY-TYPE"];
print $record["AUTHOR"];
print $record["AUTHOR/NAME"];
print $record["AUTHOR/URL"];
print $record["CONTENT"];
print $record["CONTENT-TYPE"];
print $record["CONTENT-MODE"];
print $record["CONTENT-XML:LANG"];
print $record["CONTENT-XML:BASE"];
}
$result = MagicParser_parse("http://www.eyebeam.org/reblog/atom.xml","myRecordHandler","xml|FEED/ENTRY/");
if (!$result)
{
print MagicParser_getErrorMessage();
}
?>
However this code from my first posting still gives the error. Original code:
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
// This is where you write your code to process each record, such as loading a database
// You can display the record contents using PHP's internal print_r() function:
print_r($record);
// The following code will print out each field in your sample data:
print $record["ENTRY"];
print $record["TITLE"];
print $record["LINK"];
print $record["LINK-REL"];
print $record["LINK-TYPE"];
print $record["LINK-HREF"];
print $record["MODIFIED"];
print $record["ISSUED"];
print $record["ID"];
print $record["CREATED"];
print $record["SUMMARY"];
print $record["SUMMARY-TYPE"];
print $record["AUTHOR"];
print $record["AUTHOR/NAME"];
print $record["AUTHOR/URL"];
print $record["CONTENT"];
print $record["CONTENT-TYPE"];
print $record["CONTENT-MODE"];
print $record["CONTENT-XML:LANG"];
print $record["CONTENT-XML:BASE"];
}
MagicParser_parse("http://www.eyebeam.org/reblog/atom.xml","myRecordHandler","xml|FEED/ENTRY/");
?>
Hi Matt,
As there is hardly any difference between them now; could you make the final change and modify the last section of MagicParserTest.php from:
$result = MagicParser_parse("http://www.eyebeam.org/reblog/atom.xml","myRecordHandler","xml|FEED/ENTRY/");
if (!$result)
{
print MagicParser_getErrorMessage();
}
...to just:
MagicParser_parse("http://www.eyebeam.org/reblog/atom.xml","myRecordHandler","xml|FEED/ENTRY/");
That will make both files identical. If this works (in MagicParserTest.php) then the problem may be something very obscure such as invalid characters in your test PHP file that are confusing the parser. If this is the case, I would suggest working from here with MagicParserTest.php (renaming as required)...
Cheers,
David.
That worked also. I'll work from the modified MagicParserTest.php file as you suggested. Thank you for your help on this.
-Matt
Hello Matt,
It's possible that this indicates a PHP configuration error. Can you first try an almost empty test script:
<?php
print "PHP Test";
?>
Assuming that works, then try just including the Magic Parser library on its own:
<?php
require("MagicParser.php");
?>
If you still get the same error; it is possible that MagicParser.php did not unzip correctly or was corrupted, so it might be worth extracting it again just to make sure...
Cheers,
David.