OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 8 Feb 2008 19:59:33 -0000 Issue 5282

php-general-digest-helplists.php.net
Date: Fri Feb 08 2008 - 13:59:33 CST


php-general Digest 8 Feb 2008 19:59:33 -0000 Issue 5282

Topics (messages 268929 through 268977):

Re: PHP Source code protection
        268929 by: Per Jessen
        268930 by: Per Jessen
        268932 by: Richard Heyes

Re: Recommended ORM for PHP
        268931 by: Zoltán Németh
        268934 by: Manuel Lemos
        268936 by: Zoltán Németh

Re: Profiling with register_tick_function / declare
        268933 by: Jochem Maas

generate xls file on fly
        268935 by: Hiep Nguyen
        268937 by: Per Jessen
        268938 by: Adrian Bruce
        268939 by: Daniel Brown
        268940 by: Hiep Nguyen
        268943 by: Jason Pruim
        268947 by: Andrew Ballard
        268948 by: Hiep Nguyen
        268949 by: Per Jessen

Name of variable to string
        268941 by: tedd
        268942 by: Eric Butera
        268944 by: Jason Pruim
        268945 by: Daniel Brown
        268946 by: Adrian Bruce
        268959 by: Richard Lynch
        268968 by: David Giragosian
        268969 by: Eric Butera
        268970 by: Daniel Brown
        268971 by: Paul Scott
        268972 by: Daniel Brown
        268973 by: Jason Pruim
        268974 by: David Giragosian
        268976 by: Daniel Brown

fgets???
        268950 by: Pastor Steve
        268951 by: Zoltán Németh
        268952 by: Pastor Steve
        268953 by: Daniel Brown
        268954 by: Zoltán Németh
        268955 by: Zoltán Németh
        268956 by: Daniel Brown
        268957 by: Nirmalya Lahiri
        268958 by: Richard Lynch
        268960 by: Daniel Brown
        268961 by: Zoltán Németh

Re: php file extension
        268962 by: Richard Lynch
        268966 by: Per Jessen

Re: Directory
        268963 by: Richard Lynch

Re: shopping carts
        268964 by: Richard Lynch

Re: problem with imagefontwidth function, It looks to be unavailable...
        268965 by: Richard Lynch
        268975 by: Børge Holen
        268977 by: Daniel Brown

Re: Passing object reference to session
        268967 by: Richard Lynch

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Greg Donald wrote:

> Deductive reasoning leads to two possible options:
>
> 1) Don't give the code to anyone.
> 2) Give the code to the client and accept the fact that it may get
> pirated.

Yep, that's all there is to it.

/Per Jessen, Zürich

attached mail follows:


Casey wrote:

>
> Why not just translate it to C#?

Personally I'd just go for C - that way I can just distribute a binary
and be done with it. No runtime, no JVM, no mono etc.

/Per Jessen, Zürich

attached mail follows:


> accept the fact that it may get pirated.

It may do. But there's nothing wrong with making it as hard as possible
to do so. Most people have better things to do than try to reverse
engineer a piece of code.

Consider:

1. People who buy code will generally do so to solve a problem that they
    have in the process of making money.
2. Reverse engineering takes time, and therefore diverts their attention
    away from the process of making money.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Helpdesk software for £299 hosted for you -
no installation, no maintenance, new features automatic and free

              ** New Helpdesk demo now available **

attached mail follows:


2008. 02. 7, csütörtök keltezéssel 13.15-kor Manuel Lemos ezt írta:
> Hello
>
> on 02/07/2008 07:26 AM Zoltán Németh said the following:
> >>> When creating a LAMP app, I always start by writing ORM myself.
> >>> It's fun but it usually takes a long time.
> >>> Besides, that always results in a toy-system,
> >>> I mean, that has not so many features, not so efficient non-bug-free.
> >>>
> >>> I started to think that now is the time to throw away my rubbish
> >>> and use more effective Open source ORM.
> >>>
> >>> So my question is what ORM are you using?
> >>> What ORM do you recommend?
> >>> There're lots of Web app frameworks out there
> >>> but I could't find simple ORM in PHP.
> >> A similar question was asked here a couple of days ago.
> >>
> >> I will be repeating myself, but what I said was that I use Metatsorage
> >> which is an ORM class generator tool. It is a different approach than
> >> others you may find. It generates persistent object classes that are
> >> smaller and more efficient.
> >
> > that's exactly the same method all the ORMs we mentioned earlier
> > (Doctrine, Propel, Qcodo) work. all these generate classes. ;P
> >
> > aside from that, metastorage might be as good as any of the others of
> > course
>
> I don't know about Doctrine and QCodo, but once I looked at Propel and
> the way it works was not exactly better than Metastorage generated
> classes from my point of view.
>
> What happens is that Propel relies on fat base classes that the
> generated persistent object classes need to inherit to do the actual
> Object-relational mapping.
>
> Metastorage generates self-contained code. This means the generated
> classes are root classes that do only what you need. The generated code
> does the necessary database calls directly to store and retrieve objects.
>
> It does not call base classes like Propel generated classes that waste
> time composing SQL queries at run-time. Metastorage generated classes
> already have the necessary SQL built-in to execute the queries without
> further analysis at run-time.
>
> Another aspect is that Metastorage features what is called report
> classes. These are classes that perform queries that you define and
> generates SQL and PHP at compile time to retrieve data from the
> persistent objects for read-only purposes.

and what if you want to switch sql server from mysql to oracle or
whatever? in propel, you change 1 line in the config, you don't have to
regenerate or rewrite anything.

the base classes are useful too because if you change your schema, you
simply regenerate them and all your extensions remain the same in the
child classes.

>
> For instance, if you want to send a newsletter to a million subscribers
> and you just need the e-mail address and names of the subscribers, you
> can tell Metastorage to generate a report class that queries the users
> objects and retrives just the name and e-mail address. The report
> classes return arrays just like plain SELECT queries.
>
> If you use the Propel approach you would need to retrieve 1 million
> objects of the users class just to pick the name and e-mail address,
> which is totally inefficient in terms of memory and very slow.

not at all. you can build the criteria for the select and then run a
doSelectRS method which gives you only the result set in an array, no
objects involved.

>
> There are more differences between Metastorage and Propel (and probably
> others approach). I just wanted to make the point that the fact that
> approaches use generated code, it does not mean that all provide the
> same efficiency.

yeah, sure. however there is a payoff between efficiency and portability
and maintainability, and of course not all these orms have the same
level of these. choose the one that fits your needs best.

>
> If you are interested about more differences in the approaches, you may
> check the Metastorage documentaion:
>
> http://www.metastorage.net/
>

sure, I'll check it out when I have some free time

greets
Zoltán Németh

> --
>
> Regards,
> Manuel Lemos
>
> PHP professionals looking for PHP jobs
> http://www.phpclasses.org/professionals/
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>

attached mail follows:


Hello,

