php-general Digest 23 Sep 2002 01:40:35 -0000 Issue 1601

Topics (messages 117162 through 117220):

mysql password function
        117162 by: Murat .

Re: Elliptic curve cryptology
        117163 by: EjdeR
        117168 by: pan
        117172 by: EjdeR

Re: A weired browser-session problem
        117164 by: Chris Shiflett

cookies?
        117165 by: :B nerdy

Re: LDAP (NDS) authentication example...
        117166 by: Stig Venaas

Create Thumbnails from image
        117167 by: Kjell Hansen

closing browser's window
        117169 by: Murat .
        117174 by: EjdeR
        117176 by: Chris Hewitt
        117209 by: Justin French

Designing N-tier applications in PHP (long)
        117170 by: Michael Sims
        117183 by: Chris Shiflett
        117186 by: Peter J. Schoenster
        117192 by: Michael Sims
        117194 by: Michael Sims
        117197 by: Peter J. Schoenster
        117198 by: Manuel Lemos
        117206 by: Michael Sims
        117210 by: Michael Sims

Web site analysys
        117171 by: Rosen

Re: return the amount of records in a mysql databace
        117173 by: Jeff Bluemel
        117180 by: Chris Shiflett
        117189 by: Philip J. Newman
        117218 by: John Holmes

i got a method but how in php now?
        117175 by: :B nerdy

Re: algorythm question
        117177 by: Bar

$_GLOBAL["var"] or $_GLOBAL['var'] or $_GLOBAL[var]; ???
        117178 by: Victor
        117185 by: Peter J. Schoenster

Re: [PHP-WIN] Create Thumbnails from image
        117179 by: Olivier Hubert

Re: [PHP-DB] password function
        117181 by: Stephen Craton

Re: counting guest users
        117182 by: Stephen Craton

unlink() and IIS
        117184 by: Gerard Samuel

Update undefined List Values in DB
        117187 by: Sascha Braun

Cannot Redeclare?
        117188 by: Stephen Craton

What does this error mean
        117190 by: Randy Johnson
        117191 by: Daniel Kushner
        117193 by: Randy Johnson

Calling class functions using string variables?
        117195 by: Nick Richardson
        117196 by: Nick Richardson

session_start() --> no more output
        117199 by: Hans Wilmer
        117201 by: Michael Sims

JAVASCRIPT INCLUDES
        117200 by: Georgie Casey
        117202 by: Chris Shiflett
        117204 by: Georgie Casey
        117207 by: Chris Shiflett
        117208 by: Georgie Casey
        117211 by: David Rice

solved
        117203 by: :B nerdy

error with php and pdflib
        117205 by: Thoenen, Peter  Mr.  EPS

Redirection
        117212 by: Sascha Braun
        117213 by: Todd Pasley
        117214 by: Justin French
        117215 by: Chris Shiflett

Re: more stress on server...
        117216 by: Jason Morehouse
        117217 by: Bill Leonard

Replace linefeed/newline from text inputs with <br> tag?
        117219 by: Patrick Lebon

Re: Date Time
        117220 by: Don Read

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
hi,
i want to encode a string that users enter with mysql password function. but
sometimes this code works sometimes don't. mysql warns me:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in ........

the code is:

$result=mysql_query("select password(".$_POST['password'].")");
  while ($p = mysql_fetch_array($result, MYSQL_ASSOC)):
  $pswrd=$p['password('.$_POST['password'].')'];
  endwhile;

thanks...



--- End Message ---
--- Begin Message ---
i know searching.. and buy books. i asked for an little example..

"Danny Shepherd" <[EMAIL PROTECTED]> wrote in message
001201c2622d$4d52d640$0200a8c0@DANNYS">news:001201c2622d$4d52d640$0200a8c0@DANNYS...
> http://www.amazon.com/exec/obidos/ASIN/1884777694/102-5129419-0804910
>
> ----- Original Message -----
> From: "EjdeR" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, September 22, 2002 11:12 AM
> Subject: [PHP] Elliptic curve cryptology
>
>
> > i cant find any example about "Elliptic curve cryptology".. do you have
> any
> > example? i cant understand without an example :)
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


--- End Message ---
--- Begin Message ---



> i cant find any example about "Elliptic curve cryptology".. do you
have any
> example? i cant understand without an example :)
>

Ten seconds of googling produced these URLs.

http://www.certicom.com/resources/w_papers/w_papers.html

http://www.certicom.com/resources/ecc_tutorial/ecc_tutorial.html

--- End Message ---
--- Begin Message ---
thnx

"Pan" <[EMAIL PROTECTED]> wrote in message
004501c26249$89786a60$0901a8c0@plexus">news:004501c26249$89786a60$0901a8c0@plexus...
>
>
>
> > i cant find any example about "Elliptic curve cryptology".. do you
> have any
> > example? i cant understand without an example :)
> >
>
> Ten seconds of googling produced these URLs.
>
> http://www.certicom.com/resources/w_papers/w_papers.html
>
> http://www.certicom.com/resources/ecc_tutorial/ecc_tutorial.html
>


--- End Message ---
--- Begin Message ---
Monil,

First, from the perspective of the Web server, there is only one 
browser. Also, there is no way to know when a user closes a browser.

So, your problem just sounds like PHP is *maintaining* the session, 
which is exactly what it is supposed to do. :-) It is your job to 
maintain the data associated with a particular session, and there are 
functions to help you destroy data in a session, or you can simply 
reinitialize all of your session variables when the user first selects 
an option from the menu.

Happy hacking.

Chris

Monil Chheda wrote:

>The following is my problem.
>1) User with valid username and password is given an
>Administration Menu.
>2) Various options are there. He selects a particular
>option.
>3) The selected option is opened in a new page.
>4) He does his job on the new window. But midway ( say
>after 2 pages ), after making a few chioices, he
>closes the newly opened window,leading to some
>variables being registered
>5) Now , after some time , selects the same option.
>6) Makes his selection. But , he gets the choices that
>he had used previous time inspite of him closing the
>window .
>
>How do I get rid of the problem ? I would like that
>even if the user closes the browser midway and then
>again checks the same , his new sessions should be
>registered and not the old.
>
>Is there a way wherein we can destroy the sessions of
>the new browser window as soon as the browser is
>closed ?
>

--- End Message ---
--- Begin Message ---
i wish to POST submit to a login form on another server and then after that
POST some more information on the resulting page.

the thing is, after the first login, the website sends me a cookie. it
probably holds the session id and or authentication information. how will
can i relay this back to the page so i can view the resulting page without
being kicked out because of no cookie??

ive already used curl and am able to post things to scripts. but this cookie
problem i dont know how to get around.

any idea?
cheers



--- End Message ---
--- Begin Message ---
On Thu, Sep 12, 2002 at 09:37:22AM +1000, joshua wrote:
> i'm not sure if i follow you. i have never used ldap to write 
> authentication scripts as i've only used the .htaccess method.
> 
> to retrieve data you need to bind using a username/password combination 
> that is valid. i guess you could test your user's username/password by 
> using it to attempt a bind.

The example below is correct, however in many cases you can avoid the
anonymous search. If say for all users you have entries with dn's like

uid=dj, o=users, dc=mycompany, dc=com

you can just do 

$dn = "uid=$inp_uid, o=users, dc=mycompany, dc=com";
$ds = ldap_connect("ldap.someserver.com");
$r = ldap_bind($ds, $dn, $inp_passwd);

and check whether $r is true. Someone reported that there is some
implementation where this is falsely true for empty password, so
prior to this I would chech that the password string is non-empty,
just to be sure.

Stig
--- End Message ---
--- Begin Message ---
Hi,
I'm using a Win2k with php4.1 and I'd like to make some thumbnails from
pictures on my disk.
I've gotten the impression that it's possible, but I havent' found out
just how.

I've stumbled across the ImageCopyResized function but it requires a
imagehandle(?) to the file copied from. How do I get that? Is it the
right way to do this?
I guess I could use some picture manipulating program to do this, but
doing it the PHP way is nicer :)

TIA
Kjell

