Re: [PHP] PHP and Ajax?

2005-04-29 Thread Hidayet Dogan
Try SAJAX at http://www.modernmethod.com/sajax

 Hidayet Dogan
  [EMAIL PROTECTED]

Pleksus Bilisim Teknolojileri D.T.O. A.S.
--
caldiran sok. 14/6 06420 kolej ankara * www.pleksus.com.tr
tel : +90 312 4355343 * faks: +90 312 4354006

On Thu, 28 Apr 2005, Jeremiah Johnson wrote:

 Does anyone have any references on using PHP and Ajax? I caught the
 news on PHP Architect about the webcast they are doing in May and it
 sounds like an interesting technology, but I can't wait, of course
 :)... and I wanted to learn as much as I could before their
 presentation.

 Any pointers?


 Thanks!

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passing a variable through 2 required files embedded in Javascript

2005-04-29 Thread Petar Nedyalkov
On Friday 29 April 2005 07:08, Mark Cain wrote:
 What a mess this has turned out to be -- But perhaps you can help me.

 I have a dynamic site that pulls headers, navigation, and footers from text
 files.  The content for the pages is pulled from mySQL.

 On each page I have a JavaScript rotating banner that displays Upcoming
 Events.  The banners rotate about every 4 seconds without the need for a
 page refresh.  The names of the individual banners themselves are fed into
 JavaScript from a PHP script that reads a folder of JPG files and makes a
 decision as to which ones to show (i.e. pass to the JavaScript).

 This all works and it's slick seeing that I have the difficulty of dealing
 with a server side script and a client script.  The browser calls a
 JavaScript file which has a php extension.  When the server sees the php
 extension the file is executed before it is delivered to the browser. 
 Since JavaScript complains about PHP functions in that file that file
 merely echo back standard JavaScript and calls another php file via
 require() that does the low level work of reading the folder and reporting
 back the JavaScript arrays.  Graphically it looks like this:

 1) the Page calls the header
  2) the header calls
3) a php generated JavaScript file which calls
 4) a php file that reads the folder on the server and
 builds the JavaScript arrays


 Now I need to add a feature and I am bumping my head on this one.

 How do I report the file name of the file that called the header in # 4 ? 
 In other words, I want the name of #1 to be reported in #4.  If I use
 $_SERVER[PHP_SELF], that variable reports the name of #4.  It gets a
 little tricky because #3 is called from within a JavaScript tag.

 Got any suggestions?

Pass the JavaScript to the client using a new header:

Content-Type: application/x-javascript


 Mark Cain

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436


pgpZ4iSMVJTIh.pgp
Description: PGP signature


[PHP] mail problem

2005-04-29 Thread Ross
I get the following mail problem when trying to send from localhost. Any 
ideas?


Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to 
relay for [EMAIL PROTECTED] in c:\Inetpub\wwwroot\ssn\adv_mail.php on line 
179


R. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Clive Zagno
Wait -  doesn't smarty 'compile' the php file and the tpl file into 
another php file. If you look into templates_c directory you find some 
'compiled' templates.

clive
Robert Cummings wrote:
On Thu, 2005-04-28 at 13:20, Ryan A wrote:
On 4/28/2005 7:08:00 PM, Evert | Rooftop Solutions
([EMAIL PROTECTED]) wrote:
Ryan A wrote:
So just because you use smarty you think you are smart and have the right
to be smart..who the hell do you think you are??

Sorry, just giving an example of how a jackass with extreme opinions
would write on this holy war's volatile topic. no offense meant
:-)

I would go for a xml-style template engine (start flaming right below
this thread)
Flaming??? who has time to start flaming after reading what you wrote?
am busying banging my head against the wall.

To state the obvious... the above is in actuality a flame disguised as
an excuse.
I use InterJinn, smarty, and PHP as template engines depending on what
the client wants and how much work they want done, and how much
elegance, modularity, and maintainability they want. Of the three I like
smarty the least which is probably why I wrote my own engine :) Oh wait,
I've also used eztemplate which by far takes the cake of horrible
horrible templating. While PHP is itself usable as a templating engine,
it's not what I would call clear and concise when used that way (but
maybe that's because I've come across too many instances where the
previous developer mixed business logic with display logic and then I
had to rework the functionality which was a nightmare :). When using
InterJinn I save the overhead of run-time includes incurred by using PHP
as a templating engine, and I save the overhead of cache checks incurred
by systems like smarty since InterJinn compiles to PHP source code and
does not use a cache (although it can be set to automatically recompile
pages when dependencies change).
At any rate I don't generally post about InterJinn here anymore since
some of the regulars tend to get annoyed ;)
Mind you I don't post much at all anymore since I became a father a year
and a half ago... priorities you know :)
Cheers,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Regular expressions problem

2005-04-29 Thread Khorosh Irani
Hello
I have a question:
What is in the role of space in the regular expressions (POSIX)?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php Full Page Calendar not date picker

2005-04-29 Thread Angelo Zanetti
Hi all.

Im looking for a PHP/Javascript calender that is a full page calender.
IE: for each day there is  quite a big block. Therefore it will be a
bigger form of a date picker. What I want to do is to be able to assign
notes for each day. I've seen the smarty calender which is exactly what
I need but Im not using smarty for this particular project.

thanks in advance.

-- 

Angelo Zanetti
Z Logic
www.zlogic.co.za
[c] +27 72 441 3355
[t] +27 21 469 1052

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP and Ajax?

2005-04-29 Thread Dan Rossi
its using the standard toolkit available in most browsers, what i find 
a pain in the ass is having to build the post data into a string before 
it can be sent, it should do it for u

On 29/04/2005, at 4:40 PM, Hidayet Dogan wrote:
Try SAJAX at http://www.modernmethod.com/sajax
 Hidayet Dogan
  [EMAIL PROTECTED]
Pleksus Bilisim Teknolojileri D.T.O. A.S.
--
caldiran sok. 14/6 06420 kolej ankara * www.pleksus.com.tr
tel : +90 312 4355343 * faks: +90 312 4354006
On Thu, 28 Apr 2005, Jeremiah Johnson wrote:
Does anyone have any references on using PHP and Ajax? I caught the
news on PHP Architect about the webcast they are doing in May and it
sounds like an interesting technology, but I can't wait, of course
:)... and I wanted to learn as much as I could before their
presentation.
Any pointers?
Thanks!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] PHP and Ajax?

2005-04-29 Thread Zac Barton
You should also look at JSON (JavaScript Object Notation - is a lightweight 
data-interchange format)

http://pear.php.net/pepr/pepr-proposal-show.php?id=198

http://mike.teczno.com/json.html

Zac

-Original Message-
From: Hidayet Dogan [mailto:[EMAIL PROTECTED]
Sent: 29 April 2005 07:41
To: Jeremiah Johnson
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP and Ajax?


Try SAJAX at http://www.modernmethod.com/sajax

 Hidayet Dogan
  [EMAIL PROTECTED]

Pleksus Bilisim Teknolojileri D.T.O. A.S.
--
caldiran sok. 14/6 06420 kolej ankara * www.pleksus.com.tr
tel : +90 312 4355343 * faks: +90 312 4354006

On Thu, 28 Apr 2005, Jeremiah Johnson wrote:

 Does anyone have any references on using PHP and Ajax? I caught the
 news on PHP Architect about the webcast they are doing in May and it
 sounds like an interesting technology, but I can't wait, of course
 :)... and I wanted to learn as much as I could before their
 presentation.

 Any pointers?


 Thanks!

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SOLVEDphp Full Page Calendar not date picker

2005-04-29 Thread Angelo Zanetti
Dont worry guys i solved it.

Angelo Zanetti wrote:

Hi all.

Im looking for a PHP/Javascript calender that is a full page calender.
IE: for each day there is  quite a big block. Therefore it will be a
bigger form of a date picker. What I want to do is to be able to assign
notes for each day. I've seen the smarty calender which is exactly what
I need but Im not using smarty for this particular project.

thanks in advance.

  


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SOLVEDphp Full Page Calendar not date picker

2005-04-29 Thread Petar Nedyalkov
On Friday 29 April 2005 11:43, Angelo Zanetti wrote:
 Dont worry guys i solved it.

And if you name the solution, it'll be a perfect finish for this thread.
Remember, this mailing-list is used as a knowledge base from a lot of people.


 Angelo Zanetti wrote:
 Hi all.
 
 Im looking for a PHP/Javascript calender that is a full page calender.
 IE: for each day there is  quite a big block. Therefore it will be a
 bigger form of a date picker. What I want to do is to be able to assign
 notes for each day. I've seen the smarty calender which is exactly what
 I need but Im not using smarty for this particular project.
 
 thanks in advance.

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436


pgppjeQBrd2Dd.pgp
Description: PGP signature


[PHP] Your Opinion

2005-04-29 Thread Sudeep Sarath


Hi everybody,

  I'm planning to buy PHP5  MySQL Bible, the book
written by Tim Converse, Joyce Park  Clark Morgan.
Give me your opinion on this book, if anyone has gone
thru it.

Thanx.


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to know if php CAN write files on server and WHERE it can?

2005-04-29 Thread Giulio
I know, uploading files and handling them is an issue covered again and 
again, but there are still some answers I can'tfind on archives.

Having to read some uploaded files, perform operations on them ( 
basically attach them on a single file ), and then save the resulting 
file using ftp, and trying to have the php page as general as possible 
( I mean have it work on the larger number of server possible and 
without configuration settings ):

1) Could it be possible to have a php or server config that doesn't 
allow at all to write and read files on the server( I'm afraid yes) and 
how can I detect this situation from code, at least to show a this 
script can't run here message?

2) All the upload_and_copy_files_somewhere_else examples relay on a 
destination directory explicitly set in the script. How can i have my 
php discover on its own where it can write and read, no matter the 
position since it is a kind of temporary and working folder, and I'll 
delete all files used when finished?