on 02/08/2008 06:15 AM Zoltán Németh said the following:
>> Another aspect is that Metastorage features what is called report
>> classes. These are classes that perform queries that you define and
>> generates SQL and PHP at compile time to retrieve data from the
>> persistent objects for read-only purposes.
>
> and what if you want to switch sql server from mysql to oracle or
> whatever? in propel, you change 1 line in the config, you don't have to
> regenerate or rewrite anything.
>
> the base classes are useful too because if you change your schema, you
> simply regenerate them and all your extensions remain the same in the
> child classes.

Metastorage generates totaly database independent code . You don't need
to regenerate the code to support multiple databases nor have fat base
classes to access your database or do any other ORM operations.

Currently it generates code that uses Metabase database abstraction
layer, although it can support other database abstraction layers. It
supports many databases like MySQL, PostgreSQL, Oracle, Microsoft SQL
server, SQLite, etc..

Metabase also generates a separate class for installing or upgrading
your database schema. If you change the definition of you objects, you
just need to call that class to install, upgrade, downgrade your
database schemas, safely without loosing any data that was already in
the database.

This is something very secure, as it does not do any schema changes if
the underlying database does not support certain things you want to
change. If you ask for a change that is not possible, it simply fails
without changing anything. It is not that error prone migrations method
of Ruby on Rails, that you have to write "SQL" manually to do your
migrations, and if you made a mistake, your database data is lost.

>> For instance, if you want to send a newsletter to a million subscribers
>> and you just need the e-mail address and names of the subscribers, you
>> can tell Metastorage to generate a report class that queries the users
>> objects and retrives just the name and e-mail address. The report
>> classes return arrays just like plain SELECT queries.
>>
>> If you use the Propel approach you would need to retrieve 1 million
>> objects of the users class just to pick the name and e-mail address,
>> which is totally inefficient in terms of memory and very slow.
>
> not at all. you can build the criteria for the select and then run a
> doSelectRS method which gives you only the result set in an array, no
> objects involved.

That is not exactly what I am talking about. Metastorage has an Object
Query Language (OQL) that lets you express whatever query conditions you
want. It generates PHP code with the necessary SQL queries you need. You
do not have to build any queries programatically at run-time.

The generated code can return full SQL statements if you want to execute
them separately by some other application code, but usually I just use
the generated report classes directly, as they take care of many things
like pagination, so I do not have to deal with SQL directly. That is one
of the great benefits of ORM.

With Metastorage I just do not have to deal with SQL manually nor I am
forced to retrieve all as objects, not even when I am retrieving just a
few variables of multiple classes. I do not have to SQL joins manually.
That would be walking backwards in productivity.

>> There are more differences between Metastorage and Propel (and probably
>> others approach). I just wanted to make the point that the fact that
>> approaches use generated code, it does not mean that all provide the
>> same efficiency.
>
> yeah, sure. however there is a payoff between efficiency and portability
> and maintainability, and of course not all these orms have the same
> level of these. choose the one that fits your needs best.

Exactly. I choose to develop my own because nothing that existed in PHP
matched my needs and code quality code requirements. Of course doing it
yourself is an expensive measure because it takes time and skill to
reach a mature solution. I have been developing Metastorage for 6 years.
It is very mature and reliable, but there is always room for improvement.

>> If you are interested about more differences in the approaches, you may
>> check the Metastorage documentaion:
>>
>> http://www.metastorage.net/
>>
>
> sure, I'll check it out when I have some free time

--

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

attached mail follows:


2008. 02. 8, péntek keltezéssel 11.38-kor Manuel Lemos ezt írta:
> Hello,
>
> on 02/08/2008 06:15 AM Zoltán Németh said the following:
> >> Another aspect is that Metastorage features what is called report
> >> classes. These are classes that perform queries that you define and
> >> generates SQL and PHP at compile time to retrieve data from the
> >> persistent objects for read-only purposes.
> >
> > and what if you want to switch sql server from mysql to oracle or
> > whatever? in propel, you change 1 line in the config, you don't have to
> > regenerate or rewrite anything.
> >
> > the base classes are useful too because if you change your schema, you
> > simply regenerate them and all your extensions remain the same in the
> > child classes.
>
> Metastorage generates totaly database independent code . You don't need
> to regenerate the code to support multiple databases nor have fat base
> classes to access your database or do any other ORM operations.
>
> Currently it generates code that uses Metabase database abstraction
> layer, although it can support other database abstraction layers. It
> supports many databases like MySQL, PostgreSQL, Oracle, Microsoft SQL
> server, SQLite, etc..

ok, so there is not much difference in that :)

>
> Metabase also generates a separate class for installing or upgrading
> your database schema. If you change the definition of you objects, you
> just need to call that class to install, upgrade, downgrade your
> database schemas, safely without loosing any data that was already in
> the database.
>
> This is something very secure, as it does not do any schema changes if
> the underlying database does not support certain things you want to
> change. If you ask for a change that is not possible, it simply fails
> without changing anything. It is not that error prone migrations method
> of Ruby on Rails, that you have to write "SQL" manually to do your
> migrations, and if you made a mistake, your database data is lost.
>
>

schema versioning is cool, AFAIK it is missing from propel but of course
it can transform your schema without data loss.

>
> >> For instance, if you want to send a newsletter to a million subscribers
> >> and you just need the e-mail address and names of the subscribers, you
> >> can tell Metastorage to generate a report class that queries the users
> >> objects and retrives just the name and e-mail address. The report
> >> classes return arrays just like plain SELECT queries.
> >>
> >> If you use the Propel approach you would need to retrieve 1 million
> >> objects of the users class just to pick the name and e-mail address,
> >> which is totally inefficient in terms of memory and very slow.
> >
> > not at all. you can build the criteria for the select and then run a
> > doSelectRS method which gives you only the result set in an array, no
> > objects involved.
>
> That is not exactly what I am talking about. Metastorage has an Object
> Query Language (OQL) that lets you express whatever query conditions you
> want. It generates PHP code with the necessary SQL queries you need. You
> do not have to build any queries programatically at run-time.

in propel you do not touch SQL too ;)
you initialize an object of class Criteria and define whatever you want.
e.g.
$c = new Criteria();
$c->add('whatevercolumn', 'whatevervalue');

of course it can do much more, joins and everything you may need

>
> The generated code can return full SQL statements if you want to execute
> them separately by some other application code, but usually I just use
> the generated report classes directly, as they take care of many things
> like pagination, so I do not have to deal with SQL directly. That is one
> of the great benefits of ORM.
>
> With Metastorage I just do not have to deal with SQL manually nor I am
> forced to retrieve all as objects, not even when I am retrieving just a
> few variables of multiple classes. I do not have to SQL joins manually.
> That would be walking backwards in productivity.
>
>
> >> There are more differences between Metastorage and Propel (and probably
> >> others approach). I just wanted to make the point that the fact that
> >> approaches use generated code, it does not mean that all provide the
> >> same efficiency.
> >
> > yeah, sure. however there is a payoff between efficiency and portability
> > and maintainability, and of course not all these orms have the same
> > level of these. choose the one that fits your needs best.
>
> Exactly. I choose to develop my own because nothing that existed in PHP
> matched my needs and code quality code requirements. Of course doing it
> yourself is an expensive measure because it takes time and skill to
> reach a mature solution. I have been developing Metastorage for 6 years.
> It is very mature and reliable, but there is always room for improvement.