--- End Message ---
--- Begin Message ---
hi,

is it possible to close client's browser's window from php script?

thanks...


--- End Message ---
--- Begin Message ---
with javascript. yes

<?
echo "<input name=\"Close\" onClick=\"self.close();return false\"
type=\"button\" value=\"Close\">";
?>

"Murat ." <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> hi,
>
> is it possible to close client's browser's window from php script?
>
> thanks...
>
>


--- End Message ---
--- Begin Message ---
Murat . wrote:

>is it possible to close client's browser's window from php script?
>
 From a php script yes, but not by PHP, because PHP runs on the server, 
not the browser. If you use JavaScript you can close it with window.close()

HTH
Chris


--- End Message ---
--- Begin Message ---
I can't imagine how anyone could thing this is a good idea!

What's next?  Change my browser preferences without asking me?  Move some
files around on my hard drive?

FWIW, PHP is a SERVER SIDE language.  It doesn't interact with the
browser... by the time your browser recieves a page, it's just plain HTML,
which can be seen with view > source.

To do something as horrid as closing a browser, it would have to be done
with something like JavaScript on the browser (client-side).  For example,
self.close() (forget exact syntax) in JavaScript may do what you want.


I still can't see an occasion where you'd want this... at least not on a
consumer site.


Justin


on 23/09/02 1:03 AM, Murat . ([EMAIL PROTECTED]) wrote:

> hi,
> 
> is it possible to close client's browser's window from php script?
> 
> thanks...
> 
> 

--- End Message ---
--- Begin Message ---
I have a few application design questions that I was hoping someone
might have some thoughts on.  I'll warn you in advance that this post
is kinda long winded.  I'll try my best not to use two many trendy
buzzwords, but I may not be able to avoid it. :-)

I work for a real-estate company and one of the functions of our
website is to (obviously) allow customers to search our listings
database.  I currently have a fairly straightforward set of PHP pages
that accepts search criteria, constructs SQL queries, and then
displays the listing data.  For quite some time this was more than
sufficient for our needs.

Recently we added a new application to what we provide that allows
customers to sign up to receive new listing notifications based on a
certain set of search criteria.  I was charged with the responsibility
of creating this application.  I decided (for various reasons) to
implement this application in Perl.

As I was putting the Perl script together I realized that I was going
to have to duplicate all of the business logic that existed in my PHP
pages to build the SQL queries and display the results.  For example,
different listings have different rules for display.  Some bits of
information cannot be legally displayed based on the location the
listing is in.  All of this business logic was wrapped up tightly
inside my PHP pages, and I realized I was going to have to implement
it again in my Perl script.  Worse yet, I realized that if any of this
business logic changes (which it often does), I was going to have to
remember to change it in TWO places.  Up until this point there was
only the website, but now that I had two completely seperate
applications that I have to maintain whenever anything changes.

I realized at this point that I would be really nice if the business
logic that determines how to construct the queries and which bits of
data to display were completely seperated from the presentation logic
that existed in my PHP pages.  If I had some sort of component that
merely accepted search parameters and returned data then I could
access this component from both the PHP page and the Perl script.  If
the business logic changed later I could simply update the component
and I (theoretically speaking) wouldn't have to touch the PHP page or
the Perl script.

I've been doing research into this kind of application design.  From
my limited and inexperienced perspective, it does appear that
Microsoft does offer some advantages in this area.  But COM is not an
option for me, for several reasons, not the least of which is the fact
that our servers run Linux and I cannot access PHP's COM functions.

I have considered setting up a PHP page that runs on a seperate port.
This page would accept search criteria via a query string, and then
return listing data in XML format.  Then on the PHP presentation side
(or my Perl script), I would parse the XML and either display it
manually, or use XSLT.

I don't have a lot of experience with this, however.  It seems that
XML support in PHP is still in a state of infancy.  I'm aware of
Sablotron, and I have successfully compiled PHP with Sablotron
support. But I've read articles that the SAX implementation that PHP
employs is inferior that the DOM model.  I've also read that the PHP
developers are working on improving the support for XML and XSLT by
using libxslt instead of Sablotron in later versions.  After reading
all of this, it seems like the best thing to do is to wait a bit until
XML support in PHP solidifies a little more.

Also, I am concerned that the overhead of connecting via TCP (even if
on the same physical web server), having a page generate XML,
receiving the response, and then having to parse it back out again,
might impact peformance too severely.  On our website, the most
popular thing is searching listings.  If I drastically reduce
responsiveness by adding all of this overhead, then I've made things
easier for programmers, at the expense of the end user.

Another technology I was toying around with is Java servlets and Java
Beans.  I'm a complete newbie when it comes to this stuff too, but
from what I've read it seems that Java Beans are designed to wrap up
business logic in reusable components.  Money is an issue, however, so
if I implemented anything in Java I would have to use Apache's Tomcat,
and not one of the commercial Java platforms.  I realize this is
wildly off-topic for this list, but if anyone here has any experience
with Tomcat I'd appreciate any advice (off-list if necessary) as to
whether I'm barking up the wrong tree or not. :-)

Thanks in advance to any advice anyone can give...
--- End Message ---
--- Begin Message ---
Michael Sims wrote:

>Recently we added a new application to what we provide that allows
>customers to sign up to receive new listing notifications based on a
>certain set of search criteria.  I was charged with the responsibility
>of creating this application.  I decided (for various reasons) to
>implement this application in Perl.
>

I think this decision lies at the heart of your trouble.

>As I was putting the Perl script together I realized that I was going
>to have to duplicate all of the business logic that existed in my PHP
>pages to build the SQL queries and display the results.
>

And this is why.

>I realized at this point that I would be really nice if the business
>logic that determines how to construct the queries and which bits of
>data to display were completely seperated from the presentation logic
>that existed in my PHP pages.
>

Yes, this is exactly what you should do. Design (redesign?) your Web 
application with a more modular approach. Make your business logic in 
separate modules. There is no need to use a different language for this, 
however, especially since your business logic is probably simple 
decision making based on information from a database.

>I have considered setting up a PHP page that runs on a seperate port.
>

Don't forget that PHP has a CLI (command line interface). For example, 
create a script like this:

#! /usr/bin/php -q
<?
echo "PHP has a command line interface!";
?>

Make it executable and execute it, just like a Perl script.

Basically, it's really easy to create multiple interfaces to the same 
business logic. Don't try to make things more complicated than 
necessary, and since there is no need to use multiple languages in your 
implementation, that is a complexity worth avoiding.

If your Web application utilizes a modular design, then all your PHP 
script has to do is include the appropriate business logic from your Web 
application. Then, you can set it up with cron or whatever to decide who 
needs to be emailed what.

Happy hacking.

Chris

--- End Message ---
--- Begin Message ---
On 22 Sep 2002 at 10:23, Michael Sims wrote:

> of creating this application.  I decided (for various reasons) to
> implement this application in Perl.

I began programming in Perl back in 1995. Took up mod_perl (the only 
way to seriously use Perl btw on web apps) but as I work primarily on 
virtual servers mod_perl was just too sophisticated for most 
environments, so I settled for just Apache::Registry which would also 
run as plain cgi. Well  ... I've finally found a nice framework using 
PHP (using smarty.php.net) with Pear and then private classes for the 
App at hand. Works like a charm. I'm a fan of Perl but you can't beat 
PHP for ease of deployment and PHP does everying Perl does (all that I 
need) (although not all that mod_perl allows but then those conditions 
are pretty rare, for instance, like taking command at any of the apache 
request phases, especially good for custom auth stuff).

> in my Perl script.  Worse yet, I realized that if any of this business
> logic changes (which it often does), I was going to have to remember to
> change it in TWO places.  Up until this point there was only the
> website, but now that I had two completely seperate applications that I
> have to maintain whenever anything changes.

Oh yeah, avoid that at all costs. Sounds like something like SOAP etc. 
could have been an answer, but then it depends on how you write your 
apps. 