3) Which security settings ( safe_mode and so on )  should I be aware 
of?

Some good tutorial somewhere?
Thank you so much,
Giulio

Cantoberon Multimedia srl
http://www.cantoberon.it
Tel. 06 39737052
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] SOLVEDphp Full Page Calendar not date picker

2005-04-29 Thread Angelo Zanetti
I got a script from a friend of mine.
Otherwise I would have definitely given the URL...


Petar Nedyalkov wrote:

On Friday 29 April 2005 11:43, Angelo Zanetti wrote:
  

Dont worry guys i solved it.



And if you name the solution, it'll be a perfect finish for this thread.
Remember, this mailing-list is used as a knowledge base from a lot of people.

  

Angelo Zanetti wrote:


Hi all.

Im looking for a PHP/Javascript calender that is a full page calender.
IE: for each day there is  quite a big block. Therefore it will be a
bigger form of a date picker. What I want to do is to be able to assign
notes for each day. I've seen the smarty calender which is exactly what
I need but Im not using smarty for this particular project.

thanks in advance.
  


  



Re: [PHP] PHP and Ajax?

2005-04-29 Thread Dan Rossi
hmm isnt the intention of httprequest is that u can send post data 
without leaving the page ? It has worked for me, except u have to build 
the post data yourself to send. On other similar circumstances i've had 
to post certain data from a post to the current database but also 
executr a script and insert data into another system, i used nusoap for 
this as i wanted the logic to be in the same system not duplicate it. 
The issue is I wouldnt know if posting the form building post array on 
the other reuqest , sending to the other system via httprequest 
returning the insert id, insert post data into current database would 
work.

It looks like u are trying to build the serializes array in the current 
request, i'll do some tests though.

On 29/04/2005, at 6:25 PM, Zac Barton wrote:
You should also look at JSON (JavaScript Object Notation - is a 
lightweight data-interchange format)

http://pear.php.net/pepr/pepr-proposal-show.php?id=198
http://mike.teczno.com/json.html
Zac
-Original Message-
From: Hidayet Dogan [mailto:[EMAIL PROTECTED]
Sent: 29 April 2005 07:41
To: Jeremiah Johnson
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP and Ajax?
Try SAJAX at http://www.modernmethod.com/sajax
 Hidayet Dogan
  [EMAIL PROTECTED]
Pleksus Bilisim Teknolojileri D.T.O. A.S.
--
caldiran sok. 14/6 06420 kolej ankara * www.pleksus.com.tr
tel : +90 312 4355343 * faks: +90 312 4354006
On Thu, 28 Apr 2005, Jeremiah Johnson wrote:
Does anyone have any references on using PHP and Ajax? I caught the
news on PHP Architect about the webcast they are doing in May and it
sounds like an interesting technology, but I can't wait, of course
:)... and I wanted to learn as much as I could before their
presentation.
Any pointers?
Thanks!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Can this code go faster?

2005-04-29 Thread Rolf Østvik
Just a couple of comments about those 0x.. and 11
in my post.
(By the way, i haven't looked to closely on speed even if the OP asked
for that, i was unsure on how he was coding his numbers). 

[EMAIL PROTECTED] (Rolf Østvik) wrote in
news:[EMAIL PROTECTED]: 

 [EMAIL PROTECTED] (René Fournier) wrote in 
 news:[EMAIL PROTECTED]:
 
 I need to convert a binary number of arbitrary length to a signed 
 integer.
 
 If you on the other hand know that the string should represent an 8
 bit in two's complement then this could work:
 
 function bin2int ($bin) {
 $a =  bindec($bin);
 
 $val = ($a | 0x80) ? (0xff00 | $a) : $a;
if the input is a 8 bit signed binary string then bit 7 determine the
sign. 0xff00 will then make this to an 32 signed integer

 
 return $val;
 }
 
 function bin2int ($bin) {
 if (substr($bin,0,1) == 1) {
 // NEGATIVE
 $val = bindec(substr(
   .$bin,-32)); 
bindec returns a 32 bit signed integer, i just make sure that the
leftmost bits in the 32 character long string are 1 if the leftmost bit
in the original string is 1. 
 } else {
 // POSITIVE
 $val = bindec($bin); 
 }
 return $val;
 }
 

-- 
Rolf

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Templating engines

2005-04-29 Thread pete M
Hi clive
I tried all of them and I must admit smarty comes out on top by a mile
I use it on a very busy virtual host and have had NO problems with slow 
script etc, highly recommended http://smarty.php.net

pete
Clive Zagno wrote:
Hi all,
What templating engines do you use with php and why?
Ive been using smarty (http://smarty.php.net)
Clive.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Regular expressions problem

2005-04-29 Thread Matthew Weier O'Phinney
* Khorosh Irani [EMAIL PROTECTED]:
 Hello
 I have a question:
 What is in the role of space in the regular expressions (POSIX)?

To match a space.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Matthew Weier O'Phinney
* Clive Zagno [EMAIL PROTECTED]:
 Wait -  doesn't smarty 'compile' the php file and the tpl file into 
 another php file. If you look into templates_c directory you find some 
 'compiled' templates.

Yes, it does. And your question is...?

If it's about performance, the compilation is not an issue. Compilation
of templates into PHP code happens only when the template file changes;
subsequent requests for the template then use the compiled version. This
actually speeds things up tremendously.

This could be interpreted as, Well, if Smarty just compiles the
templates into PHP anyways, why not use PHP? And the answer is that
Smarty uses a language subset -- it doesn't try to implement all of PHP,
just a number of functions that are useful to template designers (like
some basic logic, some loops, some data formatting for dates,
truncation, etc.); this subset is easier to pick up for many HTML
designers than learning PHP would be.  Additionally, the way Smarty does
tagging means that templates can often be tossed to an X/HTML validator
without the tagging causing breakage.

I'm not going to say Smarty is the best template engine out there for
PHP -- I simply haven't tried enough of them. But I made a decision to
use it and stick with it when I made the decision to start using
templates, and I haven't regretted it.

 Robert Cummings wrote:
 On Thu, 2005-04-28 at 13:20, Ryan A wrote:
 
On 4/28/2005 7:08:00 PM, Evert | Rooftop Solutions
([EMAIL PROTECTED]) wrote:

Ryan A wrote:

So just because you use smarty you think you are smart and have the right

to be smart..who the hell do you think you are??


Sorry, just giving an example of how a jackass with extreme opinions

would write on this holy war's volatile topic. no offense meant

:-)


I would go for a xml-style template engine (start flaming right below
this thread)

Flaming??? who has time to start flaming after reading what you wrote?
am busying banging my head against the wall.
 
 
 To state the obvious... the above is in actuality a flame disguised as
 an excuse.
 
 I use InterJinn, smarty, and PHP as template engines depending on what
 the client wants and how much work they want done, and how much
 elegance, modularity, and maintainability they want. Of the three I like
 smarty the least which is probably why I wrote my own engine :) Oh wait,
 I've also used eztemplate which by far takes the cake of horrible
 horrible templating. While PHP is itself usable as a templating engine,
 it's not what I would call clear and concise when used that way (but
 maybe that's because I've come across too many instances where the
 previous developer mixed business logic with display logic and then I
 had to rework the functionality which was a nightmare :). When using
 InterJinn I save the overhead of run-time includes incurred by using PHP
 as a templating engine, and I save the overhead of cache checks incurred
 by systems like smarty since InterJinn compiles to PHP source code and
 does not use a cache (although it can be set to automatically recompile
 pages when dependencies change).
 
 At any rate I don't generally post about InterJinn here anymore since
 some of the regulars tend to get annoyed ;)
 
 Mind you I don't post much at all anymore since I became a father a year
 and a half ago... priorities you know :)
 
 Cheers,
 Rob.


-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: __autoLoad php5 callback is being triggered for every class ?

2005-04-29 Thread Matthew Weier O'Phinney
* [EMAIL PROTECTED] [EMAIL PROTECTED]:
 I'm experiencing some issues with autoLoad with pear packages. DB_Error is
 contained within the DB.php, but my autoload method is trying to split the
 underscores with forward slashes and then load. Supressing errors with @
 still doesnt work, its triggering a php error. Any ideas ?

Sounds to me like you may need to do a quick call to file_exists()
before trying to load it up. This may involve looping through the
elements in your include_path to build the paths:

// assuming $class = class requested
$file = str_replace('_', '/', $class) . '.php';
$include_path = ini_get('include_path');
$paths = explode(':', $include_path);
$final = '';
foreach ($paths as $path) {
if (file_exists($path/$file)) {
$final = $path/$file;
break;
}
}
if (!empty($final)) {
include_once $final;
}

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] __autoLoad php5 callback is being triggered for every class ?

2005-04-29 Thread Jochem Maas
[EMAIL PROTECTED] wrote:
I'm experiencing some issues with autoLoad with pear packages. DB_Error is
contained within the DB.php, but my autoload method is trying to split the
underscores with forward slashes and then load. Supressing errors with @
still doesnt work, its triggering a php error. Any ideas ?
__autoload() gets called whenever you reference a class that has not been
defined. additionally its called if you call class_exists() and the class 
doesn't
... unless you call class_exists() with the second parameter to false.
if your __autoload() is being called then the class is not loaded
and from what you say its seems your autoload function can't find the relevant
file - whats the function look like?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] __autoLoad php5 callback is being triggered for every class ?

2005-04-29 Thread Dan Rossi
Its DB_Error which is the error callback for the PEAR DB. I dont know 
where its being references but its triggering my php error handler and 
i cant supress the errors for require. There is no such file 
DB/Error.php however i may have to create one just to make it go away 
:)