I too had thought about implementing my own ORM, because none of them
fits my needs exactly, however I don't have the time for that... so I
use whatever I find the best at the moment.

greets
Zoltán Németh

>
>
> >> If you are interested about more differences in the approaches, you may
> >> check the Metastorage documentaion:
> >>
> >> http://www.metastorage.net/
> >>
> >
> > sure, I'll check it out when I have some free time
>
>
>
> --
>
> Regards,
> Manuel Lemos
>
> PHP professionals looking for PHP jobs
> http://www.phpclasses.org/professionals/
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>

attached mail follows:


Daniel Brown schreef:
> On Feb 7, 2008 7:10 PM, Jochem Maas <jochemiamjochem.com> wrote:
>> McNaught, Scott schreef:
>>> . Get profile results for novices without having to mess around
>>> installing php binaries such as APD / zend debugger etc
>> I suppose that includes xdebug?
>
> If xdebug works as a local binary (which it may, I'm not sure),
> you'd still have to have a local php.ini and be allowed to override
> the server php.ini by configuration, no?
>
> What if both of the above are true, but a user has no permissions
> to compile?
>
> While I was going to point out this morning that he failed to
> mention xdebug (which is my personal favorite), I still wouldn't
> discount his script-based profiler, if he can get it to work. Imagine
> being able to drop that into a project on SourceForge.

indeed - I wasn't discounting his idea, if it works it could be very handy
for situtation where you don't have any server access.

>

attached mail follows:


hi friends,

i have a php page with the following logic:

<html>
<head>
<title>Download</title>
</head>
<table>
   <tr><td>Title></td><td>Author</td></tr>
   <? $sql = "select title,author from book where title != null and author != null"; ?>
   <? $rs = mysql_query($sql) or die(mysql_error()); ?>
   <? while($row = mysql_fetch_array($rs)) { ?>
   <tr><td><?=$row[0];?></td><td><?=$row[1];?></td></tr>
   <? } ?>
   <tr><td><a href="">Download Into Excel File</a></td></tr>
</table>
</html>

is there anyway to generate this into xls file w/o using fopen & fwrite to
the server? my goal is to have a link after the table and user can click
on that link and a save window pop up to allow user to save to local disk.

appreciate very much for any input.

t. hiep

attached mail follows:


Hiep Nguyen wrote:

> is there anyway to generate this into xls file w/o using fopen &
> fwrite to the server? my goal is to have a link after the table and
> user can click on that link and a save window pop up to allow user to
> save to local disk.

Yes - have a link like this:

<a href="<yourscript.php?parameters>">Get XLS file</a>

in yourscript.php, you evaluate the parameters given and build the XSL
file as output:

header("Content-Type: application/excel");
header("Content-Disposition: attachment; filename=\"filename\"");

print
.
.
.
.
.

done.

/Per Jessen, Zürich

attached mail follows:


Hiep Nguyen wrote:
> hi friends,
>
> i have a php page with the following logic:
>
> <html>
> <head>
> <title>Download</title>
> </head>
> <table>
> <tr><td>Title></td><td>Author</td></tr>
> <? $sql = "select title,author from book where title != null and
> author != null"; ?>
> <? $rs = mysql_query($sql) or die(mysql_error()); ?>
> <? while($row = mysql_fetch_array($rs)) { ?>
> <tr><td><?=$row[0];?></td><td><?=$row[1];?></td></tr>
> <? } ?>
> <tr><td><a href="">Download Into Excel File</a></td></tr>
> </table>
> </html>
>
>
> is there anyway to generate this into xls file w/o using fopen &
> fwrite to the server? my goal is to have a link after the table and
> user can click on that link and a save window pop up to allow user to
> save to local disk.
>
> appreciate very much for any input.
>
> t. hiep
>

Somthing like this works ok, you can further refine it for the purpse
you want.

<?php

$q= mysql_query("select * from table");
$count = mysql_num_fields($q);

//print field names
for ($i = 0; $i < $count; $i++) {
$header .= mysql_field_name($export, $i)."\t";
}
//print data
while($row = mysql_fetch_array($q, MYSQL_NUM))
{
   $table[] = implode("\t", $row);
}

$table= $header . "\r\n" . implode("\r\n", $table);
//set headers that prompt user for download
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Disposition: attachment; filename=fileName");
echo $table;

?>

Ade

attached mail follows:


On Feb 8, 2008 8:41 AM, Hiep Nguyen <hiepee.ucr.edu> wrote:
> hi friends,
>
> i have a php page with the following logic:
>
> <html>
> <head>
> <title>Download</title>
> </head>
> <table>
> <tr><td>Title></td><td>Author</td></tr>
> <? $sql = "select title,author from book where title != null and author != null"; ?>
> <? $rs = mysql_query($sql) or die(mysql_error()); ?>
> <? while($row = mysql_fetch_array($rs)) { ?>

    Hiep,

    You should also put all of the code you can into one block. Each
time you <? open and close ?> it will take longer to load. Not
noticeably on a single page with one user accessing it, but with full
sites and many simultaneous users, it will be noticeable. This is
because PHP is "stepping in and out" of parse mode. So simply
concatenate that code as follows:

<tr><td>Title></td><td>Author</td></tr>
<?
    $sql = "select title,author from book where title != null and
author != null";
    $rs = mysql_query($sql) or die(mysql_error());
    while($row = mysql_fetch_array($rs)) {
        echo "<tr><td>".$row[0]."</td><td>".$row[1];."</td></tr>\n";
    }
?>
<tr><td><a href="">Download Into Excel File</a></td></tr>
--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


On Fri, 8 Feb 2008, Per Jessen wrote:

> Hiep Nguyen wrote:
>
>> is there anyway to generate this into xls file w/o using fopen &
>> fwrite to the server? my goal is to have a link after the table and
>> user can click on that link and a save window pop up to allow user to
>> save to local disk.
>
> Yes - have a link like this:
>
> <a href="<yourscript.php?parameters>">Get XLS file</a>
>
> in yourscript.php, you evaluate the parameters given and build the XSL
> file as output:
>
> header("Content-Type: application/excel");
> header("Content-Disposition: attachment; filename=\"filename\"");
>
> print
> .
> .
> .
> .
> .
>
>
> done.

i already got this method, but the problem that i have is the parameters
is mysql statement and it's very long. i don't think a good idea to pass
this in the url. also, the page that i'm working on is a search page,
therefore the mysql statement is very complicate and long. that's why i
don't want to pass via url.

is there way to do within this page???

t. hiep

attached mail follows:


On Feb 8, 2008, at 10:14 AM, Hiep Nguyen wrote:

>
> On Fri, 8 Feb 2008, Per Jessen wrote:
>
>> Hiep Nguyen wrote:
>>
>>> is there anyway to generate this into xls file w/o using fopen &
>>> fwrite to the server? my goal is to have a link after the table and
>>> user can click on that link and a save window pop up to allow user
>>> to
>>> save to local disk.
>>
>> Yes - have a link like this:
>>
>> <a href="<yourscript.php?parameters>">Get XLS file</a>
>>
>> in yourscript.php, you evaluate the parameters given and build the
>> XSL
>> file as output:
>>
>> header("Content-Type: application/excel");
>> header("Content-Disposition: attachment; filename=\"filename\"");
>>
>> print
>> .
>> .
>> .
>> .
>> .
>>
>>
>> done.
>
> i already got this method, but the problem that i have is the
> parameters is mysql statement and it's very long. i don't think a
> good idea to pass this in the url. also, the page that i'm working
> on is a search page, therefore the mysql statement is very
> complicate and long. that's why i don't want to pass via url.
>
> is there way to do within this page???

I have actually done what you are looking for... Here is how I do it:

On the search page, write the search phrase into a session variable so
you can access it from another page and then run this code:

<?PHP

$sortOrder = $_SESSION['order'];
$search = $_SESSION['search'];
$select = "SELECT * FROM ".$table." WHERE blah blah blah blah blah"";

$export = mysql_query($select);
$fields = mysql_num_fields($export);

for ($i = 0; $i < $fields; $i++) {
        $header .= mysql_field_name($export, $i) . "\t";
}

while($row = mysql_fetch_row($export)) {
        $line = '';
        foreach($row as $value) {
                if ((!isset($value)) or ($value == "")) {
                        $value = "\t";
                }
                else
                {
                        $value = str_replace('"', '""', $value);
                        $value = '"' . $value . '"' . "\t";
                }
                $line .= $value;
        }
        $data .= trim($line). "\n";
}
$data = str_replace("\r", "", $data);

if ($data =="") {
        $data ="\n(0) Records Found!\n";
}
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=Export.xls");
header("Pragma: no-cache");
header("Expires: 0");

print "$header\n$data";

?>

What that does is it writes the current search pattern into an excel
file called Export.xls and downloads it to your harddrive. I am in the
process of re-writing it to work as a function, but have had mixed
results so far. I'm learning functions right now :)

If you know functions, and want to take a stab at re-writing it, I can
provide you with the code I have so far :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruimraoset.com

attached mail follows:


On Feb 8, 2008 10:14 AM, Hiep Nguyen <hiepee.ucr.edu> wrote:
>
> On Fri, 8 Feb 2008, Per Jessen wrote:
>
> > Hiep Nguyen wrote:
> >
> >> is there anyway to generate this into xls file w/o using fopen &
> >> fwrite to the server? my goal is to have a link after the table and
> >> user can click on that link and a save window pop up to allow user to
> >> save to local disk.
> >
> > Yes - have a link like this:
> >
> > <a href="<yourscript.php?parameters>">Get XLS file</a>
> >
> > in yourscript.php, you evaluate the parameters given and build the XSL
> > file as output:
> >
> > header("Content-Type: application/excel");
> > header("Content-Disposition: attachment; filename=\"filename\"");
> >
> > print
> > .
> > .
> > .
> > .
> > .
> >
> >
> > done.
>
> i already got this method, but the problem that i have is the parameters
> is mysql statement and it's very long. i don't think a good idea to pass
> this in the url. also, the page that i'm working on is a search page,
> therefore the mysql statement is very complicate and long. that's why i
> don't want to pass via url.
>
> is there way to do within this page???
>
> t. hiep
>
>

How are you passing the parameters to THIS page? The solution Per
presented would either require the same parameter list as the current
page (if going to a URL dedicated to sending the output in the format
you are using for the xls) or one additional parameter to the current
page if you the current page is written to vary the style of the
output based on that parameter's value.

Andrew

attached mail follows:


On Fri, 8 Feb 2008, Jason Pruim wrote:

>
> On Feb 8, 2008, at 10:14 AM, Hiep Nguyen wrote:
>
>>
>> On Fri, 8 Feb 2008, Per Jessen wrote:
>>
>>> Hiep Nguyen wrote:
>>>
>>>> is there anyway to generate this into xls file w/o using fopen &
>>>> fwrite to the server? my goal is to have a link after the table and
>>>> user can click on that link and a save window pop up to allow user to
>>>> save to local disk.
>>>
>>> Yes - have a link like this:
>>>
>>> <a href="<yourscript.php?parameters>">Get XLS file</a>
>>>
>>> in yourscript.php, you evaluate the parameters given and build the XSL
>>> file as output:
>>>
>>> header("Content-Type: application/excel");
>>> header("Content-Disposition: attachment; filename=\"filename\"");
>>>
>>> print
>>> .
>>> .
>>> .
>>> .
>>> .
>>>
>>>
>>> done.
>>
>> i already got this method, but the problem that i have is the parameters is
>> mysql statement and it's very long. i don't think a good idea to pass this
>> in the url. also, the page that i'm working on is a search page, therefore
>> the mysql statement is very complicate and long. that's why i don't want
>> to pass via url.
>>
>> is there way to do within this page???
>
>
> I have actually done what you are looking for... Here is how I do it:
>
> On the search page, write the search phrase into a session variable so you
> can access it from another page and then run this code:
>
> <?PHP
>
> $sortOrder = $_SESSION['order'];
> $search = $_SESSION['search'];
> $select = "SELECT * FROM ".$table." WHERE blah blah blah blah blah"";
>
> $export = mysql_query($select);
> $fields = mysql_num_fields($export);
>
> for ($i = 0; $i < $fields; $i++) {
> $header .= mysql_field_name($export, $i) . "\t";
> }
>
> while($row = mysql_fetch_row($export)) {
> $line = '';
> foreach($row as $value) {
> if ((!isset($value)) or ($value == "")) {
> $value = "\t";
> }
> else
> {
> $value = str_replace('"', '""', $value);
> $value = '"' . $value . '"' . "\t";
> } $line .= $value;
> }
> $data .= trim($line). "\n";
> }
> $data = str_replace("\r", "", $data);
>
> if ($data =="") {
> $data ="\n(0) Records Found!\n";
> }
> header("Content-type: application/x-msdownload");
> header("Content-Disposition: attachment; filename=Export.xls");
> header("Pragma: no-cache");
> header("Expires: 0");
>
>
> print "$header\n$data";
>
>
> ?>
>
> What that does is it writes the current search pattern into an excel file
> called Export.xls and downloads it to your harddrive. I am in the process of
> re-writing it to work as a function, but have had mixed results so far. I'm
> learning functions right now :)
>
> If you know functions, and want to take a stab at re-writing it, I can
> provide you with the code I have so far :)
>
>
thank you for the suggestion, but here is another problem that i try to
avoid saving mysql statement to query from the table again.

