The error:
PHP Notice: Undefined variable: exec in readings.php on line 3
PHP Fatal error: Function name must be a string in readings.php on line 3
The code:
<?php
require('smarty_config.php');
exec('reading_fetcher.py',$output,$ret_code);
$smarty->assign('readings',$output);
$smarty->display('readings.tpl');
?>
I was asked for the code of reading_fetcher.py
so here it is:
#!/usr/bin/env python
import urllib2, re
response = urllib2.urlopen('http://it.ctsfw.edu/inc/nc_scriptureframe.php')
html = response.read()
def remove_html_tags(data):
p = re.compile(r'<.*?>')
return p.sub(' ', data)
import re
import htmlentitydefs
def convertentity(m):
if m.group(1)=='#':
try:
return unichr(int(m.group(2)))
except ValueError:
return '&#%s;' % m.group(2)
try:
return htmlentitydefs.entitydefs[m.group(2)]
except KeyError:
return '&%s;' % m.group(2)
def converthtml(s):
return re.sub(r'&(#?)(.+?);',convertentity,s)
readings = converthtml(str(remove_html_tags(html)))
readings.replace(" ", " ")
print readings[699:]
I already looked here, here and here. Two of those errors are an extra "$". I don't see an extra "$" on my function name. The third error is having "()" instead of "[]". So I tried replacing them. That didn't work. What else might I try?
function_exists('exec')
return true? (It pretty surely does, but who knows?) – zneak Feb 1 '11 at 5:26Fatal error: Call to undefined function
. (I think.) – alex Feb 1 '11 at 5:29smarty_config.php
? Do you get a different error? If so, probably that the problem is in the file. – zneak Feb 1 '11 at 5:34smarty_config.php
has no effect. The error remains the same. – John Feb 1 '11 at 5:53