On 29/04/2005, at 9:32 PM, Jochem Maas wrote:
[EMAIL PROTECTED] wrote:
I'm experiencing some issues with autoLoad with pear packages. 
DB_Error is
contained within the DB.php, but my autoload method is trying to 
split the
underscores with forward slashes and then load. Supressing errors 
with @
still doesnt work, its triggering a php error. Any ideas ?
__autoload() gets called whenever you reference a class that has not 
been
defined. additionally its called if you call class_exists() and the 
class doesn't
... unless you call class_exists() with the second parameter to false.

if your __autoload() is being called then the class is not loaded
and from what you say its seems your autoload function can't find the 
relevant
file - whats the function look like?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] mail problem

2005-04-29 Thread Brent Baisley
It probably means your email server is not setup for open relaying (aka 
spam server). Mail servers should require a login in order to send 
email through them. The mail() function itself doesn't support names 
and passwords, but other php functions do. You might want to look into 
phpmailer to handle you email needs.

Alternatively, you could setup your email server to allow open relaying 
from the localhost. But that's not really recommended even if you know 
exactly what you are doing with the mail server configuration.

On Apr 29, 2005, at 3:27 AM, Ross wrote:
I get the following mail problem when trying to send from localhost. 
Any
ideas?

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 
Unable to
relay for [EMAIL PROTECTED] in c:\Inetpub\wwwroot\ssn\adv_mail.php on 
line
179

R.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Round to the nearest X - SOLVED

2005-04-29 Thread Chris Boget
Thank you for everyone's suggestions.  Using them
(and a few other things I've found elsewhere), I've
come up with the following function:

function roundToNearest( $number, $toNearest = 5 ) {

  $retval = 0;

  $mod = $number % $toNearest;

  if( $mod = 0 ) {
$retval = ( $mod  ( $toNearest / 2 )) ? $number + ( $toNearest - $mod )
: $number - $mod;

  } else {
$retval = ( $mod  ( -$toNearest / 2 )) ? $number - $mod : $number +
( -$toNearest - $mod );

  }
  return $retval;

} // end function round();

that works with positive and negative numbers and seems
to work with every test I threw at it.

Thanks again for everyone's help!

thnx,
Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: __autoLoad php5 callback is being triggered for every class ?

2005-04-29 Thread Jason Barnett
[EMAIL PROTECTED] wrote:
I'm experiencing some issues with autoLoad with pear packages. DB_Error is
contained within the DB.php, but my autoload method is trying to split the
underscores with forward slashes and then load. Supressing errors with @
still doesnt work, its triggering a php error. Any ideas ?
Try loading DB before DB_Error because __autoload() only gets called if 
a class is not already loaded.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] POP access to gmail

2005-04-29 Thread Malcolm Mill
Does anyone know of a PHP script to access gmail's POP services?
Thanks, 
Malcolm.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POP access to gmail

2005-04-29 Thread The Disguised Jedi
On 4/29/05, Malcolm Mill [EMAIL PROTECTED] wrote: 
 
 Does anyone know of a PHP script to access gmail's POP services?

 Check PEAR. There is a POP communication script that you may like there.
 http://pear.php.net/package/Net_POP3
 HTH,

-- 
The Disguised Jedi
[EMAIL PROTECTED]

Now you have my $0.02. Or .01 Pounds, .014 Euros, or $0.025 CAN. I'm 
world-wide BABY!
PHP rocks!
Knowledge is Power. Power Corrupts. Go to school, become evil

Disclaimer: Any disclaimer attached to this message may be ignored. However, 
I must say that the ENTIRE contents of this message are subject to other's 
criticism, corrections, and speculations.

This message is Certified Virus Free


[PHP] Re: POP access to gmail

2005-04-29 Thread pete M
http://phpmailer.sourceforge.net/
excellent and easy to use class
Malcolm Mill wrote:
Does anyone know of a PHP script to access gmail's POP services?
Thanks, 
Malcolm.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] help formatting a mysql datetime variable

2005-04-29 Thread Bosky, Dave
I'm trying to get a mysql datetime variable called $cdate formatted so
it will print:

Thursday, April 28, 2005 at 8:00:00 PM Eastern Time

I tried the following but it's not perfect.

--
$newDate = date('I, F d, Y at g:i:s A T', $cdate);
echo $newDate;
--


Thanks,

Dave

 

 



HTC Disclaimer:  The information contained in this message may be privileged 
and confidential and protected from disclosure. If the reader of this message 
is not the intended recipient, or an employee or agent responsible for 
delivering this message to the intended recipient, you are hereby notified that 
any dissemination, distribution or copying of this communication is strictly 
prohibited.  If you have received this communication in error, please notify us 
immediately by replying to the message and deleting it from your computer.  
Thank you.


[PHP] check for alphanumeric characters

2005-04-29 Thread Diana Castillo
what kind of a function can I use that will tell me whether a variable is 
alphanumeric (that is has only characters A-Z or 1-9 )?


-- 
Diana Castillo
Global Reservas, S.L.
C/Granvia 22 dcdo 4-dcha
28013 Madrid-Spain
Tel : 00-34-913604039 Ext 216
Fax : 00-34-915228673
email: [EMAIL PROTECTED]
Web : http://www.hotelkey.com
  http://www.destinia.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] check for alphanumeric characters

2005-04-29 Thread Jay Blanchard
[snip]
what kind of a function can I use that will tell me whether a variable
is 
alphanumeric (that is has only characters A-Z or 1-9 )?
[/snip]

You can use a regular expression, start here http://us3.php.net/regex

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] check for alphanumeric characters

2005-04-29 Thread John Nichel
Diana Castillo wrote:
what kind of a function can I use that will tell me whether a variable is 
alphanumeric (that is has only characters A-Z or 1-9 )?


Something like this should work.  (untested)
preg_match ( /^([a-z]||[A-Z]||[0-9])+$/, $string )
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] only allowing php_flag register_globals off

2005-04-29 Thread Karin van den Berg
Hi,
I am on a quest for a new good webhost and I am currently using a trail
account at a host that seems pretty good, but has one problem. I cannot
turn register_globals off. They don't allow php_flag/php_value in
.htaccess for security reasons but in this case it's causing insecurity
It's not that I can't code secure enough code to deal with this, but I'm
also running other (public) php applications, and I just want
register_globals off, period. I have tried to convince the sysadmin to
find a way to turn it off just for my account but I think they don't
want to set up individual configs or something.
One final way I want to try to convince him is to allow the
register_globals php_flag only in the general configuration, so that you
can only use this flag and no others. That way, the only thing allowed
is actually closing a security risk. B
But I can't find any info on this, is there a way to configure apache
and/or PHP so that you allow only one type of php_flag?
Please help me, I've been looking for a host for ages and I'm really
getting tired of this :-(
Thanks a million!
Karin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] only allowing php_flag register_globals off

2005-04-29 Thread Jay Blanchard
[snip]
I am on a quest for a new good webhost 
[/snip]

How about http://www.phpwebhosting.com?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Robert Cummings
On Fri, 2005-04-29 at 13:27, Clive Zagno wrote:
 Wait -  doesn't smarty 'compile' the php file and the tpl file into 
 another php file. If you look into templates_c directory you find some 
 'compiled' templates.

I didn't say smarty wasn't compiled, only that InterJinn avoids the
cache overhead incurred by smarty since InterJinn compiles to the actual
page loaded by the browser, and not as smarty does... into a cache file
which then needs to be loaded by the smarty engine, subsequently
requiring smarty to be loaded beforehand incurring yet another overhead.

Cheers,
Rob.

  I use InterJinn, smarty, and PHP as template engines depending on what
  the client wants and how much work they want done, and how much
  elegance, modularity, and maintainability they want. Of the three I like
  smarty the least which is probably why I wrote my own engine :) Oh wait,
  I've also used eztemplate which by far takes the cake of horrible
  horrible templating. While PHP is itself usable as a templating engine,
  it's not what I would call clear and concise when used that way (but
  maybe that's because I've come across too many instances where the
  previous developer mixed business logic with display logic and then I
  had to rework the functionality which was a nightmare :). When using
  InterJinn I save the overhead of run-time includes incurred by using PHP
  as a templating engine, and I save the overhead of cache checks incurred
  by systems like smarty since InterJinn compiles to PHP source code and
  does not use a cache (although it can be set to automatically recompile
  pages when dependencies change).
  
  At any rate I don't generally post about InterJinn here anymore since
  some of the regulars tend to get annoyed ;)
  
  Mind you I don't post much at all anymore since I became a father a year
  and a half ago... priorities you know :)
  
  Cheers,
  Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] authentication problem

2005-04-29 Thread Yavuz S. Atmaca
Hi all
I'm trying to do authentication with database. I
created the database and I inserted some usernames and
passwords into my database. By using the below file,
I'm trying to give access to the main page for the
accounts that matches the username and password. The
problem is that it do not recognize the usernames and
password that i already inserted and it dont let me
in.
Do you see an problem with the code ort any idea?
When I modifiy that line to 0, it lets me in
 if (mysql_num_rows($result) ==0)   //---like
that


Thanks in advance :) 

This is my form and php file--

?php 

session_start(); 