let say that user searched and found 10 records,
in the meantime, other users may change any of these 10 records,
so if we saved mysql statement and re-run mysql statement again, the
result might be different. to prevent this problem, i only want to
download records that returned on this page only.

thanks,
t. hiep

attached mail follows:


Hiep Nguyen wrote:

> let say that user searched and found 10 records,
> in the meantime, other users may change any of these 10 records,
> so if we saved mysql statement and re-run mysql statement again, the
> result might be different. to prevent this problem, i only want to
> download records that returned on this page only.

This is more of a caching issue - then you determine how long you want
to keep the results for, and only re-run the mysql query when the
results have gone stale.

/Per Jessen, Zürich

attached mail follows:


Hi gang:

 From a variable with the name of $this_variable -- how do I get a
string 'this_variable' ?

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


On Feb 8, 2008 10:14 AM, tedd <teddsperling.com> wrote:
> Hi gang:
>
> From a variable with the name of $this_variable -- how do I get a
> string 'this_variable' ?
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

There really isn't a way to do this. Maybe you could do some
get_defined_vars hackery, but that really isn't practical.

attached mail follows:


On Feb 8, 2008, at 10:14 AM, tedd wrote:

> Hi gang:
>
> From a variable with the name of $this_variable -- how do I get a
> string 'this_variable' ?

