FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Heredoc print to file? Use nowdoc.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Heredoc print to file? Use nowdoc. [message #172132 is a reply to message #172129] Mon, 31 January 2011 13:05 Go to previous messageGo to previous message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma:
Member
"Jerry Stuckle" wrote in message
news:ii6a9c$kmg$1(at)news(dot)eternal-september(dot)org...

> Your biggest problem is you are still trying to equate PHP to Perl. It's a
> HUGE mistake to do that (no matter what the language).
> Trying to look for the differences will only confuse you.

Well, I finally got everything working at least about as well as the
equivalent Perl script, so now I can just continue to develop this project
in PHP. I was confused about the {} operator and it seems that it is only
needed within a string. Now I have something like this:

$arr = array();
$qres = $db->query($q);
$line = 0;
while ($row = $qres->fetcharray(SQLITE3_BOTH)) {
for ($i = 0; $i < 9; $i++) {
$arr[$line][$i] = $row[$i];
}
$dtStart = date_create_from_format('Y-m-d', substr($arr[$line][4], 0,
10) );
$dowStart = $arr[$line][5];
$timeStart = substr($arr[$line][4], 11, 5);
$dtEnd = date_create_from_format('Y-m-d', substr($arr[$line][6], 0,
10) );
$dowEnd = $arr[$line][7];
$timeEnd = substr($arr[$line][6], 11, 5);
$url = $arr[$line][3];
$descr = $arr[$line][8];
$id = $arr[$line][0];
$title = $arr[$line][2];

$nowdoc .= "<p><h3>Title: $title</h3>\n Entry ID: $id\n";
$nowdoc .= "<h4>From: $dowStart, ";
$nowdoc .= date_format($dtStart, 'M d, Y');
$nowdoc .= " at $timeStart";
$nowdoc .= " to $dowEnd, ";
$nowdoc .= date_format($dtEnd, 'M d, Y') . "\n";
$nowdoc .= " at $timeEnd</h4>\n";
$nowdoc .= "URL: $url\n<br>Description: $descr<hr></p>\n";
$line++;
}

It would be better with an associative array but I'm not sure if I can loop
through with:

// eid,etype,et,eurl,sdt,sdow,edt,edow,ed (array elements)
for ($i = 'eid'; $i <= 'ed'; $i++) {
$arr[$line][$i] = $row[$i];
}

I would normally (in Delphi) do this with an "enum" with the integers 0..8
represented by eid..ed.

When I get this script cleaned up I'll put it on my website so you may be
able to see the whole thing and provide any major caveats. I am concerned
about security although the data in this database is (at present) only going
to be lists of events and outings, and I might also make a similar setup for
a sort of blog or ongoing discussion. I've learned a lot over the past
several days, and I do think PHP is the best for me to use from now on.
Thanks for the help and patience.

Paul
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Unable to connect to database server!
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 10:50:48 GMT 2024

Total time taken to generate the page: 0.04189 seconds