$errorMessage = ''; 
if (isset($_POST['txtUserId']) 
isset($_POST['txtPassword'])) { 
include 'library/config.php'; 
include 'library/opendb.php'; 
 
$userId   = $_POST['txtUserId']; 
$password = $_POST['txtPassword']; 
 
// check if the user id and password combination
exist in database 
$sql = SELECT user_id 
FROM tbl_auth_user 
WHERE user_id = '$userId' AND
user_password = PASSWORD('$password'); 
 
$result = mysql_query($sql) or die('Query failed.
' . mysql_error()); 
 
if (mysql_num_rows($result) ==1) { 
// the user id and password match, 
// set the session 
$_SESSION['db_is_logged_in'] = true; 
 
// after login we move to the main page 
header('Location: main.php'); 
exit; 
} else { 
$errorMessage = 'Sorry, wrong user id /
password'; 
} 
 
include 'library/closedb.php'; 
} 
? 
html 
head 
titleBasic Login/title 
meta http-equiv=Content-Type content=text/html;
charset=iso-8859-1 
/head 

body 
?php 
if ($errorMessage != '') { 
? 
p align=centerstrongfont color=#99?php
echo $errorMessage; ?/font/strong/p 
?php 
} 
? 
form action= method=post name=frmLogin
id=frmLogin 
table width=400 border=1 align=center
cellpadding=2 cellspacing=2 
  tr 
   td width=150User Id/td 
   tdinput name=txtUserId type=text
id=txtUserId/td 
  /tr 
  tr 
   td width=150Password/td 
   tdinput name=txtPassword type=password
id=txtPassword/td 
  /tr 
  tr 
   td width=150nbsp;/td 
   tdinput name=btnLogin type=submit
id=btnLogin value=Login/td 
  /tr 
/table 
/form 
/body 
/html 
--



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] check for alphanumeric characters

2005-04-29 Thread Philip Hallstrom
what kind of a function can I use that will tell me whether a variable is
alphanumeric (that is has only characters A-Z or 1-9 )?
http://us3.php.net/manual/en/function.ctype-alnum.php
bool ctype_alnum ( string text )
Checks if all of the characters in the provided string, text, are 
alphanumeric. In the standard C locale letters are just [A-Za-z] and the 
function is equivalent to preg_match('/^[a-z0-9]*$/i', $text).

Returns TRUE if every character in text is either a letter or a digit, 
FALSE otherwise.


Note that if you pass in an empty string you'll also get TRUE...
-philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] check for alphanumeric characters

2005-04-29 Thread John Nichel
Philip Hallstrom wrote:
what kind of a function can I use that will tell me whether a variable is
alphanumeric (that is has only characters A-Z or 1-9 )?

http://us3.php.net/manual/en/function.ctype-alnum.php
bool ctype_alnum ( string text )
Checks if all of the characters in the provided string, text, are 
alphanumeric. In the standard C locale letters are just [A-Za-z] and the 
function is equivalent to preg_match('/^[a-z0-9]*$/i', $text).

Returns TRUE if every character in text is either a letter or a digit, 
FALSE otherwise.


Note that if you pass in an empty string you'll also get TRUE...
I always forget about the c_type functions.  Good call.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] check for alphanumeric characters

2005-04-29 Thread Matthew Weier O'Phinney
* John Nichel [EMAIL PROTECTED]:
 Diana Castillo wrote:
  what kind of a function can I use that will tell me whether a variable is 
  alphanumeric (that is has only characters A-Z or 1-9 )?

 Something like this should work.  (untested)

 preg_match ( /^([a-z]||[A-Z]||[0-9])+$/, $string )

It can be simpler than that, actually:

preg_match('/^[a-z0-9]+$/i', $string)

(tested and works)

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread rush
Clive Zagno [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I dont mind seeing php and html together, but designer generally hate
 it, so I would want to seperate php code from html as much as possible.

if this is your objective than it could be worthwile for you to look at
TemplateTamer, since it has very clean separation between those two, the
designers get their html template file, and you get your .logic.php file,
and it would rarely if ever happen that you edit each others file, or stomp
over each oders code.

In addition to that, not only that TT would separate php from html, it will
also not introduce new progaming constructs in template, as many fat
template systems do.

rush
--
http://www.templatetamer.com/
http://www.folderscavenger.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Session Expiring

2005-04-29 Thread John Martinez
Hi list,
I want to have the page expire after ten minutes of inactivity. For
example, if you goto Travelocity.com and do a search then sit idle for
awhile it refreshes the page with a notice that you've been idle etc.
I want to dupe this but I only know the cheeseball way of using the
meta tag http-equiv-refresh.

What's a good alternative to using http-eqiuv-refresh?

John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Session Expiring

2005-04-29 Thread Richard Lynch
On Fri, April 29, 2005 10:28 am, John Martinez said:
 I want to have the page expire after ten minutes of inactivity. For
 example, if you goto Travelocity.com and do a search then sit idle for
 awhile it refreshes the page with a notice that you've been idle etc.
 I want to dupe this but I only know the cheeseball way of using the
 meta tag http-equiv-refresh.

 What's a good alternative to using http-eqiuv-refresh?

As far as PHP goes, you can expire the session *OR* force them to re-login
after time X with the same session easily enough when they hit a new page.

But as far as having the browser doing something when it's idle, it's
*NOT* going to be PHP!

PHP lives on the server.  It knows *nothing* about an idle browser.

As far as I know, though, the only alternative to the HTTP-EQUIV=REFRESH
would be some kind of JavaScript timer, which, to me, would be even more
cheeseball than HTTP-EQUIV=REFRESH...  But that's just me.

Why don't you just look at Travelocity.com HTML source.  Whatever they are
doing, it has to be in there, and it *CANNOT* be in anything server-side.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Templating engines

2005-04-29 Thread rush
Mattias Thorslund [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 (On the subject of templating engines, again.)

 I wonder what you folks think of the following:
 http://www.massassi.com/php/articles/template_engines/

hi!

It is nicely written, but actually, I think completely oposite from you. The
way I see it, the statement that template system purpose is to separate
bussines logic from presentation, is the biggest missconception about
templates :)

Not that I think that bussines logic should not be separated from
presentation logic, it is only that I think that it shold be separated in
your php code design, l, not by the template system. And html, and code
should be separated, one is used to model static and visual concepts, and
another to model  dynamic concepts. And they usually get defined by people
with completely different skills and even mindsets.

Anyway, I do not think there is One Right Way, of looking at templates. I
for one would never be satsfied with fat temlates like they are in Smarty
for example. But on the other hand I understand that there are people that
would never trade their Smarty templates. So as we do not get to exclusive
about how thing must be done, we could get along nicely :)

rush
--
http://www.templatetamer.com/
http://www.folderscavenger.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] authentication problem

2005-04-29 Thread Richard Lynch
On Fri, April 29, 2005 8:50 am, Yavuz S. Atmaca said:
 $sql = SELECT user_id
 FROM tbl_auth_user
 WHERE user_id = '$userId' AND
 user_password = PASSWORD('$password');

Did you use the PASSWORD function when you inserted your passwords, or are
they just plain-text?

SELECT * FROM tbl_auth_user;

If you see 'secret' in the user_password field, you need to do:
UPDATE tbl_auth_user SET user_password = PASSWORD(user_password) WHERE
user_id = 1;

Or whatever user_id has a clear-text user_password.

That's about the only thing I can see that could be messing you up...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] only allowing php_flag register_globals off

2005-04-29 Thread Richard Lynch
On Fri, April 29, 2005 7:51 am, Karin van den Berg said:
 I am on a quest for a new good webhost and I am currently using a trail
 account at a host that seems pretty good, but has one problem. I cannot
 turn register_globals off. They don't allow php_flag/php_value in
 .htaccess for security reasons but in this case it's causing insecurity

Are they unwilling to change it for a paying account, or just the trial one?

Big difference. :-)

Though they may not be willing to do it for paid account either, depending
on how they maintain their httpd.conf file, and what changes on a
per-VirtualHost basis they can cope with.

 But I can't find any info on this, is there a way to configure apache
 and/or PHP so that you allow only one type of php_flag?

I don't think anybody can do that...

They could certainly, in theory, add a flag in httpd.conf for your
VirtualHost, but not make .htaccess work just for one php_flag and no
others.