Hey tedd,

What is the end result you want? for debugging and checking variable
contents, I've simply: echo "this_variable = $this_variable";

But that was just for debugging, in a large environment, it could be
quite tedious to type all that out...

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruimraoset.com

attached mail follows:


On Feb 8, 2008 10:25 AM, Jason Pruim <japruimraoset.com> wrote:
>
> On Feb 8, 2008, at 10:14 AM, tedd wrote:
>
> > Hi gang:
> >
> > From a variable with the name of $this_variable -- how do I get a
> > string 'this_variable' ?
>
>
> Hey tedd,
>
> What is the end result you want? for debugging and checking variable
> contents, I've simply: echo "this_variable = $this_variable";
>
> But that was just for debugging, in a large environment, it could be
> quite tedious to type all that out...

    What Tedd means is this: ;-P

<?
function vname(&$var,$scope=false,$prefix='unique',$suffix='value') {
    if($scope) {
        $vals = $scope;
    } else {
        $vals = $GLOBALS;
    }
    $old = $var;
    $var = $new = $prefix.rand().$suffix;
    $vname = FALSE;
    foreach($vals as $p => $v) {
        if($v === $new) {
            $vname = $p;
        }
    }
    $var = $old;
    return $vname;
}
?>

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


tedd wrote:
> Hi gang:
>
> From a variable with the name of $this_variable -- how do I get a
> string 'this_variable' ?
>
> Cheers,
>
> tedd
At some point or the other you will have to define $this_variable as
$this_variable, so at that point you will have access to the string
'this_variable'. Even if you define it using variable vairables or
within or for each loop (e.g. get_definied_vars, $_POST) you will have
an oppertunity to get the 'this_variable' string.

????

Ade

attached mail follows:


On Fri, February 8, 2008 9:14 am, tedd wrote:
> From a variable with the name of $this_variable -- how do I get a
> string 'this_variable' ?

You don't...

Consider this:

function foo($bar){
  //what would your function output?
}

$baz = 3;
foo($baz);

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On 2/8/08, Richard Lynch <ceol-i-e.com> wrote:
>
> On Fri, February 8, 2008 9:14 am, tedd wrote:
> > From a variable with the name of $this_variable -- how do I get a
> > string 'this_variable' ?
>
> You don't...
>
> Consider this:
>
> function foo($bar){
> //what would your function output?
> }
>
> $baz = 3;
> foo($baz);
>
> --

If you dynamically created the variable:

${ 'something' . '_' . 'somethingElse' };

then you'd have access to it via the variable name parts.

David

attached mail follows:


On Feb 8, 2008 1:53 PM, David Giragosian <dgiragosiangmail.com> wrote:
> On 2/8/08, Richard Lynch <ceol-i-e.com> wrote:
> >
> > On Fri, February 8, 2008 9:14 am, tedd wrote:
> > > From a variable with the name of $this_variable -- how do I get a
> > > string 'this_variable' ?
> >
> > You don't...
> >
> > Consider this:
> >
> > function foo($bar){
> > //what would your function output?
> > }
> >
> > $baz = 3;
> > foo($baz);
> >
> > --
>
>
> If you dynamically created the variable:
>
> ${ 'something' . '_' . 'somethingElse' };
>
> then you'd have access to it via the variable name parts.
>
> David
>

That is ridiculous.

attached mail follows:


On Feb 8, 2008 2:18 PM, Eric Butera <eric.buteragmail.com> wrote:
> That is ridiculous.

    And look who chimes in with some helpful advice! ;-P

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


On Fri, 2008-02-08 at 14:37 -0500, Daniel Brown wrote:
> On Feb 8, 2008 2:18 PM, Eric Butera <eric.buteragmail.com> wrote:
> And look who chimes in with some helpful advice! ;-P
>

lol