I write both Perl and PHP to manipulate data. Every function has input 
and output and those are just arrays. I ran into a similar problem with 
NUKE. My customer wanted me to allow a user to join via a multi-
newsletter module I was writing. Well I got it to work but it was not 
as easy as it should have been imho. I should have been able to call 
CreateNewUser and pass it the require input and gotten back a user id 
and then I could have called soemthing like GetUser and pass it a user 
id and get back an associative array (my pref) of that user. It was not 
like that, not at all, or I missed it. It seemed that the creation of a 
new user was tightly *coupled* with an html signup process. 


> I realized at this point that I would be really nice if the business
> logic that determines how to construct the queries and which bits of
> data to display were completely seperated from the presentation logic
> that existed in my PHP pages.  If I had some sort of component that
> merely accepted search parameters and returned data then I could access
> this component from both the PHP page and the Perl script.  If the
> business logic changed later I could simply update the component and I
> (theoretically speaking) wouldn't have to touch the PHP page or the Perl
> script.

Ummm .... like the other guy said, why bother? You can do that. Of 
course. But what are you doing in Perl that you cannot do in PHP? Maybe 
a cron script? I've not written any cron stuff in PHP and I'm not 
calling lynx to do it as I've seen advertised :( ... 


> I've been doing research into this kind of application design.  From my
> limited and inexperienced perspective, it does appear that Microsoft
> does offer some advantages in this area.  But COM is not an option for
> me, for several reasons, not the least of which is the fact that our
> servers run Linux and I cannot access PHP's COM functions.

SOAP, XML-RPC 

http://php.weblogs.com/xml-rpc

I just did a search on Google. I have not written anything along these 
lines but given XML you could write your own but I'd always go the 
public route if I were to do this. 