.htaccess off also gives a performance boost they might not be willing to
forego, even if it were possible.

 Please help me, I've been looking for a host for ages and I'm really
 getting tired of this :-(

I always recommend http://hostbaby.com, personally.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Is there any way to show the error file without showing the dir information?

2005-04-29 Thread cchereTieShou
In many case, if there is an error happen in a php script, it may
return an error message something like 
Parse error: parse error, unexpected T_FUNCTION in
/home/content/usr/html/test.php on line 6

Is there any way to not show the dir information, but only as
test.php on line 6 instead?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help formatting a mysql datetime variable

2005-04-29 Thread Richard Lynch
On Fri, April 29, 2005 7:38 am, Bosky, Dave said:
 I'm trying to get a mysql datetime variable called $cdate formatted so
 it will print:

 Thursday, April 28, 2005 at 8:00:00 PM Eastern Time

 I tried the following but it's not perfect.

 --
 $newDate = date('I, F d, Y at g:i:s A T', $cdate);
 echo $newDate;
 --

http://php.net/date may help you.

You should also consider using MySQL's date_format function.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SOLVEDphp Full Page Calendar not date picker

2005-04-29 Thread Wil Hitchman
Well you could have shared that script with us.  I am actually looking for 
the same thing.

Thanks,
Wil
- Original Message - 
From: Angelo Zanetti [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: PHP List php-general@lists.php.net
Sent: Friday, April 29, 2005 5:25 AM
Subject: Re: [PHP] SOLVEDphp Full Page Calendar not date picker


I got a script from a friend of mine.
Otherwise I would have definitely given the URL...
Petar Nedyalkov wrote:
On Friday 29 April 2005 11:43, Angelo Zanetti wrote:

Dont worry guys i solved it.

And if you name the solution, it'll be a perfect finish for this thread.
Remember, this mailing-list is used as a knowledge base from a lot of 
people.


Angelo Zanetti wrote:

Hi all.
Im looking for a PHP/Javascript calender that is a full page calender.
IE: for each day there is  quite a big block. Therefore it will be a
bigger form of a date picker. What I want to do is to be able to assign
notes for each day. I've seen the smarty calender which is exactly what
I need but Im not using smarty for this particular project.
thanks in advance.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Templating engines

2005-04-29 Thread Mattias Thorslund

rush wrote:
Mattias Thorslund [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 

(On the subject of templating engines, again.)
I wonder what you folks think of the following:
http://www.massassi.com/php/articles/template_engines/
   

hi!
It is nicely written, but actually, I think completely oposite from you. The
way I see it, the statement that template system purpose is to separate
bussines logic from presentation, is the biggest missconception about
templates :)
 

Nice turn of phrase. It took me a while to see that you didn't misread 
the article. :-P

Not that I think that bussines logic should not be separated from
presentation logic, it is only that I think that it shold be separated in
your php code design, l, not by the template system. And html, and code
should be separated, one is used to model static and visual concepts, and
another to model  dynamic concepts. And they usually get defined by people
with completely different skills and even mindsets.
 

I suppose this depends on the situation.  If the graphic designers are 
allergic to seeing ?=$var;? instead of {$var}, I suppose a 
templating engine like Smarty or TemplateTamer is the way to go.  Or, if 
you wanted to prevent the graphic designer from adding some complicated 
PHP code in the code , say because they don't understand how to 
structure the code. Or, because the templates will be created and 
uploaded by people who shouldn't have access to upload PHP code to the 
server.

As for the article, I know the author describes putting even pretty 
complicated presentation logic in the template. I agree that that's 
probably not such a good idea.  But I don't see where the 
PHP-as-templating engine concept implies that you couldn't also separate 
the business logic from the (dynamic) presentation logic in the php 
code, before calling the template.   The static layout in the PHP 
'template' file is basically HTML only, with placeholders for the 
dynamic data - only that the placeholders are also valid PHP, not 
yet-another language.

Anyway, I do not think there is One Right Way, of looking at templates. I
for one would never be satsfied with fat temlates like they are in Smarty
for example. But on the other hand I understand that there are people that
would never trade their Smarty templates. So as we do not get to exclusive
about how thing must be done, we could get along nicely :)
 

Agreed.  I don't lose sleep over it :-)
/Mattias
--
More views at http://www.thorslund.us


[PHP] Having problems connecting to MS SQL2000 server on PHP5

2005-04-29 Thread Vernon Jenewein
Hi,
Follwoing is a problem I'm having following some advice in a book called 
PHP5 in easy steps written by Mike McGrath:
This is a connection that seems not to work according to the writer of PHP 
5 in easy steps :

html
head titleMS SQL2000 Connection Test/title /head
body
h2
?php
$connection = mssql_connect ( MS_SQL2000 )
or die ( Sorry - unable to connect to MS SQL2000 );
echo (Congratulations, Vernon, - you connected to MS SQL2000) ;

?

/h2
/body /html

He originally wrote  (for line 6) $connection = mysql_connect ( localhost, 
root,  )
or die (Sorry - unable to connect to connect to MySQL);

All I am doing is trying to use MS SQL2000 which I have running on my 
comptuer, along with Apache Server (1.3.33)and  PHP5 (5.0.4)  And get a 
result that does not connect.  Give it a try and you will see.  I created a 
file in the htdocs folder of Apache and it is named mssqltest.php  and has 
the above scripts.  Rather than using the MySQL that the author has 
suggested to use, I'm using my exisiting MS SQL2000 that is up and running.

Also I have not had much success with Apache Server 2.0.54 as yet.. any one 
else?

Would be nice if authors would not assume that you ALWAYS want to use MySQL 
or any other database manager, and just put in a few examples from different 
angles.

thanks in advance if you have some ideas for me.
CHEERS!!
Vernon



Flintknapper Forums at:
http://scottieluvr.com/v-web/bulletin/bb/index.php

Vernon Jenewein

6658 116th Ave.
Fennville, MI 49408
269-227-8748
You will know the truth, and the truth will set you free. (Jn 8:23)

[EMAIL PROTECTED]
[EMAIL PROTECTED]   (secondary) 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SOLVEDphp Full Page Calendar not date picker

2005-04-29 Thread Richard Lynch
Here's source code to one I wrote ages and ages ago...

http://chatmusic.com/calendar.phps
http://chatmusic.com/calendar.php

Here's a similar one with PDF output:

http://uncommonground.com/events.phps
http://uncommonground.com/events.pdf

Help yourself to whatever bits and pieces you want.

YMMV

On Fri, April 29, 2005 2:25 am, Angelo Zanetti said:
 I got a script from a friend of mine.
 Otherwise I would have definitely given the URL...


 Petar Nedyalkov wrote:

On Friday 29 April 2005 11:43, Angelo Zanetti wrote:


Dont worry guys i solved it.



And if you name the solution, it'll be a perfect finish for this thread.
Remember, this mailing-list is used as a knowledge base from a lot of
 people.



Angelo Zanetti wrote:


Hi all.

Im looking for a PHP/Javascript calender that is a full page calender.
IE: for each day there is  quite a big block. Therefore it will be a
bigger form of a date picker. What I want to do is to be able to assign
notes for each day. I've seen the smarty calender which is exactly what
I need but Im not using smarty for this particular project.

thanks in advance.








-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Having problems connecting to MS SQL2000 server on PHP5

2005-04-29 Thread Mike Smith
Check your php.ini. It seems you are running this on Windows w/Apache.
Make sure php_mssql.dll (or php_mssql.so if you are on Linux) is NOT
commented out. Also, I think you'll need a SQL account. Is the SQL
Server in mixed mode or Windows authentication? Look in Enterprise
MAnager or the registry
(HKLM\Software\Microsoft\MSSqlserver\MSSqlServer\LoginMode) 1 is
Windows authentication, 2 is mixed (SQL/Windows). Have a look here for
others experiences:
http://us4.php.net/function.mssql-connect

--
Mike

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to know if php CAN write files on server and WHERE it can?

2005-04-29 Thread Richard Lynch
On Fri, April 29, 2005 1:51 am, Giulio said:
 Having to read some uploaded files, perform operations on them (
 basically attach them on a single file ), and then save the resulting
 file using ftp, and trying to have the php page as general as possible
 ( I mean have it work on the larger number of server possible and
 without configuration settings ):

 1) Could it be possible to have a php or server config that doesn't
 allow at all to write and read files on the server( I'm afraid yes) and
 how can I detect this situation from code, at least to show a this
 script can't run here message?

It's certainly possible for a server to not allow any write access to
anywhere for PHP, and probably even for there to be no possible way for
the end user to alter the permissions of directories/files so they can't
over-ride that...

There is *NO* way for you to detect that from PHP, however, since in many
cases the user/pass that can alter the file permissions is not accessible
to PHP in any way, shape, or form, nor should it be.

I guess you *could* attempt to write in every possible directory on the
server, walking down from / to all the directories you can find, and
eventually maybe find one, god knows where, that is writable...

But that would probably get your script banned on every server :-)

 2) All the upload_and_copy_files_somewhere_else examples relay on a
 destination directory explicitly set in the script. How can i have my
 php discover on its own where it can write and read, no matter the
 position since it is a kind of temporary and working folder, and I'll
 delete all files used when finished?

If you're just going to delete the files after your script is done, why
copy them somewhere else at all?

Your best bet is to try and use the /tmp dir, or, more properly, what PHP
thinks is a good place for tmp files.

For that matter, using http://php.net/tmpfile may take care of all your
worries on this one.

If tmpfile doesn't work, then you might as well just give up.

 3) Which security settings ( safe_mode and so on )  should I be aware
 of?

All of them? [shrug]

You're going to have to read the manual on this one.

 Some good tutorial somewhere?

 Thank you so much,

There are a zillion, but I doubt that any of them address a generalized
file upload script...

Maybe check out how applications like squirrelmail handle file uploads
before they send them off to email them out.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SOLVEDphp Full Page Calendar not date picker

2005-04-29 Thread Jason Motes
Here is cal from a scheduling app i have working on.
http://www.imotes.com/cal2.php
http://www.imotes.com/cal2.phps
Richard Lynch wrote:
Here's source code to one I wrote ages and ages ago...
http://chatmusic.com/calendar.phps
http://chatmusic.com/calendar.php
Here's a similar one with PDF output:
http://uncommonground.com/events.phps
http://uncommonground.com/events.pdf
Help yourself to whatever bits and pieces you want.
YMMV
On Fri, April 29, 2005 2:25 am, Angelo Zanetti said:
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Your Opinion

2005-04-29 Thread Richard Lynch
On Fri, April 29, 2005 1:51 am, Sudeep Sarath said:
   I'm planning to buy PHP5  MySQL Bible, the book
 written by Tim Converse, Joyce Park  Clark Morgan.
 Give me your opinion on this book, if anyone has gone
 thru it.

I tech-edited the first two editions, before a change in personnel at the
Publisher.

They were good, solid introduction/journeyman texts with enough meat to
last you for awhile.

They were geared toward somebody who had a LITTLE programming experience,
and some HTML experience, rather than a complete beginner.

I haven't read the latest edition, though.

The addition of MySQL is a change -- possibly making it much larger, or
possibly chopping out a fair amount of the content to make room for the
MySQL stuff...

Hope that is at least a little helpful.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] User Logout system advice needed...

2005-04-29 Thread Richard Lynch
On Thu, April 28, 2005 10:51 pm, William Stokes said:
 How about preventing access by hitting the browsers back button after the
 user has logged out?

Try sending an md5 or uniqid out as TYPE=HIDDEN with your login, and
marking it used after the first login.