(now isn't that even more useless?)

--Paul

All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm

attached mail follows:


On Feb 8, 2008 2:41 PM, Paul Scott <pscottuwc.ac.za> wrote:
>
> On Fri, 2008-02-08 at 14:37 -0500, Daniel Brown wrote:
> > On Feb 8, 2008 2:18 PM, Eric Butera <eric.buteragmail.com> wrote:
> > And look who chimes in with some helpful advice! ;-P
> >
>
> lol
>
> (now isn't that even more useless?)

    That's why I threw the ;-P at the end. Not only to indicate that
I was playing around, but also because it held double meaning (in
words and action).

    TFGIF, brother!

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


On Feb 8, 2008, at 2:41 PM, Paul Scott wrote:

>
> On Fri, 2008-02-08 at 14:37 -0500, Daniel Brown wrote:
>> On Feb 8, 2008 2:18 PM, Eric Butera <eric.buteragmail.com> wrote:
>> And look who chimes in with some helpful advice! ;-P
>>
>
> lol
>
> (now isn't that even more useless?)

Not worse then this... :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruimraoset.com

attached mail follows:


On 2/8/08, Eric Butera <eric.buteragmail.com> wrote:
>
> On Feb 8, 2008 1:53 PM, David Giragosian <dgiragosiangmail.com> wrote:
> > On 2/8/08, Richard Lynch <ceol-i-e.com> wrote:
> > >
> > > On Fri, February 8, 2008 9:14 am, tedd wrote:
> > > > From a variable with the name of $this_variable -- how do I get a
> > > > string 'this_variable' ?
> > >
> > > You don't...
> > >
> > > Consider this:
> > >
> > > function foo($bar){
> > > //what would your function output?
> > > }
> > >
> > > $baz = 3;
> > > foo($baz);
> > >
> > > --
> >
> >
> > If you dynamically created the variable:
> >
> > ${ 'something' . '_' . 'somethingElse' };
> >
> > then you'd have access to it via the variable name parts.
> >
> > David
> >
>
> That is ridiculous.
>

This is what I meant, as was posted just yesterday by someone (Jim Lucas?)

for ( $i = 0 ; $i < 20 ; $i++ )
{

        $theVariableAsString = 'something_' . $i;

         ${ 'something' . '_' . $i } = "Assign something here";

}

String value available here -> $theVariableAsString.

I have no idea why tedd wants to have the string value of the variable nor
how he will use it.

David

attached mail follows:


On Feb 8, 2008 2:45 PM, David Giragosian <dgiragosiangmail.com> wrote:
> On 2/8/08, Eric Butera <eric.buteragmail.com> wrote:

    Did you see the function that I published in this thread this
morning? I'm nearly positive that's what he's looking for, and it
worked for me.

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


Is it possible to read each line of data from a file?

I have a text file that has several lines on it. I only want to display the
first line only.

The
file I have
looks like this.

But outputs:

"The file I have looks like this."

Here is my code:

<?php

$dir = "path/to/files/";

// set pattern
$pattern = ".txt*|.TXT*";

// open directory and parse file list
if (is_dir($dir))
{
if ($dh = opendir($dir))
{

echo "<div class=\"spstory\" style=\"font-family: Times New Roman, Times,
serif; font-size: 12px; width: 290px;\">
    <div style=\"width: 285px; background-color: #FFFFCC; padding: 3px;\">
        <span class=\"NormalHeadRed\">Breaking News</span>
        <br />Please check here often for breaking news stories.
    </div>
    <p />
    <span class=\"NomalText\">
    <ul>";

// iterate over file list
while (($filename = readdir($dh)) !== false)
{
// if filename matches search pattern, print it
if (ereg($pattern, $filename))
   if(strpos($filename,'.')>0)
   
// if ($filename = str_replace('.html','',$filename))

{
$fh = fopen($dir . $filename, 'r');
$filehead = fread($fh, 72);
fclose($fh);
echo "<li class=\"bn_bullet\"><a
href=\"/breaking_news/$filename\">".$filehead."</a></li>";
}
}
echo "</ul><p />
        </span>
    </div>";

// close directory
closedir($dh);
}
}

?>

attached mail follows:


2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt írta:
> Is it possible to read each line of data from a file?
>
> I have a text file that has several lines on it. I only want to display the
> first line only.
>
> The
> file I have
> looks like this.
>
> But outputs:
>
> "The file I have looks like this."

you need nl2br()
http://hu.php.net/nl2br

greets
Zoltán Németh

>
> Here is my code:
>
> <?php
>
>
>
> $dir = "path/to/files/";
>
> // set pattern
> $pattern = ".txt*|.TXT*";
>
> // open directory and parse file list
> if (is_dir($dir))
> {
> if ($dh = opendir($dir))
> {
>
> echo "<div class=\"spstory\" style=\"font-family: Times New Roman, Times,
> serif; font-size: 12px; width: 290px;\">
> <div style=\"width: 285px; background-color: #FFFFCC; padding: 3px;\">
> <span class=\"NormalHeadRed\">Breaking News</span>
> <br />Please check here often for breaking news stories.
> </div>
> <p />
> <span class=\"NomalText\">
> <ul>";
>
> // iterate over file list
> while (($filename = readdir($dh)) !== false)
> {
> // if filename matches search pattern, print it
> if (ereg($pattern, $filename))
> if(strpos($filename,'.')>0)
>
> // if ($filename = str_replace('.html','',$filename))
>
> {
> $fh = fopen($dir . $filename, 'r');
> $filehead = fread($fh, 72);
> fclose($fh);
> echo "<li class=\"bn_bullet\"><a
> href=\"/breaking_news/$filename\">".$filehead."</a></li>";
> }
> }
> echo "</ul><p />
> </span>
> </div>";
>
> // close directory
> closedir($dh);
> }
> }
>
> ?>
>

attached mail follows:


I think I may have written the question wrong. I only want to display the
first line. It is a news story with a headline. I only want to display the
headline in the link.

The output I want is:

The

But I am getting:

The file looks like this.

Does that make more sense?

Thanks,

--
Steve M.

on 2/8/08 11:03 AM Zoltán Németh (znemethalterationx.hu) wrote:

> 2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt írta:
>> > Is it possible to read each line of data from a file?
>> >
>> > I have a text file that has several lines on it. I only want to display the
>> > first line only.
>> >
>> > The
>> > file I have
>> > looks like this.
>> >
>> > But outputs:
>> >
>> > "The file I have looks like this."
>
> you need nl2br()
> http://hu.php.net/nl2br
>
> greets
> Zoltán Németh
>
>> >
>> > Here is my code:
>> >
>> > <?php
>> >
>> >
>> >
>> > $dir = "path/to/files/";
>> >
>> > // set pattern
>> > $pattern = ".txt*|.TXT*";
>> >
>> > // open directory and parse file list
>> > if (is_dir($dir))
>> > {
>> > if ($dh = opendir($dir))
>> > {
>> >
>> > echo "<div class=\"spstory\" style=\"font-family: Times New Roman, Times,
>> > serif; font-size: 12px; width: 290px;\">
>> > <div style=\"width: 285px; background-color: #FFFFCC; padding: 3px;\">
>> > <span class=\"NormalHeadRed\">Breaking News</span>
>> > <br />Please check here often for breaking news stories.
>> > </div>
>> > <p />
>> > <span class=\"NomalText\">
>> > <ul>";
>> >
>> > // iterate over file list
>> > while (($filename = readdir($dh)) !== false)
>> > {
>> > // if filename matches search pattern, print it
>> > if (ereg($pattern, $filename))
>> > if(strpos($filename,'.')>0)
>> >
>> > // if ($filename = str_replace('.html','',$filename))
>> >
>> > {
>> > $fh = fopen($dir . $filename, 'r');
>> > $filehead = fread($fh, 72);
>> > fclose($fh);
>> > echo "<li class=\"bn_bullet\"><a
>> > href=\"/breaking_news/$filename\">".$filehead."</a></li>";
>> > }
>> > }
>> > echo "</ul><p />
>> > </span>
>> > </div>";
>> >
>> > // close directory
>> > closedir($dh);
>> > }
>> > }
>> >
>> > ?>
>> >
>

attached mail follows:


On Feb 8, 2008 12:11 PM, Pastor Steve <smarquezccfortsmith.com> wrote:
> I think I may have written the question wrong. I only want to display the
> first line. It is a news story with a headline. I only want to display the
> headline in the link.
>
> The output I want is:
>
> The
>
> But I am getting:
>
> The file looks like this.
>
> Does that make more sense?

<?
$handle = fopen($filename);
$data = fgets($handle);
echo $data."\n";
?>

    So long as you don't do a while() loop or something similar,
fgets() will only read the first line.

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


2008. 02. 8, péntek keltezéssel 11.11-kor Pastor Steve ezt írta:
> I think I may have written the question wrong. I only want to display
> the first line. It is a news story with a headline. I only want to
> display the headline in the link.
>
> The output I want is:
>
> The
>
> But I am getting:
>
> The file looks like this.
>
> Does that make more sense?

in that case why not read the file as an array of lines and display the
first line?
$f = file('whatever.txt');
echo $f[0];

http://hu.php.net/file

greets
Zoltán Németh

>
> Thanks,
>
> --
> Steve M.
>
> on 2/8/08 11:03 AM Zoltán Németh (znemethalterationx.hu) wrote:
>
> 2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt
> írta:
> > Is it possible to read each line of data from a file?
> >
> > I have a text file that has several lines on it. I only want
> to display the
> > first line only.
> >
> > The
> > file I have
> > looks like this.
> >
> > But outputs:
> >
> > "The file I have looks like this."
>
> you need nl2br()
> http://hu.php.net/nl2br
>
> greets
> Zoltán Németh
>
> >
> > Here is my code:
> >
> > <?php
> >
> >
> >
> > $dir = "path/to/files/";
> >
> > // set pattern
> > $pattern = ".txt*|.TXT*";
> >
> > // open directory and parse file list
> > if (is_dir($dir))
> > {
> > if ($dh = opendir($dir))
> > {
> >
> > echo "<div class=\"spstory\" style=\"font-family: Times New
> Roman, Times,
> > serif; font-size: 12px; width: 290px;\">
> > <div style=\"width: 285px; background-color: #FFFFCC;
> padding: 3px;\">
> > <span class=\"NormalHeadRed\">Breaking News</span>
> > <br />Please check here often for breaking news
> stories.
> > </div>
> > <p />
> > <span class=\"NomalText\">
> > <ul>";
> >
> > // iterate over file list
> > while (($filename = readdir($dh)) !== false)
> > {
> > // if filename matches search pattern, print it
> > if (ereg($pattern, $filename))
> > if(strpos($filename,'.')>0)
> >
> > // if ($filename = str_replace('.html','',$filename))
> >
> > {
> > $fh = fopen($dir . $filename, 'r');
> > $filehead = fread($fh, 72);
> > fclose($fh);
> > echo "<li class=\"bn_bullet\"><a
> > href=\"/breaking_news/$filename\">".$filehead."</a></li>";
> > }
> > }
> > echo "</ul><p />
> > </span>
> > </div>";
> >
> > // close directory
> > closedir($dh);
> > }
> > }
> >
> > ?>
> >
>
>

attached mail follows:


2008. 02. 8, péntek keltezéssel 12.17-kor Daniel Brown ezt írta:
> On Feb 8, 2008 12:11 PM, Pastor Steve <smarquezccfortsmith.com> wrote:
> > I think I may have written the question wrong. I only want to display the
> > first line. It is a news story with a headline. I only want to display the
> > headline in the link.
> >
> > The output I want is:
> >
> > The
> >
> > But I am getting:
> >
> > The file looks like this.
> >
> > Does that make more sense?
>
> <?
> $handle = fopen($filename);
> $data = fgets($handle);
> echo $data."\n";
> ?>
>
> So long as you don't do a while() loop or something similar,
> fgets() will only read the first line.

sure, and much more efficient than my last letter, so ignore that...
its friday, and late, and I'm still at work, so my mind is not on the
top now... :)

greets
Zoltán Németh

>

attached mail follows:


On Feb 8, 2008 12:19 PM, Zoltán Németh <znemethalterationx.hu> wrote:
> 2008. 02. 8, péntek keltezéssel 12.17-kor Daniel Brown ezt írta:
> > On Feb 8, 2008 12:11 PM, Pastor Steve <smarquezccfortsmith.com> wrote:
> > > I think I may have written the question wrong. I only want to display the
> > > first line. It is a news story with a headline. I only want to display the
> > > headline in the link.
> > >
> > > The output I want is:
> > >
> > > The
> > >
> > > But I am getting:
> > >
> > > The file looks like this.
> > >
> > > Does that make more sense?
> >
> > <?
> > $handle = fopen($filename);
> > $data = fgets($handle);
> > echo $data."\n";
> > ?>
> >
> > So long as you don't do a while() loop or something similar,
> > fgets() will only read the first line.
>
> sure, and much more efficient than my last letter, so ignore that...
> its friday, and late, and I'm still at work, so my mind is not on the
> top now... :)

    Zoltan, if you're sticking around, zip me a message off-list. I
have a favor to ask of you.

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


--- Daniel Brown <parasanegmail.com> wrote:

> On Feb 8, 2008 12:11 PM, Pastor Steve <smarquezccfortsmith.com>
> wrote:
> > I think I may have written the question wrong. I only want to
> display the
> > first line. It is a news story with a headline. I only want to
> display the
> > headline in the link.
> >
> > The output I want is:
> >
> > The
> >
> > But I am getting:
> >
> > The file looks like this.
> >
> > Does that make more sense?
>
> <?
> $handle = fopen($filename);
> $data = fgets($handle);
> echo $data."\n";
> ?>
>
> So long as you don't do a while() loop or something similar,
> fgets() will only read the first line.
>
> --
> </Dan>
>
> Daniel P. Brown
> Senior Unix Geek
> <? while(1) { $me = $mind--; sleep(86400); } ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Another method....
 <?
 $data = file($filename);
 echo $data[0]."\n";
 ?>

---
Nirmalya Lahiri
[+91-9433113536]

      ____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

attached mail follows:


The first possible issue is that the "newline" character[s] is
different for Mac, Windows, and Linux...

So if your file is one format, and fgets is expecting the other, it
won't do what you want.

The next is that if your code is wrong, and is showing it all as one
line, it PROBABLY means you are using a browser, and you PROBABLY
aren't using nl2br to change the newlines (assuming again that nl2br
looks for the right OS newline). Another option is "View Source" in
the browser to see the newlines.