I'm reading an interesting book called "Software Architect Bootcamp" 
where components is the big word. It's interesting. I'm not sure if 
I've got a full grasp but it defintiely seems to have an emphasis on 
decoupling (something going back to I read about in McConnell who is 
very good).  But how to implement?  In the book I'm guilty of what he 
calls the Stovepipe System :( but I'm working on it.

> I have considered setting up a PHP page that runs on a seperate port.
> This page would accept search criteria via a query string, and then
> return listing data in XML format.  Then on the PHP presentation side
> (or my Perl script), I would parse the XML and either display it
> manually, or use XSLT.

> I don't have a lot of experience with this, however.  It seems that XML
> support in PHP is still in a state of infancy.  

I don't know about that. Works well for me. I take an Amazaon XML feed 
and run it through my smarty templates with no problem here:

http://www.readbrazil.com/books/amazon.php?mode=books

please note that above site has been more of a php playground than 
anything else.

No need to go the XSLT route although that is interesting. I use 
Template::Toolkit in Perl and have templates in html, xml, or plain 
text.

> the best thing to do is to wait a bit until XML support in PHP
> solidifies a little more.

I really don't now enough about this. Seem strong to me but I have'nt 
done much.

> Another technology I was toying around with is Java servlets and Java
> Beans.  I'm a complete newbie when it comes to this stuff too, but from
> what I've read it seems that Java Beans are designed to wrap up business
> logic in reusable components.  Money is an issue, however, so if I
> implemented anything in Java I would have to use Apache's Tomcat, and
> not one of the commercial Java platforms.  I realize this is wildly
> off-topic for this list, but if anyone here has any experience with
> Tomcat I'd appreciate any advice (off-list if necessary) as to whether
> I'm barking up the wrong tree or not. :-)

I think you can do all of this in PHP. But I don't think there is any 
easy answer. I have a website I work on now and then (using geeklog) 
http://www.smartarchitectures.com/ and I plan it to be about just what 
you are talking about. I don't think your question is really language 
specific. A lot of these books and what not are big on the strategic 
but then they leave the details out of the picture.

It sounds like to me you are looking for a framework. This what I 
looked for in PHP and I've got one now that is equal or better to my 
Perl framework. I use the same pattern I do in Perl. Isolate data 
manipulation, functions are the sort of "programming by contract" where 
functions expect input and return output. It gets messy when I have to 
handle errors ... I'm trying to componentize my stuff to decouple it 
all ... 

Peter
--- End Message ---
--- Begin Message ---
On Sun, 22 Sep 2002 11:31:17 -0500, you wrote:

>Basically, it's really easy to create multiple interfaces to the same 
>business logic. Don't try to make things more complicated than 
>necessary, and since there is no need to use multiple languages in your 
>implementation, that is a complexity worth avoiding.

Point well taken.  However, allow me to explain some things that I
left out of my original post:

I decided to go with Perl for a few different reasons.  First of all,
I wanted to get more comfortable working with Perl, mainly so I could
get exposed to languages other than PHP.  I had used Perl in the past,
but only for small tasks.  I saw this project as an opportunity to
pick up some useful Perl experience.

Another reason I went with Perl is because IMHO some of the tasks I
needed to accomplish are just easier done in Perl.  Part of the
functionality of my script is to parse incoming email and take
different actions based on it's content.  My script responds to
certain embedded commands (subscription confirmations, unsubscribe
requests, requests for automated help, etc.).  It also forwards
unknown commands to one set of addresses, while forwarding DSN's to
another set.  This means accepting the mail on STDIN and doing a lot
of regex parsing.  I know that this is more than possible in PHP, but
Perl just seems better suited to this type of task IMHO.

In retrospect it probably would have been better for me to implement
everything in PHP, from a modularization point of view.  I could have,
like you suggested, put all of my business logic in say a class, and
included that class from both my webpage and my mail script.  But that
would lock me in to using PHP for everything that needed access to
that business logic, so I'm still not sure that is the best
solution...

Thanks for the response...
--- End Message ---
--- Begin Message ---
On Sun, 22 Sep 2002 13:07:05 -0500, you wrote:

>Oh yeah, avoid that at all costs. Sounds like something like SOAP etc. 
>could have been an answer, but then it depends on how you write your 
>apps. 

Well, that is basically my question.  I considered both SOAP and
XML-RPC (which you mention later) but I wasn't sure what the impact on
performance would be.  I am basically looking for anecdotal evidence
from people who have implemented this sort of thing before...

>Ummm .... like the other guy said, why bother? You can do that. Of 
>course. But what are you doing in Perl that you cannot do in PHP? Maybe 
>a cron script? I've not written any cron stuff in PHP and I'm not 
>calling lynx to do it as I've seen advertised :( ... 

I answered him in a seperate post, but I'll repeat here:  I'm familiar
with writing standalone scripts in PHP.  I used Perl because for this
particular task it seemed better suited, and I wanted to get some more
Perl experience.  In retrospect it was probably not the wisest
decision, and I probably have made things more complicated than
necessary...

>> I don't have a lot of experience with this, however.  It seems that XML
>> support in PHP is still in a state of infancy.  
>
>I don't know about that. Works well for me. I take an Amazaon XML feed 
>and run it through my smarty templates with no problem here:
>
>http://www.readbrazil.com/books/amazon.php?mode=books
>
>please note that above site has been more of a php playground than 
>anything else.

That was just the impression that I picked up from my admittedly
limited research I did on XML support in PHP.  I was focusing mainly
on XSL transformations though.

Do you mind if I ask how exactly you are parsing the XML in your PHP
pages?  It seems to me that there are a few different options
available on www.php.net.  There is the --with-xml option that uses
expat, and then the DOM XML extension that is marked experimental.
I'm a real newbie when it comes to XML, but the DOM functions look a
little more attractive to me...

>It sounds like to me you are looking for a framework. This what I 
>looked for in PHP and I've got one now that is equal or better to my 
>Perl framework. 

Thanks for your response, you've given me some nice food for thought.
I've heard of Smarty several times before but never looked into it.  I
definitely will take a look at it now...
--- End Message ---
--- Begin Message ---
On 22 Sep 2002 at 13:52, Michael Sims wrote:

> Well, that is basically my question.  I considered both SOAP and
> XML-RPC (which you mention later) but I wasn't sure what the impact on
> performance would be.  I am basically looking for anecdotal evidence
> from people who have implemented this sort of thing before...

I was just looking at my software architect book ... not half-way 
through yet. Good book. CORBA is what is mentioned know, a bit 
different than SOAP but I don't know enough of either yet to say for 
sure.

> with writing standalone scripts in PHP.  I used Perl because for this
> particular task it seemed better suited, and I wanted to get some more
> Perl experience.  In retrospect it was probably not the wisest decision,
> and I probably have made things more complicated than necessary...

Personally, I think you were correct. I cannt imagine just doing 
everything with one tool. But how to write PHP and your Perl so they 
can talk to each other. Dunno. IDL, CORBA .... but as you say, it sure 
would be good to hear from someone who's been here already.


> >I don't know about that. Works well for me. I take an Amazaon XML feed
> >and run it through my smarty templates with no problem here:
> >
> >http://www.readbrazil.com/books/amazon.php?mode=books
> >
> >please note that above site has been more of a php playground than
> >anything else.
> 
> That was just the impression that I picked up from my admittedly
> limited research I did on XML support in PHP.  I was focusing mainly on
> XSL transformations though.

> Do you mind if I ask how exactly you are parsing the XML in your PHP
> pages?  It seems to me that there are a few different options available
> on www.php.net.  There is the --with-xml option that uses expat, and

Yes, I avoid XSL with the SABOLOTRON (or whatever it is) cus it's not 
in most virtual environments and that's a reason to use PHP over Perl, 
the ease of deployment. If I have my own box, heck, mod_perl is strong. 

Anyhow, I'm a lazy guy, avoid writing code at all costs :)

include_once ( 'AmazonLiteXMLParser.inc'); // 
include_once ( 'AmazonAPI.inc'); // 

written by Daniel Kushner

http://www.amazonlite.com/

And so my script is essentially this:

$xml  = new AmazonAPI();
$rxml = $xml-
>keywordSearch($input['keyword'],$input['mode'],$input['page']);

$parse  = new AmazonLiteXMLParser($rxml);
$records = $parse->getRecords();

for($i = 0; $i < sizeof($records); $i++) {
    for($inner = 0; $inner < sizeof($records[$i]['rating']); $inner++) 
{
        $records[$i]['reviews'][$inner]['summary'] = 
$records[$i]['summary'][$inner];
        $records[$i]['reviews'][$inner]['rating'] = 
$records[$i]['rating'][$inner];
        $records[$i]['reviews'][$inner]['comment'] = 
$records[$i]['comment'][$inner];
    }
    unset($records[$i]['summary']);
    unset($records[$i]['rating']);
    unset($records[$i]['comment']);
}

$smarty->assign("BookLoop",$records);
$smarty->assign($input);
$smarty->display('book_index.tpl');

And that's it.

> Thanks for your response, you've given me some nice food for thought.
> I've heard of Smarty several times before but never looked into it.  I
> definitely will take a look at it now...

If you continue to use Perl, look at Template::Toolkit. I use it for 
all sorts of things, everything, really nice. 


--- End Message ---
--- Begin Message ---
Hello,

On 09/22/2002 03:38 PM, Michael Sims wrote:
>>Basically, it's really easy to create multiple interfaces to the same 
>>business logic. Don't try to make things more complicated than 
>>necessary, and since there is no need to use multiple languages in your 
>>implementation, that is a complexity worth avoiding.
> 
> Point well taken.  However, allow me to explain some things that I
> left out of my original post:
> 
> I decided to go with Perl for a few different reasons.  First of all,
> I wanted to get more comfortable working with Perl, mainly so I could
> get exposed to languages other than PHP.  I had used Perl in the past,
> but only for small tasks.  I saw this project as an opportunity to
> pick up some useful Perl experience.

Good idea, bad project. It is good that you diversify your knowlegde if 
that helps your career but I think it is not a good idea to make 
technology shift in a project that is already written and working well 
in a certain language. I would say the same if the project was written 
in Perl and you wanted to change to PHP to diversify your knowledge.

I recommend that you do that in a low risk project that you can start 
from scratch. If you do the change now, chances are that you will face 
many difficulties and a lot more work than you could antecipate.


> Another reason I went with Perl is because IMHO some of the tasks I
> needed to accomplish are just easier done in Perl.  Part of the
> functionality of my script is to parse incoming email and take
> different actions based on it's content.  My script responds to
> certain embedded commands (subscription confirmations, unsubscribe
> requests, requests for automated help, etc.).  It also forwards
> unknown commands to one set of addresses, while forwarding DSN's to
> another set.  This means accepting the mail on STDIN and doing a lot
> of regex parsing.  I know that this is more than possible in PHP, but
> Perl just seems better suited to this type of task IMHO.

There is no evidence that is true. Maybe that is just your experience 
but doing what you mentioned in PHP is a day at the beach.

Reading from stdin is the same as reading from any file. Just use 
fopen("php://stdin","r") to get the file handle.

There are many ready to use components to parse complex e-mail if that 
is what you want. If you just need to use regular expressions, you can 
do that easily in PHP.

I can tell you that I do that myself in a site of mine and probably 
handling more complex situations like handling bounced newsletter 
messages. I do it all with PHP hands down. I do not see where Perl would 
be better.

Maybe that is my lack of Perl of experience compared to PHP experience, 
or your lack of PHP experience compared to your Perl experience.



> In retrospect it probably would have been better for me to implement
> everything in PHP, from a modularization point of view.  I could have,
> like you suggested, put all of my business logic in say a class, and
> included that class from both my webpage and my mail script.  But that
> would lock me in to using PHP for everything that needed access to
> that business logic, so I'm still not sure that is the best
> solution...

My opinion is that switching to Perl in the middle of a project that 
already works well in PHP would be a major mistake. You may want to try 
it and realize that yourself at the expense of loosing a lot of time and 
probably make your employer very nervous.

Regardless if you switch the language, you will always have trouble to 
split the business from the presentation logic from your PHP scripts. My 
advice is that you do that just splitting the logic in scripts that you 
really need to do that. Resist the temptation of doing that in all scripts.

Also, doing that and switching to a new language at the same time would 
make it worse. A sure recipe for disaster. Better safe than sorry.


-- 

Regards,
Manuel Lemos

--- End Message ---
--- Begin Message ---
On Sun, 22 Sep 2002 18:45:37 -0300, you wrote:

>Hello,

Hi Manuel...

>Good idea, bad project. It is good that you diversify your knowlegde if 
>that helps your career but I think it is not a good idea to make 
>technology shift in a project that is already written and working well 
>in a certain language.

True, I see that now.  I guess I should have sent my email to the
group BEFORE I started working on the project and not after. :-)

>> of regex parsing.  I know that this is more than possible in PHP, but
>> Perl just seems better suited to this type of task IMHO.
>
>There is no evidence that is true. 
[...]
>I can tell you that I do that myself in a site of mine and probably 
>handling more complex situations like handling bounced newsletter 
>messages.

Yeah, I'm actually on the phpclasses mailing list, so I think I know
what you are talking about. :-)

>Maybe that is my lack of Perl of experience compared to PHP experience, 
>or your lack of PHP experience compared to your Perl experience.

That is a factor, although I'm no Perl expert either...  Sometimes I
fall in a trap when it comes to projects...I start focusing on what
would be cool and fun to implement and sometimes I lose sight of
what's best for the project...

>My opinion is that switching to Perl in the middle of a project that 
>already works well in PHP would be a major mistake. You may want to try 
>it and realize that yourself at the expense of loosing a lot of time and 
>probably make your employer very nervous.

I'll be honest, I didn't forsee the duplicated business logic problem
(although I should have) until I was too far along with Perl to change
my mind.  I didn't lose any time, though.  It would have taken me
about the same amount of time to implement it in PHP, simply because I
had to learn a lot about email handling and MIME messages, etc.  These
were training issues that I had to get past that were not
language-specific.

I also have the advantage of having an employer who isn't a programmer
so is fairly oblivous to the details of implementation.  He's
basically an end user who tells me how he wants the program to
function and leaves it up to me to make it work.  This can be a big
advantage because I have almost absolute freedom to do what I want,
but it can also be a disadvantage because I sometimes get carried away
with all that freedom. :-)