Also educate the users to CLOSE THEIR BROWSER to clear out all credentials.



-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passing a variable through 2 required files embedded in Javascript

2005-04-29 Thread Richard Lynch
On Thu, April 28, 2005 9:08 pm, Mark Cain said:
 What a mess this has turned out to be -- But perhaps you can help me.

 I have a dynamic site that pulls headers, navigation, and footers from
 text files.  The content for the pages is pulled from mySQL.

 On each page I have a JavaScript rotating banner that displays Upcoming
 Events.  The banners rotate about every 4 seconds without the need for a
 page refresh.  The names of the individual banners themselves are fed into
 JavaScript from a PHP script that reads a folder of JPG files and makes a
 decision as to which ones to show (i.e. pass to the JavaScript).

 This all works and it's slick seeing that I have the difficulty of dealing
 with a server side script and a client script.  The browser calls a
 JavaScript file which has a php extension.  When the server sees the php
 extension the file is executed before it is delivered to the browser.
 Since JavaScript complains about PHP functions in that file that file
 merely echo back standard JavaScript and calls another php file via
 require() that does the low level work of reading the folder and reporting
 back the JavaScript arrays.  Graphically it looks like this:

It sounds to me like you really should just cut this in HALF with:

PHP script outputs header with JavaScript and then body with JavaScript.

As you have it now, every page hits the web server *TWICE* causing twice
the overhead of resources used by HTTP.

That's not real efficient.

But that's just me.

 1) the Page calls the header
  2) the header calls
3) a php generated JavaScript file which calls
 4) a php file that reads the folder on the server and
 builds the JavaScript arrays

I mean to say:

?php
  /* Choose your JavaScript banner ads here. */

  require 'header.inc'; //This outputs JavaScript to rotate selected banners

  /* rest of page here */
?


 Now I need to add a feature and I am bumping my head on this one.

 How do I report the file name of the file that called the header in # 4 ?
 In other words, I want the name of #1 to be reported in #4.  If I use
 $_SERVER[PHP_SELF], that variable reports the name of #4.  It gets a
 little tricky because #3 is called from within a JavaScript tag.

Have you looked at $_SERVER['HTTP_REFERER']?

You may need to pass it around in a new variable ?php $source_page =
$_SERVER['HTTP_REFERER']? from PHP to JavaScript and back again, but it's
there for you to use it.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Templating engines

2005-04-29 Thread Skrol 29
What templating engines do you use with php and why?
Ive been using smarty (http://smarty.php.net)
Clive.
I just can't work with PHP the usual way.
Mixing business source and interface source is something too bastard for me.
Now that I know templates systems I totaly disagree to say that PHP is a
Template Engine. Ok, it has some basic template features, but they are too
poor to use it this way seriously.
It would be like calling Notepad / VI / TextEdit Html Editors.
I made and use TinyButStrong, because all other seems too complicated and
had too much programming at the design side for me. It's mature now.
It's also the only Template Engine that's really works with WYSIWYG
templates.
---
Skrol29
www.tinybutstrong.com
--- 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] inserting an auto incemented column in table already created

2005-04-29 Thread Ross Hulford
Hi,

I have a table with 15 columns or so that has been inherited from an older 
db and am trying to insert an auto increment column  (in mysql) without 
having to number it manually. This is fine when I add new colums via a form 
but the old entries have a null value

Alternatively It has been converted from Excel soif anyone knows how to do 
it that way that would help.I never use Excel so have no clue about it.


R. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Is there any way to show the error file without showing the dir information?

2005-04-29 Thread Jason Barnett
cchereTieShou wrote:
In many case, if there is an error happen in a php script, it may
return an error message something like 
Parse error: parse error, unexpected T_FUNCTION in
/home/content/usr/html/test.php on line 6
Is there any way to not show the dir information, but only as
test.php on line 6 instead?
If this is really important for you then you should check out this link:
http://php.net/manual/en/function.set-error-handler.php
Although personally I like detailed info going into my error log.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] inserting an auto incemented column in table already created

2005-04-29 Thread Jay Blanchard
[snip]
I have a table with 15 columns or so that has been inherited from an
older 
db and am trying to insert an auto increment column  (in mysql) without 
having to number it manually. This is fine when I add new colums via a
form 
but the old entries have a null value

Alternatively It has been converted from Excel soif anyone knows how to
do 
it that way that would help.I never use Excel so have no clue about it.
[/snip]

Just out of curiosity, wouldn't this be better on a MySQL list?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Greg Donald
On 4/29/05, Skrol 29 [EMAIL PROTECTED] wrote:
 It would be like calling Notepad / VI / TextEdit Html Editors.

HTML is text.. so any text editor is an HTML editor by default, including vi.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] inserting an auto incemented column in table already created

2005-04-29 Thread Richard Lynch
On Fri, April 29, 2005 2:14 pm, Ross Hulford said:
 I have a table with 15 columns or so that has been inherited from an older
 db and am trying to insert an auto increment column  (in mysql) without
 having to number it manually. This is fine when I add new colums via a
 form
 but the old entries have a null value

$new_id = 1;
do {
  $query = select SOMETHING_UNIQUE from whatever where NEW_ID is NULL
LIMIT 1;
  $results = mysql_query($query);
  $something_unique = mysql_result($results, 0, 0);
  $query = update whatever set NEW_ID = $new_id where SOMETHING_UNIQUE =
$something_unique;
  mysql_query($query);
} while (mysql_num_rows($results));

 Alternatively It has been converted from Excel soif anyone knows how to do
 it that way that would help.I never use Excel so have no clue about it.

In excel, you can just put '1' in the first row, and then move down a row,
and type the following sequence:

=[up_arrow]+1

and hit enter

At that point, you should be seeing a '2' in the second row.

You can copy that cell, highlight rows 3 through N, and use Paste

All your rows are now numbered, 1 to N.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Mattias Thorslund

Skrol 29 wrote:
What templating engines do you use with php and why?
Ive been using smarty (http://smarty.php.net)
Clive.

I just can't work with PHP the usual way.
Mixing business source and interface source is something too bastard 
for me.
Now that I know templates systems I totaly disagree to say that PHP is a
Template Engine. Ok, it has some basic template features, but they are 
too
poor to use it this way seriously.

Who says PHP itself is a template engine?  I think nobody. What are the 
basic template features? 

However, there is a school of thought regarding templates that advocates 
template engines (written in, for instance, PHP) which use PHP as their 
template syntax, so that there is no need to invent new tags or 
placeholders. You could read the article I linked to before, it has 
examples.  Actually, here's the link again:

http://www.massassi.com/php/articles/template_engines/
Best regards,
Mattias

--
More views at http://www.thorslund.us
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Templating engines

2005-04-29 Thread Richard Lynch
 Who says PHP itself is a template engine?

I do.

More importantly, Rasmus does.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Splitting Vars from MySQL in PHP

2005-04-29 Thread jlfx mailgroups

I remember in Perl I used to extract vars from a single fetchrow by adding
each var name to the beginning (like this). Only this ain'ta workin :)...
Anyone know the right syntax to do this?

($var1, $var2, $var3)= mysql_fetch_array($result, MYSQL_ASSOC)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Jason Barnett
Mattias Thorslund wrote:
...

Who says PHP itself is a template engine?  I think nobody. What are the 
basic template features?
Variables / placeholders
Looping construct(s)
Conditionals
A way to apply styles to text / markup
However, there is a school of thought regarding templates that advocates 
template engines (written in, for instance, PHP) which use PHP as their 
template syntax, so that there is no need to invent new tags or 
placeholders. You could read the article I linked to before, it has 
examples.  Actually, here's the link again:

http://www.massassi.com/php/articles/template_engines/
The point of this article is that PHP is a good template engine ;)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Splitting Vars from MySQL in PHP

2005-04-29 Thread Christopher Fulton
On 4/29/05, jlfx mailgroups [EMAIL PROTECTED] wrote:
 
 I remember in Perl I used to extract vars from a single fetchrow by adding
 each var name to the beginning (like this). Only this ain'ta workin :)...
 Anyone know the right syntax to do this?
 
 ($var1, $var2, $var3)= mysql_fetch_array($result, MYSQL_ASSOC)
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


list($var1, $var2, $var3) = mysql_fetch_array($result, MYSQL_ASSOC);
http://us4.php.net/manual/en/function.list.php

-Chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Mattias Thorslund
Richard Lynch wrote:
Who says PHP itself is a template engine?
   

I do.
 

More importantly, Rasmus does.
 

What? My li'l brother does PHP? Or you mean him Lerdorf?
Sorry...
/Mattias

--
More views at http://www.thorslund.us


Re: [PHP] Re: Templating engines

2005-04-29 Thread Mattias Thorslund
Jason Barnett wrote:
Mattias Thorslund wrote:
...

Who says PHP itself is a template engine?  I think nobody. What are 
the basic template features?

Variables / placeholders
Looping construct(s)
Conditionals
A way to apply styles to text / markup

So I suppose I'm just confused over what constitutes a templating 
engine? I was thinking that the class/tool/program/whatever that handles 
the templates would be the template engine.  I'm aware that a 
PHP-as-template-template would use PHP's native syntax for 
variables/loops/conditionals.

Then I wonder what makes skol29 think PHP's basic template features 
are too poor to be used seriously?  I think PHP's basic template 
features are phenomenal.


However, there is a school of thought regarding templates that 
advocates template engines (written in, for instance, PHP) which use 
PHP as their template syntax, so that there is no need to invent new 
tags or placeholders. You could read the article I linked to before, 
it has examples.  Actually, here's the link again:

http://www.massassi.com/php/articles/template_engines/
The point of this article is that PHP is a good template engine ;)

