time bomb
Moderator: General Moderators
time bomb
back again...
i'm wondering if there is a way to submit a form everyday at a certain time. i.e. I have a form that pulls from an rss feed and I strip some stuff out of it with substr, then submit it to a text file that is displayed on the site.
So I just need to be pointed to a manual or something of the sort on how to write a script that submits the form everyday at "X" o'clock.
thanks in advance
i'm wondering if there is a way to submit a form everyday at a certain time. i.e. I have a form that pulls from an rss feed and I strip some stuff out of it with substr, then submit it to a text file that is displayed on the site.
So I just need to be pointed to a manual or something of the sort on how to write a script that submits the form everyday at "X" o'clock.
thanks in advance
ok, maybe I lied... I just got the email confirmation that it ran, but the email contains the html from the page i have set to run, its suppossed to submit info to a text file. here is the code for test.php which is the file that I am trying to run a the specified times
the funtion render_news is in the file as well, just didn't want to overwhelm the page with unneeded code.
But, what is stopping cron from running this script?
thanks,
Code: Select all
<html><body><form action="textinsert.php" name="form" method="POST"><textarea cols="45" rows="5" name="report">
<? render_news("http://www.surfline.com/rss/region.cfm?alias=cocoabeachcam", false, 'news', 'news2','1'); ?>
</textarea>
</form>
<script type="text/javascript">
window.onload=document.forms["form"].submit();
</script>
</body></html>But, what is stopping cron from running this script?
thanks,
okay, forgive me, but i'm loosing you. I don't want it to email me, because it will be running this script (to get the surf report to a client's site) everyday. I just want it to submit to a php page that uses substr to remove the link, then fopen to submit it to a text file.feyd wrote:output from the script run by cron is considered error data which is emailed to the registered account. Your output should be stored into the file you are wishing to update.
sorry i'm a bit lost.
I had thought you said you were emailing it to yourself... what feyd is saying (I believe) is that ouput from your script is being sent to you by your host in an email... so that's why you got the email. So... eliminate the form... and just have the script extract the information, fopen the file you want to write it to, write the information, close the file... end script. that's it.
ok, got the file ready, but have a problem with some syntax, i'm trying to set a function to be a variable "$report" so i can substr$report down. here is my code.The Ninja Space Goat wrote:I had thought you said you were emailing it to yourself... what feyd is saying (I believe) is that ouput from your script is being sent to you by your host in an email... so that's why you got the email. So... eliminate the form... and just have the script extract the information, fopen the file you want to write it to, write the information, close the file... end script. that's it.
Code: Select all
$report=render_news("http://www.surfline.com/rss/region.cfm?alias=cocoabeachcam", false, news, news2,1);thanks
Code: Select all
//$headline_style = 'news';
$headline_style = '';
$detail_style='news2';
$description_style = '';
$feed_url = '';
$show_detail = true;
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$insideimage = true;
$max = 1;
$count = 1;
function render_news($feed_url, $showdetail, $headlinestyle, $detailstyle, $max_headlines=1) {
global $show_detail, $headline_style, $detail_style, $max, $count, $insideitem, $insideimage;
$insideitem=false;
$insideimage=true;
$count = 0;
$show_detail = $showdetail;
$headline_style = $headlinestyle;
$detail_style = "news2";
$max=$max_headlines;
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($feed_url,"r")
or die("Error reading RSS data.");
if ($fp) {
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
} else {
echo '<span class="'. $detail_style .'">Syndicated content not available</span>';
}
// Free up memory used by the XML parser
xml_parser_free($xml_parser);
}
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link, $insideimage;
if ($insideitem || $insideimage) {
$tag = $name;
}
if ($name == "ITEM" ) {
$insideitem = true;
}
if ($name == "IMAGE") {
$insideimage = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link, $insideimage, $show_detail, $headline_style, $detail_style, $count, $max;
if ($name == "URL") {
$insideimage=false;
} else if ($name == "ITEM" && $count < $max) {
$count++;
printf('<a href="%s" class="'. $headline_style .'" target="_blank">%s</a><br /><br />',trim($link),trim($title));
if ($show_detail)
printf('<span class="'. $detail_style .'">%s</span><br /><br />',trim($description));
else {
echo "";
}
$title = "";
echo "";
$description = "";
$link = "";
$insideitem = false;
} else if ($count >= $max) {
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link, $insideimage;
if ($insideimage) {
switch ($tag) {
case "URL":
break;
}
}
if ($insideitem ) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
if (!is_string($link)) $link="";
$link .= $data;
break;
}
}
}you need to take all of those echo() and store that output instead... then return the stored out put with the return control.
OR
you can use the Output Control Functions to capture the content into a variable
OR
you can use the Output Control Functions to capture the content into a variable
not catching you... the only echo with anything in it is for an error... help pleaseThe Ninja Space Goat wrote:you need to take all of those echo() and store that output instead... then return the stored out put with the return control.
OR
you can use the Output Control Functions to capture the content into a variable