On Fri, February 8, 2008 11:11 am, Pastor Steve wrote:
> I think I may have written the question wrong. I only want to display
> the
> first line. It is a news story with a headline. I only want to display
> the
> headline in the link.
>
> The output I want is:
>
> The
>
> But I am getting:
>
> The file looks like this.
>
> Does that make more sense?
>
> Thanks,
>
> --
> Steve M.
>
> on 2/8/08 11:03 AM Zoltán Németh (znemethalterationx.hu) wrote:
>
>> 2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt írta:
>>> > Is it possible to read each line of data from a file?
>>> >
>>> > I have a text file that has several lines on it. I only want to
>>> display the
>>> > first line only.
>>> >
>>> > The
>>> > file I have
>>> > looks like this.
>>> >
>>> > But outputs:
>>> >
>>> > "The file I have looks like this."
>>
>> you need nl2br()
>> http://hu.php.net/nl2br
>>
>> greets
>> Zoltán Németh
>>
>>> >
>>> > Here is my code:
>>> >
>>> > <?php
>>> >
>>> >
>>> >
>>> > $dir = "path/to/files/";
>>> >
>>> > // set pattern
>>> > $pattern = ".txt*|.TXT*";
>>> >
>>> > // open directory and parse file list
>>> > if (is_dir($dir))
>>> > {
>>> > if ($dh = opendir($dir))
>>> > {
>>> >
>>> > echo "<div class=\"spstory\" style=\"font-family: Times New
>>> Roman, Times,
>>> > serif; font-size: 12px; width: 290px;\">
>>> > <div style=\"width: 285px; background-color: #FFFFCC;
>>> padding: 3px;\">
>>> > <span class=\"NormalHeadRed\">Breaking News</span>
>>> > <br />Please check here often for breaking news stories.
>>> > </div>
>>> > <p />
>>> > <span class=\"NomalText\">
>>> > <ul>";
>>> >
>>> > // iterate over file list
>>> > while (($filename = readdir($dh)) !== false)
>>> > {
>>> > // if filename matches search pattern, print it
>>> > if (ereg($pattern, $filename))
>>> > if(strpos($filename,'.')>0)
>>> >
>>> > // if ($filename = str_replace('.html','',$filename))
>>> >
>>> > {
>>> > $fh = fopen($dir . $filename, 'r');
>>> > $filehead = fread($fh, 72);
>>> > fclose($fh);
>>> > echo "<li class=\"bn_bullet\"><a
>>> > href=\"/breaking_news/$filename\">".$filehead."</a></li>";
>>> > }
>>> > }
>>> > echo "</ul><p />
>>> > </span>
>>> > </div>";
>>> >
>>> > // close directory
>>> > closedir($dh);
>>> > }
>>> > }
>>> >
>>> > ?>
>>> >
>>
>
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Feb 8, 2008 12:35 PM, Richard Lynch <ceol-i-e.com> wrote:

    I knew it. After silence, Lynch comes back with a vengeance