As I saw it, the PHP class described in the article would be the 
template, but that's obviously a misconception on my part.  What's the 
generic term for the template handling class, then?

Cheers,
Mattias
--
More views at http://www.thorslund.us
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Templating engines

2005-04-29 Thread Rasmus Lerdorf
Mattias Thorslund wrote:
Skrol 29 wrote:
What templating engines do you use with php and why?
Ive been using smarty (http://smarty.php.net)
Clive.

I just can't work with PHP the usual way.
Mixing business source and interface source is something too bastard 
for me.
Now that I know templates systems I totaly disagree to say that PHP is a
Template Engine. Ok, it has some basic template features, but they are 
too
poor to use it this way seriously.

Who says PHP itself is a template engine?  I think nobody. 
I do.
It comes down to whether you want the delineation between the template 
and the business logic enforced by the system or not.  PHP is a 
general-purpose templating system that does not enforce this 
delineation.  It lets you choose exactly how much logic you are going to 
allow in your templates.  If you have no control over the people 
creating your templates, that may not be appropriate, but in many cases 
it is perfectly fine.  It just takes a bit of discipline to use it 
correctly.

You also need to recognize that you are going to need presentation-layer 
logic.  You simply can't get around that and you shouldn't confuse 
presentation-level logic, which can be quite complex, with the business 
logic behind your application.  I often see people make the mistake of 
trying to separate their PHP code from their HTML which the article you 
referenced hinted at as well.

The approach I tend to point people at is something I have been calling 
a Template API.  That is, when you build your application, you create a 
template api to go along with it.  In essence you are creating a 
templating system for each application you write.

For example, I describe a simple such system here:
   http://talks.php.net/show/mtladv05/20
To me, this is a perfectly good template (from the slide):
  ?php
  start_poll(1);
  $os = array(FreeBSD,Linux,OSX,Windows,Other);
  ?
  p class=purpose
  Please answer a couple of questions for us.
  /p
  p class=question
  1. What is your name?
  /p
  ?php text_answer('name',64)?
  p class=question
  2. Which operating systems do you use on a daily basis?
  /p
  ?php select_any_of($os)?
  p class=question
  3. Which operating system do you prefer?
  /p
  ?php select_one_of($os)?
  ?php end_poll(); ?
The end_poll() call could be eliminated as well to make it slightly 
cleaner, but otherwise this is straight-forward with no mixing of 
business-logic and content.

My main issue with general-purpose templating systems is that they 
always end up inventing a new language.  It may start off as a subset of 
some other language, but eventually it turns into a new language.  In 
Smarty, for example, you now have stuff like:

  {object-method p1=arg1 p2=$arg2 assign=output}
  Result was {$output}
I fail to see how this is in any way better/easier/superior to:
  ?$output = $object-method(arg1,$arg2)?
  Result was ?=$output?
As far as I am concerned you shouldn't be dealing with any sort of 
objects from a template to begin with.  There should be nothing but 
simple variables and straight function calls from a template, but this 
is a religious issue that people will never agree on.  Hence PHP's 
neutral approach where the exact templating delienation is left up to 
the users.

-Rasmus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Splitting Vars from MySQL in PHP

2005-04-29 Thread Philip Olson
  I remember in Perl I used to extract vars from a single fetchrow by adding
  each var name to the beginning (like this). Only this ain'ta workin :)...
  Anyone know the right syntax to do this?
  
  ($var1, $var2, $var3)= mysql_fetch_array($result, MYSQL_ASSOC)
 
 
 list($var1, $var2, $var3) = mysql_fetch_array($result, MYSQL_ASSOC);
 http://us4.php.net/manual/en/function.list.php

But remember that list() only works with numerical 
arrays so use MYSQL_NUM (or array_values()) in the 
above. For associative, extract() can be useful.

Regards,
Philip

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Mattias Thorslund
Rasmus Lerdorf wrote:
Mattias Thorslund wrote:
Who says PHP itself is a template engine?  I think nobody. 

I do.
It comes down to whether you want the delineation between the template 
and the business logic enforced by the system or not.  PHP is a 
general-purpose templating system that does not enforce this 
delineation.  

That explanation is sensible enough.
[skipping ahead a little]
The approach I tend to point people at is something I have been 
calling a Template API.  That is, when you build your application, you 
create a template api to go along with it.  In essence you are 
creating a templating system for each application you write.

For many projects, I think the approach you describe in the example 
(below) is appropriate. One nice thing is that output can begin before 
the whole page has been nearly processed.  I don't know if many other 
templating solutions can do that.

To me, it looks like it would be hard to keep the functions that are 
called by the template to a reasonable format or number, at least in a 
larger project.  If it's a template that is to be used by many kinds of 
pages, there would be either a large number of functions, or there would 
be generic functions that need to do different things based on the 
situation.

Of course, the functions could become methods of a page object. Then, 
it gets easy to create specialized subclasses of page objects which can 
respond differently to the same generic method call.  Sounds more 
attractive the more I think about it :-)

Then again, if I need a big object to handle the business logic (and 
dynamic presentation logic) because my template approach is sequential, 
it might be a toss-up compared to using sequential business logic and a 
small template object.


For example, I describe a simple such system here:
   http://talks.php.net/show/mtladv05/20
To me, this is a perfectly good template (from the slide):
  ?php
  start_poll(1);
  $os = array(FreeBSD,Linux,OSX,Windows,Other);
  ?
  p class=purpose
  Please answer a couple of questions for us.
  /p
  p class=question
  1. What is your name?
  /p
  ?php text_answer('name',64)?
  p class=question
  2. Which operating systems do you use on a daily basis?
  /p
  ?php select_any_of($os)?
  p class=question
  3. Which operating system do you prefer?
  /p
  ?php select_one_of($os)?
  ?php end_poll(); ?
The end_poll() call could be eliminated as well to make it slightly 
cleaner, but otherwise this is straight-forward with no mixing of 
business-logic and content.

My main issue with general-purpose templating systems is that they 
always end up inventing a new language.  

Except the class described in the article I was talking about.  It uses 
PHP as the template language.  It's a big reason why I find it attractive.

[skipping discussion on Smarty]
As far as I am concerned you shouldn't be dealing with any sort of 
objects from a template to begin with. 

This does place some demands on the business logic. 

There should be nothing but simple variables and straight function 
calls from a template, but this is a religious issue that people will 
never agree on.  Hence PHP's neutral approach where the exact 
templating delienation is left up to the users.

No doubt, people will continue to argue over it for a long time to 
come.  I try not to be religious about it, I simply want to know as many 
sides of the issue as possible.

Best,
Mattias
--
More views at http://www.thorslund.us
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Is it possible to save a file with UTF-8 encoding and noBOM using PHP?

2005-04-29 Thread Rasmus Lerdorf
Jon M. wrote:
No matter what I do to the strings to encode them in whatever format before 
using fwrite, it ALWAYS seems to end up writing the actual file in 
iso-8859-1.

Isn't the encoding of the characters in PHP's strings, and the encoding of 
the actual binary file on your hard drive, two totally different things? Or 
am I just misinformed?
A file is completely defined by its contents.  If you fwrite UTF-8 data 
to the file, then it is a UTF-8 file.  Whether your editor, or whatever 
it is you are using to determine the file is being written as iso-8859-1 
is smart enough to pick this up is a completely different question.

Why don't you try creating the same contents with PHP and with your 
preferred text editor and then compare the contents.  Perhaps your 
editor is dropping a hint somewhere in it that you are not writing to 
the file from PHP.

-Rasmus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Templating engines

2005-04-29 Thread Matthew Weier O'Phinney
* Rasmus Lerdorf [EMAIL PROTECTED] :
 My main issue with general-purpose templating systems is that they 
 always end up inventing a new language.  It may start off as a subset of 
 some other language, but eventually it turns into a new language.  In 
 Smarty, for example, you now have stuff like:

{object- method p1=arg1 p2=$arg2 assign=output}
Result was {$output}

 I fail to see how this is in any way better/easier/superior to:

?$output = $object- method(arg1,$arg2)?
Result was ?=$output?

 As far as I am concerned you shouldn't be dealing with any sort of 
 objects from a template to begin with.  There should be nothing but 
 simple variables and straight function calls from a template, but this 
 is a religious issue that people will never agree on.  Hence PHP's 
 neutral approach where the exact templating delienation is left up to 
 the users.

I thoroughly agree with you on this point. I think in some areas of
Smarty development, they've gotten a little too complex, likely as a
result of people getting lazy in what they send to the template and
requesting new features. That said, I still use Smarty -- but I try to
send it straight scalars or arrays, as you suggest above, leaving my
heavy lifting in my application logic, and keep the presentation logic
more lightweight.

In reading The Pragmatic Programmer, I think that templating languages
are an application of using metadata or a domain language. The principle
here is a subset of the language -- or another language entirely that
can be interpreted by the original language -- helps to contain and
solve the problem. Sometimes it's easier to use the subset to describe
the process than the full language. 

Let's face it, there's over 1000 functions in PHP; most of the time, I
only need a few of those for my display logic. Using a template engine
and its language helps me switch gears in my brain to thinking in terms
of display instead of my application logic.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Templating engines

2005-04-29 Thread Robert Cummings
On Fri, 2005-04-29 at 21:09, Mattias Thorslund wrote:
 Rasmus Lerdorf wrote:
 
  Mattias Thorslund wrote:
 
  Who says PHP itself is a template engine?  I think nobody. 
 
 
  I do.
 
  It comes down to whether you want the delineation between the template 
  and the business logic enforced by the system or not.  PHP is a 
  general-purpose templating system that does not enforce this 
  delineation.  

 That explanation is sensible enough.
 
 
 [skipping ahead a little]
 
  The approach I tend to point people at is something I have been 
  calling a Template API.  That is, when you build your application, you 
  create a template api to go along with it.  In essence you are 
  creating a templating system for each application you write.