>Regardless if you switch the language, you will always have trouble to 
>split the business from the presentation logic from your PHP scripts. My 
>advice is that you do that just splitting the logic in scripts that you 
>really need to do that. Resist the temptation of doing that in all scripts.

Ok.  It is hard to know when you are not abstracting and modularizing
things enough, and then when you are doing it too much.  Often I'll go
to extra work to make something scalable, and then we end up never
touching it again.  At other times I will bang something out quickly
thinking it's a one shot thing and then I find out it needs to be
expanded.  Ah well, I guess I shouldn't complain, it pays the bills...
:-)

Thanks for the response...
--- End Message ---
--- Begin Message ---
On Sun, 22 Sep 2002 16:40:06 -0500, you wrote:

>I was just looking at my software architect book ... not half-way 
>through yet. Good book. CORBA is what is mentioned know, a bit 
>different than SOAP but I don't know enough of either yet to say for 
>sure.

Something like CORBA looks good to me, although it's most likely over
my head at the moment.  It would probably offer the advantages of
SOAP/XML-RPC and do it without all of the overhead.  But PHP support
for CORBA looks to be pretty shaky.  The only reference I could find
was to Universe, but the website appears to be down:

http://universe.2good.nu/

>http://www.amazonlite.com/

Thanks for the pointer, I will check it out...

>If you continue to use Perl, look at Template::Toolkit. I use it for 
>all sorts of things, everything, really nice. 

I personally used HTML::Template, but I will take a look at that
module too...

Thanks again...
--- End Message ---
--- Begin Message ---
Hi,
Can someone tell me where I can find a PHP script
for tracking visitors on WEB site ( IP, Refferer, e.t.c )
(Like http://extremetracking.com )

Thanks,
Rosen



--- End Message ---
--- Begin Message ---
this is only going to return records in a table, and not in a database


> select count(*) as n from ... where ...
>
> -----Original Message-----
> From: Philip J. Newman [mailto:[EMAIL PROTECTED]]
>
> Can someone point me in the right direction to find out how i can return
the
> amount of records in a mysql databace ?
>


--- End Message ---
--- Begin Message ---
Look through the MySQL functions. I seem to recall that there is a 
function for just about anything, and all you really want to do is find 
how many rows are in all the tables in a particular database. Thus, a 
couple of loops is all you need, with the outer one looping through each 
table (obtained from a function) and the inner one doing a select 
count(*) or a mysql_num_rows().

Happy hacking.

Chris

Jeff Bluemel wrote:

>this is only going to return records in a table, and not in a database
>
>>select count(*) as n from ... where ...
>>
>>-----Original Message-----
>>From: Philip J. Newman [mailto:[EMAIL PROTECTED]]
>>
>>Can someone point me in the right direction to find out how i can return
>>
>the
>  
>
>>amount of records in a mysql databace ?
>>

--- End Message ---
--- Begin Message ---
<?php

$sql = "SELECT count(*) FROM stompers  WHERE 1";
$sql_result = mysql_query($sql, $connection) or die ("Could not get Query");

$row = mysql_fetch_array($sql_result);
$sUsers=$row["count(*)"];

echo "<br>We have <b>$sUsers</b> registered users.";

?>

This would be the best way (suggestions would be cool);



----- Original Message -----
From: "Mark Charette" <[EMAIL PROTECTED]>
To: "Philip J. Newman" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, September 23, 2002 1:28 AM
Subject: RE: [PHP] return the amount of records in a mysql databace


> select count(*) as n from ... where ...
>
> -----Original Message-----
> From: Philip J. Newman [mailto:[EMAIL PROTECTED]]
>
> Can someone point me in the right direction to find out how i can return
the
> amount of records in a mysql databace ?
>

--- End Message ---
--- Begin Message ---
Then do a SHOW DATABASES query before that and loop through the results,
counting the rows in each table. 

If you have to do this, though, I think you have some normalization
issues with your database...

---John Holmes...

> -----Original Message-----
> From: Jeff Bluemel [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 22, 2002 11:46 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] return the amount of records in a mysql databace
> 
> this is only going to return records in a table, and not in a database
> 
> 
> > select count(*) as n from ... where ...
> >
> > -----Original Message-----
> > From: Philip J. Newman [mailto:[EMAIL PROTECTED]]
> >
> > Can someone point me in the right direction to find out how i can
return
> the
> > amount of records in a mysql databace ?
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
i can do what i need on a command line with curl. but how would i do it in
php & curl?

this is my curl commands
curl -D hc -d "login=xxxxxx&password=xxxxxx&TYPE=login"
http://someserver.com/script/
curl -b hc -d "sendmsg=1&min=xxxxxxxx&message=test"
http://someserver.com/msgscript/

so really want i need is how do i specify with curl in php HOW TO RECORD
cookies?
and then how to RELAY them back..

cheers.

":B Nerdy" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> i wish to POST submit to a login form on another server and then after
that
> POST some more information on the resulting page.
>
> the thing is, after the first login, the website sends me a cookie. it
> probably holds the session id and or authentication information. how will
> can i relay this back to the page so i can view the resulting page without
> being kicked out because of no cookie??
>
> ive already used curl and am able to post things to scripts. but this
cookie
> problem i dont know how to get around.
>
> any idea?
> cheers
>
>
>


--- End Message ---
--- Begin Message ---
oh my god. here is an example.

$userLevels = array(
                    1 => 'Member', 
                    2 => 'Admin', 
                    4 => 'Writer', 
                    8 => 'Expert');

$cat = 15;
for ($mask=1; $mask <= 64; $mask *= 2) {
    if ( $mask & $cat ) {
        print "Yes $mask is in $cat\n<br>";
    }
} 

here i didn't have to 'or' the IDs but it works fine
and i didn't really understand how it works?
what does it mean "if 2 & 15, 2 can be found in
15"???!!! is that a miracle;)
thank you bob...


--- bob parker <[EMAIL PROTECTED]> wrote:
> On Sun, 22 Sep 2002 01:10, you wrote:
> 
> 1. To do that you should 'or' the categories when
> the ID's are
> to be in more than one category, not add them
> eg $category = $cat1 | $cat2;
> 
> 2. To extract the categories within a compounded
> category
> use the 'and' operator '&'
> 
> eg
> 
> for ($mask=1; $mask <= 64; /*or whatever*/ $mask *=
> 2; ) {
>       if ( $mask & $category ) {
>               print "Yes $mask is in $category\n";
>       }
> } 




original---
> > consider there are categories and these have IDs
> like
> > below:
> > 1, 2, 4, 8, 16, 32, 64...
> >
> > if some data belongs to more than 1 category for
> > exemple 4 and 32, its category ID will be 36, the
> sum
> > of cat. IDs.
> > i guess this is used widely in programming. so,
> how
> > can i resolve the original IDs. i mean what kind
> of
> > script can tell me what+what1+what2...whatN = 79?


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
--- End Message ---
--- Begin Message ---
$_GLOBAL["var"] or $_GLOBAL['var'] or $_GLOBAL[var] - I noticed that in
a mysql statement you can only use: $_GLOBAL[var].

I would like to get the advice of more experienced php programmers out
there about this. Which one of the above it the "most best" way to
write?
 
- Victor > www.argilent.com


______________________________________________________________________ 
Post your ad for free now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---


On 22 Sep 2002 at 12:10, Victor wrote:

> $_GLOBAL["var"] or $_GLOBAL['var'] or $_GLOBAL[var] - I noticed that in
> a mysql statement you can only use: $_GLOBAL[var].
> 
> I would like to get the advice of more experienced php programmers out
> there about this. Which one of the above it the "most best" way to
> write?

Yeah, this through me as well. Using Perl I got completely out of using 
quotes when not essential, still don't like em.  But the php.net site's 
got the answer:

http://www.php.net/manual/en/language.types.string.php

someone put a link to another good explanation:

http://www.zend.com/zend/tut/using-strings.php

And of course take care of the magic (imho, black magic) that can go on 
with auto escaping, quoting etc. that I should fathom but haven't. 

the php.net site is wealth of info, good search, I find 98% of my 
answers there.

Peter
--- End Message ---
--- Begin Message ---
Hi,

Read up on the image manipulation functions of PHP at 
http://www.php.net/manual/en/ref.image.php

You will need to install the GD library if it's not already installed and 
once you do you will have access to all the functions described, including 
the ImageCopyResized function. To read the image from disk, you will 
probably have to use ImageCreateFromGif or ImageCreateFromJpeg and to 
create the destination image you will need to use CreateImage. You can then 
save the resulting thumbnail using ImageGif, ImageJpeg or anything you like.

Just as a side note, you should probably use ImageCopyResampled which uses 
interpolation to resize the image, thus creating a thumbnail of much better 
quality.

HTH

Olivier

PS: to get the image's height and width, use ImagesY and ImagesX 
respectively, once you have opened/created the image.

At 18:09 2002-09-22 +0300, Kjell Hansen wrote:
>Hi,
>I'm using a Win2k with php4.1 and I'd like to make some thumbnails from
>pictures on my disk.
>I've gotten the impression that it's possible, but I havent' found out
>just how.
>
>I've stumbled across the ImageCopyResized function but it requires a
>imagehandle(?) to the file copied from. How do I get that? Is it the
>right way to do this?
>I guess I could use some picture manipulating program to do this, but
>doing it the PHP way is nicer :)
>
>TIA
>Kjell
>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
Not sure if this has been answered yet but since the new version of PHP,
I found that it doesn't like you entering the SQL statements in the
query tag directly. Here's what you should do.