three hours before the week's stats come out.

    And not only that.... he top-posts. ;-P

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


2008. 02. 8, péntek keltezéssel 12.46-kor Daniel Brown ezt írta:
> On Feb 8, 2008 12:35 PM, Richard Lynch <ceol-i-e.com> wrote:
>
> I knew it. After silence, Lynch comes back with a vengeance
> three hours before the week's stats come out.
>
> And not only that.... he top-posts. ;-P

Wait, this might not be the real Lynch, but his new AI instead, not
programmed yet for bottom posting :)

greets
Zoltán Németh

>
> --
> </Dan>
>
> Daniel P. Brown
> Senior Unix Geek
> <? while(1) { $me = $mind--; sleep(86400); } ?>
>

attached mail follows:


On Thu, February 7, 2008 1:49 pm, MaryAnn Woodall wrote:
> Just starting to use php on my webpages. If I save a file as .php
> or .php4 are they the same file. For example is index.php the same as
> index.php4?

They are not the same file at all, unless you use really old Windows
that only let you have 3 characters in the extension, or some other
program is converting to the 8.3 filename...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


MaryAnn Woodall wrote:

> Just starting to use php on my webpages. If I save a file as .php
> or .php4 are they the same file. For example is index.php the same as
> index.php4?

If you save the same file with two different names, the contents will
remain the same. How the different extensions are interpreted at
runtime will depend on your browser config.

/Per Jessen, Zürich

attached mail follows:


On Thu, February 7, 2008 12:30 pm, Steve Marquez wrote:
> Greetings,
>
> Could someone please point me in the right direction? I am trying to
> have
> PHP find out if a directory has files in it and then if it does,
> display and
> include, if it does not, then not display the include.
>
> I have looked at the Manual and did not really know where to look.

http://php.net/opendir
http://php.net/readdir
<?php
  $dir = opendir("/full/path/to/the/dir/please") or die("No such dir.");
  while (($f = readdir($dir)) !== false){
    echo "$f<br />";
    include $f;
  }
?>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Thu, February 7, 2008 9:51 am, Eric Butera wrote:
> On Feb 7, 2008 9:59 AM, Nathan Nobbe <quickshiftingmail.com> wrote:
>> On Feb 7, 2008 9:24 AM, Eric Butera <eric.buteragmail.com> wrote:
>>
> If you look at plugin architectures of projects such as drupal,
> phorum, or serendipity you can see there are better ways of doing
> things rather than messing up the source code. I recently found

In zenCart, you are supposed to put your modified file[s] into a
different include dir, and keep the original source pristine.

It worked pretty well for me.

The biggest problem I had was that the payment gateway had a "test"
checkbox that was supposed to do something different in the code, but
it didn't, so I ended up hacking that directly anyway -- it was too
broken to worry about not messing it up... :-v

I can't say I've ever liked any of the full-blown shopping cart apps
out there...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


You probably do not have GD installed...

Does <?php phpinfo();?> list "GD" as one of your extensions?

If not, install it.

On Thu, February 7, 2008 6:57 am, Legolas wood wrote:
> Hi
> Thank you for reading my post
> I am trying to run a php based application using php5 and apache.
> but I receive an error like:
>
>
> *Fatal error*: Call to undefined function imagefontwidth() in
> */var/www/v603/includes/functions.php* on line *28*
>
>
> when line 28 and its surrounding lines are:
>
> ## create an image not a text for the pin
>
> $font = 6;
>
> $width = imagefontwidth($font) * strlen($generated_pin);
>
> $height = ImageFontHeight($font);
>
>
>
> $im = imagecreate ($width,$height);
>
> $background_color = imagecolorallocate ($im, 219, 239, 249);
> //cell background
>
> $text_color = imagecolorallocate ($im, 0, 0,0);//text color
>
> imagestring ($im, $font, 0, 0, $generated_pin, $text_color);
>
> touch($image_url . 'uplimg/site_pin_' . $full_pin . '.jpg');
>
> imagejpeg($im, $image_url . 'uplimg/site_pin_' . $full_pin .
> '.jpg');
>
>
>
> $image_output = '<img src="' . $image_url . 'uplimg/site_pin_' .
> $full_pin . '.jpg">';
>
>
>
> imagedestroy($im);
>
>
>
> return $image_output;
>
>
>
> Can you tell me what is wrong with this code and how I can resolve the
> problem.
>
> Thanks
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Thursday 07 February 2008 17:17:30 David Giragosian wrote:
> On 2/7/08, Daniel Brown <parasanegmail.com> wrote:
> > On Feb 7, 2008 8:23 AM, Jochem Maas <jochemiamjochem.com> wrote:
> > > Legolas wood schreef:
> > > > Hi
> > > > Thank you for reading my post
> > > > I am trying to run a php based application using php5 and apache.
> > > > but I receive an error like:
> > > >
> > > >
> > > > *Fatal error*: Call to undefined function imagefontwidth() in
> >
> > */var/www/v603/includes/functions.php* on line *28*
> >
> > > mostly likely you'll have to ask your sys admin to install/activate
> > > this extension ... and if you have cheaphosting then likely the answer
> > > will
> >
> > be
> >
> > > "no we don't do that" - in which case find other hosting?
> >
> > <plug shame="false" />
> > PilotPig has GD, ImageMagick, and all kinds of other things
> > already installed, and will install any server software (when
> > reasonable) upon request at no charge. Check it out:
> > http://www.pilotpig.net/
> > </plug>
> >
> > ;-P
> >
> > --
> > </Dan>