I think a problem here is when you decide to blend two projects that
started out separately. With a templating system (some anyways :) you
can just redefine the main layout for each page being merged into the
larger project in a single centralized location. The approach described
above would appear to require in depth modification of the application's
template API.

 For many projects, I think the approach you describe in the example 
 (below) is appropriate. One nice thing is that output can begin before 
 the whole page has been nearly processed.  I don't know if many other 
 templating solutions can do that.

Personally I find having the output ALWAYS begin after all business
logic has completed to be a better choice, that way upon error (a
catchable error) you can redirect the user to an info page that might
state the page is temporarily unaccessible.

 To me, it looks like it would be hard to keep the functions that are 
 called by the template to a reasonable format or number, at least in a 
 larger project.  If it's a template that is to be used by many kinds of 
 pages, there would be either a large number of functions, or there would 
 be generic functions that need to do different things based on the 
 situation.

I don't think that templates have a dependency between the number of
pages using the template and an increase in the number of functions. In
fact depending on the template, and the template engine, you can have
500 pages using the template and not a single function call. Including
the elimination of include() and include_once() calls since if the
template engine compiles to PHP it can do the includes at compile time
rather than punting to PHP to do at run-time.

 Of course, the functions could become methods of a page object. Then, 
 it gets easy to create specialized subclasses of page objects which can 
 respond differently to the same generic method call.  Sounds more 
 attractive the more I think about it :-)

So every time you want a small difference you subclass the main page
object. Seems a lot of work and overhead for something small. What
happens when you want to share functionality from one project in another
without recoding or copying it?

I personally prefer the modularization of custom functionality into
loadable compiler modules. I find this especially convenient when an XML
or XML-like template system is used that allows namespaces. Then you can
just include already created functionality via module includes at
compile time, and incur no overhead at run-time. Not to mention you get
to skip past the whole sub-classing nightmare, although there's nothing
to stop you from sub-classing a compiler module :) But at least it's
more portable and re-usable. Overhead is still incurred for
transformation on dynamic content, but even still if you are
transforming dynamic content via the template engine you at least
minimize the amount of work needing to be done at run-time.

 Then again, if I need a big object to handle the business logic (and 
 dynamic presentation logic) because my template approach is sequential, 
 it might be a toss-up compared to using sequential business logic and a 
 small template object.
 
 
  For example, I describe a simple such system here:
 
 http://talks.php.net/show/mtladv05/20
 
  To me, this is a perfectly good template (from the slide):
 
?php
start_poll(1);
$os = array(FreeBSD,Linux,OSX,Windows,Other);
?
p class=purpose
Please answer a couple of questions for us.
/p
 
p class=question
1. What is your name?
/p
?php text_answer('name',64)?
 
p class=question
2. Which operating systems do you use on a daily basis?
/p
?php select_any_of($os)?
 
p class=question
3. Which operating system do you prefer?
/p
?php select_one_of($os)?
 
?php end_poll(); ?
 
  The end_poll() call could be eliminated as well to make it slightly 
  cleaner, but otherwise this is straight-forward with no mixing of 
  business-logic and content.

This works, but now what happens when your client/boss requests that the
operating system choice not be a multi-select list but rather checkboxes
and those check boxes should be 3 columns wide. The convenient

Re: [PHP] Re: Templating engines

2005-04-29 Thread Greg Donald
On 4/29/05, Robert Cummings [EMAIL PROTECTED] wrote:
 Personally I find having the output ALWAYS begin after all business
 logic has completed to be a better choice

I agree totally.  Most PHP coders I've worked around put PHP in their
HTML.  I am the exact opposite.  I use PHP to build up my HTML and
then output it at the very end of the script.  I use heredoc syntax
almost exclusively.  Seems very clean.

Drives me insane to see HTML with stuff like ?=$var? all through it.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] About the mail().

2005-04-29 Thread Penghui Wang
Hi lists:

I am new here. And i know little about php. Sorry ask so stupid
question.
I want to use my local /usr/sbin/sendmail to send mail to a certain
address. I have checked the function_list in http://www,php.net.
And i found the mail(). It enough to my requirement.

And i have written a php file like below:

?php
if($_POST['send']) {
  $message = $_POST['message'];
  $body =  . $message['username'] . \n .
   . $message['usermail'] . \n .
   . $message['compname'] . \n .
   . $message['telephone'] . \n\n .
   . $message['subject'] . \n .
   . $message['content'] . \n;

  $headers .= Content-Transfer-Encoding: UTF-8\n;
  $headers .= Content-Type: text/plain; charset=utf-8\n;
  $headers .= MIME-Version: 1.0\n;
  $headers .= From: [EMAIL PROTECTED];
  $headers .= X-Mailer: Online Help!(http://www.example.com)\n;

  mail('[EMAIL PROTECTED]', '! ', $body, $headers);
  header(Location: http://www.example.com;);
}

if($_POST['cancel']) {
  header(Location: http://www.example.com;);
}
?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=zh 
head
title/title
meta http-equiv=Content-Type content=text/html; charset=UTF-8 /
/head
body
h1 style=text-align:center;color: red/h1
div style=margin: auto; width: 65%;
p./p
form method=post
fieldset
legend/legend
input type=text name=message[username] 
input type=text name=message[usermail] br
input type=text name=message[compname] 
input type=text name=message[telephone] 
/fieldset
fieldset
legend/legend
input name=message[subject] type=text size=30 value=
maxLength=100br
textarea name=message[content]rows=10 cols=70/textarea
div style=text-align:center
input type=submit name=send value=
input type=submit name=cancel value=
/div
/fieldset
/form
/div
/body
/html

But all the chinese words could change to . The charset of this
file is UTF-8.
I wonder know how to deal with it. And i am blind with it now. Because
the lack of experience with php.


Best regards

Wang Penghui




Re: [PHP] Re: Templating engines

2005-04-29 Thread Rasmus Lerdorf
Robert Cummings wrote:
I think a problem here is when you decide to blend two projects that
started out separately. With a templating system (some anyways :) you
can just redefine the main layout for each page being merged into the
larger project in a single centralized location. The approach described
above would appear to require in depth modification of the application's
template API.
The template api is a functional description of the backend capabilities 
you are exposing to the templates.  They shouldn't have to change unless 
you are making changes to those backend capabilities.  The templates 
themselves provide the markup and location of these various components 
of the application.  The stack looks like this:

  http://talks.php.net/show/lca05/58
So if you are blending things together you will at most need to change 
the top two layers.

I don't think that templates have a dependency between the number of
pages using the template and an increase in the number of functions. In
fact depending on the template, and the template engine, you can have
500 pages using the template and not a single function call. Including
the elimination of include() and include_once() calls since if the
template engine compiles to PHP it can do the includes at compile time
rather than punting to PHP to do at run-time.
While compiling to PHP is by far superior to the various terrible eval() 
and regex-based templating layers out there, it is still dog-slow 
compared to tight specialized PHP code.  Just instantiating the base 
Smarty class, for example, takes a very long time.  I optimized a Smarty 
site a while back where I got a 50% speedup by migrating the base Smarty 
class to C in an extension.

So while how you want to separate your business logic from your layout 
and content, which to me are actually 3 levels of separation, is a 
religious thing, performance is not.  Even though most sites don't get 
anywhere near the traffic of the stuff I deal with at Yahoo!, it still 
makes a difference whether your pages get served up in 80ns vs. 500ns. 
The 80ns page starts rendering right away with no latency and the whole 
thing has a perceptible crispness to it.

This works, but now what happens when your client/boss requests that the
operating system choice not be a multi-select list but rather checkboxes
and those check boxes should be 3 columns wide. The convenient
select_any_of() function is no longer usable and while I know you can
still use PHP as the template language, it surely doesn't look as neat
as the above. Now add validation error messages, javascript events, and
other stuff that is usually required in a real life situation. The
source starts to get difficult to read and maintain as you switch in and
out of PHP, HTML, and Javascript :)
You simply change the select_any_of() API function, or make another one. 
 There are 3 levels of separation here.  For large projects you have 
people who provide content.  In this example, these are the people 
writing the actual polls.  They are not web designers, they don't know 
any Javascript and next to no HTML.  They simply provide the content for 
the application.  Much like a journalist would provide content to a news 
site.  The next layer down is the HTML/Javascript and whatever 
presentation layer magic you need.  And finally, the 3rd layer is the 
business logic which is where your database calls and real meat of your 
application resides.  In this 3rd layer there is absolutely no HTML nor 
Javascript.

-Rasmus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Templating engines

2005-04-29 Thread Robert Cummings
On Fri, 2005-04-29 at 23:55, Rasmus Lerdorf wrote:
 Robert Cummings wrote:
  I don't think that templates have a dependency between the number of
  pages using the template and an increase in the number of functions. In
  fact depending on the template, and the template engine, you can have
  500 pages using the template and not a single function call. Including
  the elimination of include() and include_once() calls since if the
  template engine compiles to PHP it can do the includes at compile time
  rather than punting to PHP to do at run-time.
 
 While compiling to PHP is by far superior to the various terrible eval() 
 and regex-based templating layers out there, it is still dog-slow 
 compared to tight specialized PHP code.  Just instantiating the base 
 Smarty class, for example, takes a very long time.  I optimized a Smarty 
 site a while back where I got a 50% speedup by migrating the base Smarty 
 class to C in an extension.

This isn't a problem for engines that compile to PHP source that has
direct hooks into the necessary data structures that will contain the
data at run time.

Smarty isn't one of them though :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php