$sql = "select password(".$_POST['password'].")"
$conn = **YOUR DATABASE CONNECTION**
$result = mysql_query($sql, $conn);
while ($p = mysql_fetch_array($result, MYSQL_ASSOC)):
  $pswrd=$p['password('.$_POST['password'].')'];
  endwhile;

Remember to replace **YOUR DATABASE CONNECTION** with, evidently, your
database connection. What I usually do is assign a function
(db_connect()) to connect to the database and select the database then
just put $conn = db_connect().

Hope that helps!

Thanks,
Stephen Craton
http://www.melchior.us
http://php.melchior.us

:: -----Original Message-----
:: From: Murat . [mailto:[EMAIL PROTECTED]] 
:: Sent: Sunday, September 22, 2002 7:23 AM
:: To: [EMAIL PROTECTED]
:: Subject: [PHP-DB] password function
:: 
:: 
:: hi,
:: i want to encode a string that users enter with mysql 
:: password function. but sometimes this code works sometimes 
:: don't. mysql warns me:
:: Warning: mysql_fetch_array(): supplied argument is not a 
:: valid MySQL result resource in ........
:: 
:: the code is:
:: 
:: $result=mysql_query("select password(".$_POST['password'].")");
::   while ($p = mysql_fetch_array($result, MYSQL_ASSOC)):
::   $pswrd=$p['password('.$_POST['password'].')'];
::   endwhile;
:: 
:: thanks...
:: 
:: 
:: 
:: -- 
:: PHP Database Mailing List (http://www.php.net/)
:: To unsubscribe, visit: http://www.php.net/unsub.php
:: 
:: 
:: 


--- End Message ---
--- Begin Message ---
I'm pretty sure they use cookies and see if the user is logged in or
not. I'm not sure how exactly to make the script though..

Thanks,
Stephen
http://www.melchior.us
http://php.melchior.us

:: -----Original Message-----
:: From: Andy [mailto:[EMAIL PROTECTED]] 
:: Sent: Saturday, September 21, 2002 6:46 PM
:: To: [EMAIL PROTECTED]
:: Subject: [PHP] counting guest users
:: 
:: 
:: Hi there,
:: 
:: I am wondering how some pages count guest users. An example 
:: is phpbb. They always know how many guest users are browsing 
:: the site. Are they using cookies or db for this, or both? 
:: Maybe there is a code snipped out for this already?
:: 
:: Thank you for any hint on that.
:: 
:: Andy
:: 
:: 
:: 
:: -- 
:: PHP General Mailing List (http://www.php.net/)
:: To unsubscribe, visit: http://www.php.net/unsub.php
:: 
:: 
:: 


--- End Message ---
--- Begin Message ---
Im running a dev box with IIS 5/Apache/php 4.1.2
I just noticed that part of a script that is supposed to delete a file 
isn't working under IIS but is under Apache.
Under IIS, php is installed as isapi.
Paths are correct, and the file in question is created by the script and 
according to the permissions, SYSTEM has full access to the file.
MARC and user notes under unlink() didn't reveal anything about why 
unlink() works for some and not for others.

Code snippet in question ->
--------------
$log = '../../includes/error/error.log';

    if (isset( $_POST['Reset'] ))
    {
        if (!unlink($log))
        {
            trigger_error('UNABLETORESETLOGFILE' , E_USER_WARNING );
        }
    }


Can anyone shed any light for me.
Thanks for any insight you may provide.

-- 
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/


--- End Message ---
--- Begin Message ---
Hi,

I am creating a kind of Shopsystem right now.

One of the Funktions is going to be the possibiliy that the page admin can set an 
customer status to 1 or 0
via an listing of all customers.

My Problem is, that I have to change more than one value at a time due to the Listing, 
where all
customers are listed in one big list.

So I have to write multiple values in to the database as Update.

I don't have a clue how to do this, the only thing i could do is
to make the change possible via an extrapage per customer,
but I'm not able to change all values at a time.

Would be nice if somebody would give me a hint.

Please excuse my english

Sascha Braun
--- End Message ---
--- Begin Message ---
Hello,

I was just wondering...again...why the heck I keep getting this error.
I'm trying to make a function called login() and sometimes it works,
other times it hates me and gives me this error:

Fatal error: Cannot redeclare login() in
c:\apache\htdocs\wiredphp\member\funcs.php on line 5

Here's the contents of the function login():

function login($username, $password)
{
  $sql = "select * from members where username='$username' and passwd =
password('$password')";
  $result = mysql_query($sql, $wired);
  if (!$result)
     return 0;
  
  if (mysql_num_rows($result)>0)
     return 1;
  else 
     return 0;
}

Please help. I don't see why this keeps happening...

Thanks,
Stephen
http://www.melchior.us
http://php.melchior.us


--- End Message ---
--- Begin Message ---
What does this error mean?

Warning: Wrong parameter count for mysql_query() 


Thanks

Randy


--- End Message ---
--- Begin Message ---
Hi Randy,

It means that you are calling the function without the right amount of
parameters. The function mysql_query expects at least 1 (one) paramter:
the query String.
http://www.php.net/manual/en/function.mysql-query.php

Regards,
Daniel Kushner
____________________________________
Need hosting? http://thehostingcompany.us




-----Original Message-----
From: Randy Johnson [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, September 22, 2002 2:26 PM
To: Paul Nicholson; Bryan McLemore; PHP GEN LIST
Subject: [PHP] What does this error mean


What does this error mean?

Warning: Wrong parameter count for mysql_query() 


Thanks

Randy



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




--- End Message ---
--- Begin Message ---
I found out what it was:

I mispelled a column in the insert statement.  it actually had nothing to do
with the parameters passed to the function  i passed $query and $link and
once i spelled the column right it went through just fine.   why would it
not just tell me that the column did not exist?

Randy
----- Original Message -----
From: "Daniel Kushner" <[EMAIL PROTECTED]>
To: "'Randy Johnson'" <[EMAIL PROTECTED]>; "'Paul Nicholson'"
<[EMAIL PROTECTED]>; "'Bryan McLemore'" <[EMAIL PROTECTED]>; "'PHP
GEN LIST'" <[EMAIL PROTECTED]>
Sent: Sunday, September 22, 2002 2:34 PM
Subject: RE: [PHP] What does this error mean


> Hi Randy,
>
> It means that you are calling the function without the right amount of
> parameters. The function mysql_query expects at least 1 (one) paramter:
> the query String.
> http://www.php.net/manual/en/function.mysql-query.php
>
> Regards,
> Daniel Kushner
> ____________________________________
> Need hosting? http://thehostingcompany.us
>
>
>
>
> -----Original Message-----
> From: Randy Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 22, 2002 2:26 PM
> To: Paul Nicholson; Bryan McLemore; PHP GEN LIST
> Subject: [PHP] What does this error mean
>
>
> What does this error mean?
>
> Warning: Wrong parameter count for mysql_query()
>
>
> Thanks
>
> Randy
>
>
>
> --
> 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
>


--- End Message ---
--- Begin Message ---
Hi,

Anyone know if it's possible to call a class function using 2 string
variables WITHOUT instantiating the class?

i.e.:

$clName = "myClass";
$fuName = "myFunc";

$clName::$fuName();

I have tried several different combinations of eval and {} and just
about everything else I can think of and they all give parse errors
when the class name is a string var. (i.e. myClass::$fuName() works fine
(as expected) but $clName::myFunc() does not).  Everytime it doesn't
work, it just gives a simple parse error.

Any suggested are much appreciated!

Thanks in advance!

//Nick Richardson
// [EMAIL PROTECTED]


---
Outgoing mail is certified Virus Free. Can McAfee do that? - Hell NO!
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.386 / Virus Database: 218 - Release Date: 9/9/2002
 
--- End Message ---
--- Begin Message ---
Nevermind, I have finally figured it out... I was missing a ; in the
eval statement.

For anyone who wanted to know, there's 2 ways...
1) the long way
$clName = "myClass";
$fuName = "myFunc";

$t = new $clName;
$t->$fuName();
unset($t);

2) the short way
$cl = "myClass";
$fu = "myFunc";

eval("$cl::$fu();");

-----Original Message-----
From: Nick Richardson [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, September 22, 2002 12:50 PM
To: 'PHP General'
Subject: [PHP] Calling class functions using string variables?


Hi,

Anyone know if it's possible to call a class function using 2 string
variables WITHOUT instantiating the class?

i.e.:

$clName = "myClass";
$fuName = "myFunc";

$clName::$fuName();

I have tried several different combinations of eval and {} and just
about everything else I can think of and they all give parse errors
when the class name is a string var. (i.e. myClass::$fuName() works fine
(as expected) but $clName::myFunc() does not).  Everytime it doesn't
work, it just gives a simple parse error.

Any suggested are much appreciated!

Thanks in advance!

//Nick Richardson
// [EMAIL PROTECTED]


---
Outgoing mail is certified Virus Free. Can McAfee do that? - Hell NO!
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.386 / Virus Database: 218 - Release Date: 9/9/2002
 

---
Outgoing mail is certified Virus Free. Can McAfee do that? - Hell NO!
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.386 / Virus Database: 218 - Release Date: 9/9/2002
 

--- End Message ---
--- Begin Message ---
Hi,

the following PHP script causes me trouble:


<?php
session_register("bunt");
phpinfo();
?>


This is just a simple example. The problem is that the script produces
no output at all when called with the browser. I could use


<?php
session_start();
echo "test";
?>


instead, but I won't get any output either.

Everything works as expected when session_start() or
session_register() are not used --- phpinfo() then says: Apache/1.3.22
(Unix) Debian/GNU PHP/4.1.0RC2.

Any help would be appreciated; thanks in advance!


GH
-- 
This mail is copyrighted material and must not be processed by
closed-source software.
--- End Message ---
--- Begin Message ---
On Mon, 23 Sep 2002 00:54:07 +0200, you wrote:

><?php
>session_register("bunt");
>phpinfo();
>?>
>
>This is just a simple example. The problem is that the script produces
>no output at all when called with the browser.

Is it possible that display_errors is set to "Off" in your php.ini?
If this were the case, perhaps a fatal error is occuring when you call
the session functions but you aren't seeing it because of the
display_errors setting...?
--- End Message ---
--- Begin Message ---
In HTML, you can do this:
<script language="JavaScript"
src="http://localhost/top_stuff.php?affiliate=1";></script>

But the script isn't executed before being used by the browser, it's
returned with PHP tags and all, which obviously gives JS errors. Is there
any setting you can change in Apache that let's you do this.


--- End Message ---
--- Begin Message ---
Georgie,

I'm not sure what you're wanting to do here, but it looks like you just 
want to use PHP to write some javascript. There's no need to make the 
browser request an additional page for this. Just do something like this 
in your PHP script:

<script language="javascript">
<?
    PHP stuff here - output is valid javascript
?>
</script>

or even:

<script language="javascript">
<?
include("/home/georgie/top_stuff.php");
?>
</script>

However, speaking directly to your problem, see what you see when you 
access that URL (http://localhost/top_stuff.php?affiliate=1) yourself. 
If your PHP scripts are not being processed and instead are just 
displayed in the browser, then your Web server is not configured to 
process PHP.

Happy hacking.

Chris

Georgie Casey wrote:

>In HTML, you can do this:
><script language="JavaScript"
>src="http://localhost/top_stuff.php?affiliate=1";></script>
>
>But the script isn't executed before being used by the browser, it's
>returned with PHP tags and all, which obviously gives JS errors. Is there
>any setting you can change in Apache that let's you do this.
>

--- End Message ---
--- Begin Message ---
The Javascript has to be called from other servers, some who might not even
support PHP. And yeah, when you actually visit the URL, it displays perfect
JavaScript

Thanks anyway
"Chris Shiflett" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Georgie,
>
> I'm not sure what you're wanting to do here, but it looks like you just
> want to use PHP to write some javascript. There's no need to make the
> browser request an additional page for this. Just do something like this
> in your PHP script:
>
> <script language="javascript">
> <?
>     PHP stuff here - output is valid javascript
> ?>
> </script>
>
> or even:
>
> <script language="javascript">
> <?
> include("/home/georgie/top_stuff.php");
> ?>
> </script>
>
> However, speaking directly to your problem, see what you see when you
> access that URL (http://localhost/top_stuff.php?affiliate=1) yourself.
> If your PHP scripts are not being processed and instead are just
> displayed in the browser, then your Web server is not configured to
> process PHP.
>
> Happy hacking.
>
> Chris
>
> Georgie Casey wrote:
>
> >In HTML, you can do this:
> ><script language="JavaScript"
> >src="http://localhost/top_stuff.php?affiliate=1";></script>
> >
> >But the script isn't executed before being used by the browser, it's
> >returned with PHP tags and all, which obviously gives JS errors. Is there
> >any setting you can change in Apache that let's you do this.
> >
>


--- End Message ---
--- Begin Message ---
Georgie,

Then what you're doing should work perfectly fine. Can you give more 
details about the error received?

The reason I ask is because a Web browser will submit the exact same 
request for that URL that you do when you type it in yourself. Thus, if 
you don't see any PHP code, neither should the browser when it tries to 
execute that as javascript.

Chris

Georgie Casey wrote:

>The Javascript has to be called from other servers, some who might not even
>support PHP. And yeah, when you actually visit the URL, it displays perfect
>JavaScript
>

--- End Message ---
--- Begin Message ---
Solved the problem.
In case anyones wondering,
I had the PHP script starting with a <script> and ending with </script> when
I already had that done in the HTML page.

Simple
"Georgie Casey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> In HTML, you can do this:
> <script language="JavaScript"
> src="http://localhost/top_stuff.php?affiliate=1";></script>
>
> But the script isn't executed before being used by the browser, it's
> returned with PHP tags and all, which obviously gives JS errors. Is there
> any setting you can change in Apache that let's you do this.
>
>


--- End Message ---
--- Begin Message ---
Georgie:

So just for clarity, this "PHP" script 
("http://localhost/top_stuff.php?affiliate=1";) was actually a file 
containing javascript? and no PHP?

And out of curiosity, if that is so, why append the file name with 
".php"

-David

On Sunday, September 22, 2002, at 07:20 PM, Georgie Casey wrote:

> Solved the problem.
> In case anyones wondering,
> I had the PHP script starting with a <script> and ending with 
> </script> when
> I already had that done in the HTML page.
>
> Simple
> "Georgie Casey" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> In HTML, you can do this:
>> <script language="JavaScript"
>> src="http://localhost/top_stuff.php?affiliate=1";></script>
>>
>> But the script isn't executed before being used by the browser, it's
>> returned with PHP tags and all, which obviously gives JS errors. Is 
>> there
>> any setting you can change in Apache that let's you do this.
>>
>>
>
>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
its cool. ive solved it..

there is an option in php curl to save the headers. i just feed that back
out. and it implements the cookies

cheers

":B Nerdy" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> i can do what i need on a command line with curl. but how would i do it in
> php & curl?
>
> this is my curl commands
> curl -D hc -d "login=xxxxxx&password=xxxxxx&TYPE=login"
> http://someserver.com/script/
> curl -b hc -d "sendmsg=1&min=xxxxxxxx&message=test"
> http://someserver.com/msgscript/
>
> so really want i need is how do i specify with curl in php HOW TO RECORD
> cookies?
> and then how to RELAY them back..
>
> cheers.
>
> ":B Nerdy" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > i wish to POST submit to a login form on another server and then after
> that
> > POST some more information on the resulting page.
> >
> > the thing is, after the first login, the website sends me a cookie. it
> > probably holds the session id and or authentication information. how
will
> > can i relay this back to the page so i can view the resulting page
without
> > being kicked out because of no cookie??
> >
> > ive already used curl and am able to post things to scripts. but this
> cookie
> > problem i dont know how to get around.
> >
> > any idea?
> > cheers
> >
> >
> >
>
>


--- End Message ---
--- Begin Message ---
Hello everybody,

Getting the following error when trying to generate a pdf file.

Fatal error: PDFlib error: function 'PDF_set_info' must not be called in
'object' scope in E:\php\pdf.php on line 6

>From what I can tell (google and php manual online) this error is caused
when your webserver (IIS 5 in this case) doesn't have write permissions to
the directory.

This is NOT the case here as far as I can tell.  Other scripts I run write
just fine and as seen in the below code, 'abc.txt' is written with no
problems before the script dies with the above error.

Any ideas?

-Peter

<?php
  $fp=fopen("abc.txt", "w");
  fwrite($fp, 'test');
  $pdf = pdf_new();
  pdf_open_file($pdf, "e:\php\test.pdf");
  pdf_set_info($pdf, "Author", "Uwe Steinmann");
  pdf_close($pdf);
  pdf_delete($pdf);
  echo "<A HREF=getpdf.php>finished</A>";
?>

##################################
Peter Thoenen - Systems Programmer
Commercial Communications
Camp Bondsteel, Kosovo
##################################

"Stumbled Upon"...heh (Score:5, Funny) /.
by $carab on 23:00 23 August 2002 (#4131637)

"ForensicTec officials said they stumbled upon the military networks about
two months ago, while checking on network security for a private-sector
client."

Someone new to a Dvorak probably tried to type in "lynx
http://www.google.com"; but instead got "nmap -v -p 1-1024 -sS -P0 army.mil
-T paranoid".
--- End Message ---
--- Begin Message ---
Hi,

I want to post a form and after parsing i want to redirect the user to the home page.

header() doesn't work in this circumstance, what can I do else?

Greetings

Sascha
--- End Message ---
--- Begin Message ---
I use....

<meta http-equiv="refresh" content="DELAY;url=http://place.to.redirect.to>

Todd.

----- Original Message -----
From: "Sascha Braun" <[EMAIL PROTECTED]>
To: "PHP Mailingliste" <[EMAIL PROTECTED]>
Sent: Monday, September 23, 2002 9:42 AM
Subject: [PHP] Redirection


Hi,

I want to post a form and after parsing i want to redirect the user to the
home page.

header() doesn't work in this circumstance, what can I do else?

Greetings

Sascha


--- End Message ---
--- Begin Message ---
Validate the input BEFORE outputting anything to the browser... this way you
have control over such problems.

<?
// validate
// code
// here


if($valid)
    {
    header(...);
    exit;
    }
?>
<HTML>
<?
if(!$valid)
    {
    echo "error on form";
    }
?>
</HTML>

The code below exit; will only be executed if the input was NOT valid....


Regards,

Justin




on 23/09/02 9:42 AM, Sascha Braun ([EMAIL PROTECTED]) wrote:

> Hi,
> 
> I want to post a form and after parsing i want to redirect the user to the
> home page.
> 
> header() doesn't work in this circumstance, what can I do else?
> 
> Greetings
> 
> Sascha
> 

--- End Message ---
--- Begin Message ---
Sascha Braun wrote:

>I want to post a form and after parsing i want to redirect the user to the home page.
>
>header() doesn't work in this circumstance, what can I do else?
>

header() does work in this circumstance. In what way do you think it 
doesn't?

header("Location: http://www.google.com/";);
exit;

Include that code "after parsing", and your users will be redirected to 
Google's Web site. I'm not aware of any Web client that does not support 
this, regardless of how old or uncommon.

Chris

--- End Message ---
--- Begin Message ---
You'd be hard pressed to find any difference in how the server reacts to
either.  You'll generally have better luck in some search engines if you
use example 2.  But onless you've got some strange reason hording
all of your code in one file, I can't imagine any reason why example
1 would be of any use / advantage.

On Sat, 21 Sep 2002 22:08:42 +0000, Matt Zur wrote:

> Here is the site and the file names:
> Test Site:
> - index.php
> - about.php
> - services.php
> 
> Which example would cause more stress on the server and/or what are the 
> advantages, disadvantages to each example?
> 
> Example 1
> -index.php with these links:
> <a href="index.php">Home</a>
> <a href="index.php?view=about">Home</a>
> <a href="index.php?view=services">Home</a>
> 
> With the index.php using a switch statment for the view var and file 
> includes.
> 
> OR
> 
> Example 2
> -index.php with these links:
> <a href="index.php">Home</a>
> <a href="about.php">Home</a>
> <a href="services.php">Home</a>
> 
> Any help will be appreciated.
> 
> -Matt

-- 
 Jason Morehouse (jm[@]netconcepts[.]com)
 Netconcepts - http://www.netconcepts.com
 Auckland, New Zealand
 Linux: Because rebooting is for adding hardware.

--- End Message ---
--- Begin Message ---
On 9/22/02 9:08 PM, "Jason Morehouse" <[EMAIL PROTECTED]> wrote:


>> Example 1
>> -index.php with these links:
>> <a href="index.php">Home</a>
>> <a href="index.php?view=about">Home</a>
>> <a href="index.php?view=services">Home</a>

> all of your code in one file, I can't imagine any reason why example
> 1 would be of any use / advantage.

That's easy! Modular site building.

Ever hear of Fusebox for PHP and ColdFusion (www.fusebox.org)? Corral for
Lasso (www.corralmethod.org)? These and other frameworks allow for rapid
construction of complex sites by reusing elements and conditionally doing
things on the fly! (among other stuff)

But you are correct, search engines tend to not think sites built this way
are very deep. So "alternate" URL coding should be considered in every case!

Good luck.


-- 
Bill Leonard                                           [EMAIL PROTECTED]
www.machinemen.com                                            407.464.0147

XrackHosting.com - Mac OS X hosting done right!
http://www.xrackhosting.com/



--- End Message ---
--- Begin Message ---
If i have a textarea form input for users and they enter in return spaces,
how can i replace the ascci chars with html tags?


--- End Message ---
--- Begin Message ---

On 21-Sep-2002 Patrick wrote:
> Hi,,
> 
> my server is located in the US and i live in Sweden, so when i try to run
> the following command i get a 8hour diffrence,, anyone got any idea of how
> to solve this?
> 
> date("Y-m-j")
> 
> 

putenv('TZ=Europe/Stockholm');
mktime(0,0,0,1,1,1970);
echo date("Y-m-j");

-- 
Don Read                                       [EMAIL PROTECTED]
-- "Beer is proof that God loves us and wants us to be happy."
--- End Message ---

Reply via email to