Re: [PHP] html forms class in php

2004-04-07 Thread Richard Harb
Then again you can just put the pear stuff into a subdirectory of your
project site / whatever.

for PHP 4 >= 4.3.0 you could have a look at:
http://www.php.net/manual/en/function.set-include-path.php

for older versions you can use ini_set (@see same url)
I've seen it done - works just as well. The pear libraries are PHP
code anyway, so it doesn't really have to be installed like
ImageMagick or TurckCache or something ...

hth

Richard

Thursday, April 8, 2004, 8:09:09 AM, you wrote:

> hi

> yesterday i posted a msg about wanting to know if it was a good idea to
> write a class that created/dealt with html forms and so on... somebody told
> me to go look at html_quick_forms class and it looks good like everything i
> would want to do but there is 1 problem: is there any classes for the same
> thing out there anybody knows of that does the same thing but doesnt require
> pear to be installed??

> i dont have access to pear on the servers i deal with and the admin refuse
> to install it...

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



Re: [PHP] very large and long if statement

2004-04-07 Thread Tyler Replogle
yeah well they are really close but i add a ")" on line 3





From: "Andy B" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: Re: [PHP] very large and long if statement
Date: Thu, 8 Apr 2004 02:03:38 -0400
i dont see any difference in the one you wrote and the one i wrote...they
seem to be exactly the same??
- Original Message -
From: "Tyler Replogle" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, April 07, 2004 9:43 PM
Subject: RE: [PHP] very large and long if statement
> hey,
> i don't know how to make it smaller but should it be
> if
> (!empty($_SESSION['add']['type'])
> && !empty($_SESSION['add']['start_date'])
> && !empty($_SESSION['add']['end_date'])
> && !empty($_SESSION['add']['name'])
> && !empty($_SESSION['add']['county'])
> && !empty($_SESSION['add']['discription'])
> && !empty($_SESSION['add']['StartingDay'])
> && !empty($_SESSION['add']['StartingMonth'])
> && !empty($_SESSION['add']['StartingYear'])
> && !empty($_SESSION['add']['EndingDay']})
> && !empty($_SESSION['add']['EndingMonth'])
> && !empty($_SESSION['add']['EndingYear']))
> {//run the insert query}
> else
> {//show error since one or more fields above are blank}
>
> ?
> >From: "Andy B" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Subject: [PHP] very large and long if statement
> >Date: Wed, 7 Apr 2004 18:47:02 -0400
> >
> >I have this very large and long if statement:
> >if
> >  (!empty($_SESSION['add']['type'])
> >  && !empty($_SESSION['add']['start_date']
> >  && !empty($_SESSION['add']['end_date'])
> >  && !empty($_SESSION['add']['name'])
> >  && !empty($_SESSION['add']['county'])
> >  && !empty($_SESSION['add']['discription'])
> >  && !empty($_SESSION['add']['StartingDay'])
> >  && !empty($_SESSION['add']['StartingMonth'])
> >  && !empty($_SESSION['add']['StartingYear'])
> >  && !empty($_SESSION['add']['EndingDay']})
> >  && !empty($_SESSION['add']['EndingMonth'])
> >  && !empty($_SESSION['add']['EndingYear']))
> >  {//run the insert query}
> >else
> >  {//show error since one or more fields above are blank}
> >was wondering if there was really any way to condense that down to
> >something
> >any better? all fields in the form that those came from are required...
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> _
> Watch LIVE baseball games on your computer with MLB.TV, included with 
MSN
> Premium!
>
http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/direct/01/
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Check out MSN PC Safety & Security to help ensure your PC is protected and 
safe. http://specials.msn.com/msn/security.asp

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


Re: [PHP] Exceptions and builtin functions in PHP5

2004-04-07 Thread daniel
> If I understand right, PHP5 has an exception
> handling mechanism but it is only for "manual" using, i.e.
> a programmer can use try/catch but only for own code.
> PHP's built-in functions and functions from extensions still
> use old "return value" method. Yes?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

I bloody hope not or what is the point ?

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



[PHP] html forms class in php

2004-04-07 Thread Andy B
hi

yesterday i posted a msg about wanting to know if it was a good idea to
write a class that created/dealt with html forms and so on... somebody told
me to go look at html_quick_forms class and it looks good like everything i
would want to do but there is 1 problem: is there any classes for the same
thing out there anybody knows of that does the same thing but doesnt require
pear to be installed??

i dont have access to pear on the servers i deal with and the admin refuse
to install it...

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



Re: [PHP] very large and long if statement

2004-04-07 Thread Andy B
i dont see any difference in the one you wrote and the one i wrote...they
seem to be exactly the same??

- Original Message - 
From: "Tyler Replogle" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, April 07, 2004 9:43 PM
Subject: RE: [PHP] very large and long if statement


> hey,
> i don't know how to make it smaller but should it be
> if
> (!empty($_SESSION['add']['type'])
> && !empty($_SESSION['add']['start_date'])
> && !empty($_SESSION['add']['end_date'])
> && !empty($_SESSION['add']['name'])
> && !empty($_SESSION['add']['county'])
> && !empty($_SESSION['add']['discription'])
> && !empty($_SESSION['add']['StartingDay'])
> && !empty($_SESSION['add']['StartingMonth'])
> && !empty($_SESSION['add']['StartingYear'])
> && !empty($_SESSION['add']['EndingDay']})
> && !empty($_SESSION['add']['EndingMonth'])
> && !empty($_SESSION['add']['EndingYear']))
> {//run the insert query}
> else
> {//show error since one or more fields above are blank}
>
> ?
> >From: "Andy B" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Subject: [PHP] very large and long if statement
> >Date: Wed, 7 Apr 2004 18:47:02 -0400
> >
> >I have this very large and long if statement:
> >if
> >  (!empty($_SESSION['add']['type'])
> >  && !empty($_SESSION['add']['start_date']
> >  && !empty($_SESSION['add']['end_date'])
> >  && !empty($_SESSION['add']['name'])
> >  && !empty($_SESSION['add']['county'])
> >  && !empty($_SESSION['add']['discription'])
> >  && !empty($_SESSION['add']['StartingDay'])
> >  && !empty($_SESSION['add']['StartingMonth'])
> >  && !empty($_SESSION['add']['StartingYear'])
> >  && !empty($_SESSION['add']['EndingDay']})
> >  && !empty($_SESSION['add']['EndingMonth'])
> >  && !empty($_SESSION['add']['EndingYear']))
> >  {//run the insert query}
> >else
> >  {//show error since one or more fields above are blank}
> >was wondering if there was really any way to condense that down to
> >something
> >any better? all fields in the form that those came from are required...
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> _
> Watch LIVE baseball games on your computer with MLB.TV, included with MSN
> Premium!
>
http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/direct/01/
>

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



[PHP] Exceptions and builtin functions in PHP5

2004-04-07 Thread Tumurbaatar S.
If I understand right, PHP5 has an exception
handling mechanism but it is only for "manual" using, i.e.
a programmer can use try/catch but only for own code.
PHP's built-in functions and functions from extensions still
use old "return value" method. Yes?

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



RE: [PHP] problems with md5()

2004-04-07 Thread jdavis
On Wed, 2004-04-07 at 22:59, Chris wrote:
> The second, longer, one is the correct one.
> 
> It looks like the column you've got the password stored in is too small, it
> must be 32 characters long
> 
> Chris
> 


On Wed, 2004-04-07 at 22:57, Jason Wong wrote:
>md5() returns a 32 character string so whatever is stored in your DB is 
>obviously truncated. Make sure the field holding the password is of 
>sufficient size/length.

>-- 
>Jason Wong -> Gremlins Associates -> www.gremlins.biz
>Open Source Software Systems Integrators
>* Web Design & Hosting * Internet & Intranet Applications Development *


thank you both so much , that was exactly the problem :)


thanks,
jd

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



Re: [PHP] problems with md5()

2004-04-07 Thread Richard Harb
could it be that the field in the database is of type
varchar(25) ?
looks like it's too small to hold the complete hash: that one always
consists of 32 characters.

Thursday, April 8, 2004, 6:35:47 AM, you wrote:

> hello,
>  I have a database containing usernames and md5 encrypted passwords.
> When i use md5() to encrypt a users password recived via a form
> to compare to the md5ed passwd in the database i get problems...

> for instance ...

> user foo has passwd 'pass' 
> 'pass' md5ed in database is this 

> 1a1dc91c907325c69271ddf0c

> i got this using phps md5.

> Then ... when i md5 a pass i recieve later to compare
> for a login the password 'pass' comes up like this...

> 1a1dc91c907325c69271ddf0c944bc72

> they are the same except the trailing 944bc72

> this happens when i try other password too.

> here is the code that is giving me the problems...

> function auth(){
>  $user = $_POST['user'];
>  $pass = rtrim($_POST['pass']);  // i added this trying to fix :(
>  $pass = md5($pass);  
>  $query = "select password from dealers where username = '$user'";
>  $result = $this->sqlQuery($query);
>  if(!$result){
>   echo "Sorry there was a error, please try again later.\n";
>  }
>  else{
>   $thePass = mysql_fetch_array($result);
>   if($thePass[0]){
>if(strcmp( $pass , $thePass[0]) == 0){
> echo "match\n";
>}
>else{
> echo "pass = $pass "; // from from   
> echo "hash = $thePass[0]";// from db  
>}
>   }
>   else{
>$this->logonPage(1);
>   }
>  }
> }



> can some one tell me what im doing wrong

> thanks,


> [EMAIL PROTECTED]

> "Bad spellers of the world untie!"




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



Re: [PHP] problems with md5()

2004-04-07 Thread Jason Wong
On Thursday 08 April 2004 12:35, jdavis wrote:
> hello,
>  I have a database containing usernames and md5 encrypted passwords.
> When i use md5() to encrypt a users password recived via a form
> to compare to the md5ed passwd in the database i get problems...
>
> for instance ...
>
> user foo has passwd 'pass'
> 'pass' md5ed in database is this
>
> 1a1dc91c907325c69271ddf0c
>
> i got this using phps md5.
>
> Then ... when i md5 a pass i recieve later to compare
> for a login the password 'pass' comes up like this...
>
> 1a1dc91c907325c69271ddf0c944bc72
>
> they are the same except the trailing 944bc72

md5() returns a 32 character string so whatever is stored in your DB is 
obviously truncated. Make sure the field holding the password is of 
sufficient size/length.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Most burning issues generate far more heat than light.
*/

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



RE: [PHP] problems with md5()

2004-04-07 Thread Chris
The second, longer, one is the correct one.

It looks like the column you've got the password stored in is too small, it
must be 32 characters long

Chris

-Original Message-
From: jdavis [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 07, 2004 9:36 PM
To: PHP List
Subject: [PHP] problems with md5()


hello,
 I have a database containing usernames and md5 encrypted passwords.
When i use md5() to encrypt a users password recived via a form
to compare to the md5ed passwd in the database i get problems...

for instance ...

user foo has passwd 'pass'
'pass' md5ed in database is this

1a1dc91c907325c69271ddf0c

i got this using phps md5.

Then ... when i md5 a pass i recieve later to compare
for a login the password 'pass' comes up like this...

1a1dc91c907325c69271ddf0c944bc72

they are the same except the trailing 944bc72

this happens when i try other password too.

here is the code that is giving me the problems...

function auth(){
 $user = $_POST['user'];
 $pass = rtrim($_POST['pass']);  // i added this trying to fix :(
 $pass = md5($pass);
 $query = "select password from dealers where username = '$user'";
 $result = $this->sqlQuery($query);
 if(!$result){
  echo "Sorry there was a error, please try again later.\n";
 }
 else{
  $thePass = mysql_fetch_array($result);
  if($thePass[0]){
   if(strcmp( $pass , $thePass[0]) == 0){
echo "match\n";
   }
   else{
echo "pass = $pass "; // from from
echo "hash = $thePass[0]";// from db
   }
  }
  else{
   $this->logonPage(1);
  }
 }
}



can some one tell me what im doing wrong

thanks,


[EMAIL PROTECTED]

"Bad spellers of the world untie!"

--
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] smarty

2004-04-07 Thread Jason Sheets
Some excellent points, however

Smarty makes it much easier to do certain tasks than doing it in strait PHP
and Smarty is extendable with PHP both directly and indirectly, you can
create Smarty modifiers and functions and if necessary write inline PHP
code.  

Web development has an hourly cost even when quoted per project, if I can
shave 2 hours of time off of a project I've saved the client $100 to $150 on
budget or increased my profit margin depending on the project and the
client.  Those two hours are also time that can be invested in polishing the
project or documenation, increasing the liklihood of an additional contract
with them.

Smarty is also open source so you aren't locked into a particular language,
if you don't like it you can change it or extend it easily.  You can change
quite a bit of its behavior including opening and closing delimiters, etc.

html_options is an excellent example of smarty functionality eliminating
several lines of code and several minutes of coding, sure you could
duplicate or implement the functionality in PHP but why re-invent the wheel.


Smarty also has the benefit of introducing template caching and some other
really powerful features that arne't available natively in PHP, you could
use some PEAR classes or other functionality or implement it yourself but
then you get into the whole re-inventing trap again.

In many ways Smarty helps turn PHP into an even faster rapid application
development platform for me resulting in more profit and a much more stable
platform to use for clients, resulting in fewer complaints and a lower
defect rate.

I think this conversation has resulted in quite a few good points on both
sides but has also exposed that most people already have a bias towards one
technique and are unlikely to be swayed to the other side until a business
need arises that forces it.

Jason

A really good example woul
-Original Message-
From: Justin French [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 07, 2004 9:02 PM
To: Kelly Hallman
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] smarty

On 08/04/2004, at 11:35 AM, Kelly Hallman wrote:

> Apr 8 at 10:26am, Justin French wrote:
>> PHP itself is a great templating language :)  
>>   
>>   
>>   > href='mailto:'>
>> 
>
> Uhhh, yeah--that's not a templating, that's called spaghetti code :)

I fail to see the difference in complexity.  Taking an example straight form
the smarty docs:


{section name=mysec loop=$users}
{strip}

   {$users[mysec].name}
   {$users[mysec].phone}

{/strip}
{/section}


Looks the same to me as:




   
   




(yes, I wrote a cycle() function in about 30 seconds)

> I guarantee another person not as adept at PHP will screw that code 
> up, and there is less potential for that with a Smarty template. If 
> you know PHP as well as yourself, it should be plain to see how Smarty 
> is just a wrapper over PHP that makes templates easier to build and 
> maintain.
> For a designer or non-coder, Smarty will be easier to learn than PHP.

Not in my experience.  Smarty lies somewhere in between a programming
language and pseudo tags... In *my* experience training template
designers...
{section name=mysec loop=$users}
was more confusing than:


Your mileage may vary, of course, but that's not my point.


> Unless your needs never exceed the very basics like you have 
> demonstrated above, you'll be hosed when another person needs to 
> modify your template.
> Which goes back to a templating truism never in dispute: if this is 
> all you want templating for, it's six of one, half a dozen of the other.
>
> However, there are practical limitations on what you can easily 
> accomplish with this approach, and Smarty addresses those issues. And 
> you're worse off if you invest a lot into building your sites this 
> way, and then realize you need some better templating strategies 
> later.

WHAT??? Are you suggesting that smarty templates are MORE EXTENSIBLE than
straight PHP???

This is exactly my point.  If you run with Smarty, you're LOCKED IN to that
language virtually forever.  Anything Smarty can do, I can replicate with
PHP (obviously), plus a whole heap more.  Smarty adds a layer of limitations
and simplicity to your templates, but at huge
cost:

You're locked into a proprietary templating language.  When that language
fails to deliver everything you want/need, you have no where to go.

A agree Smarty is fantastic at imposing limitations on it's templates, but
this is it's strength AND it's weakness.

> You can consider it it's own language, but really it's more like PHP 
> with different formatting. Which is why it's different than what 
> you're doing above--it's designed to facilitate templating. Your 
> method is just poking in variables and PHP into inline'd HTML. It 
> works, but you're missing some of the power of Smarty if you think 
> that's all it's good for.

I agree, there's more to smarty, but in the end, it's just an interface to
P

[PHP] problems with md5()

2004-04-07 Thread jdavis
hello,
 I have a database containing usernames and md5 encrypted passwords.
When i use md5() to encrypt a users password recived via a form
to compare to the md5ed passwd in the database i get problems...

for instance ...

user foo has passwd 'pass' 
'pass' md5ed in database is this 

1a1dc91c907325c69271ddf0c

i got this using phps md5.

Then ... when i md5 a pass i recieve later to compare
for a login the password 'pass' comes up like this...

1a1dc91c907325c69271ddf0c944bc72

they are the same except the trailing 944bc72

this happens when i try other password too.

here is the code that is giving me the problems...

function auth(){
 $user = $_POST['user'];
 $pass = rtrim($_POST['pass']);  // i added this trying to fix :(
 $pass = md5($pass);
 $query = "select password from dealers where username = '$user'";
 $result = $this->sqlQuery($query);
 if(!$result){
  echo "Sorry there was a error, please try again later.\n";
 }
 else{  
  $thePass = mysql_fetch_array($result);
  if($thePass[0]){
   if(strcmp( $pass , $thePass[0]) == 0){
echo "match\n";
   }
   else{
echo "pass = $pass "; // from from   
echo "hash = $thePass[0]";// from db  
   }
  }
  else{
   $this->logonPage(1);
  }
 }
}



can some one tell me what im doing wrong

thanks,


[EMAIL PROTECTED]

"Bad spellers of the world untie!"

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



Re: [PHP] smarty

2004-04-07 Thread Kelly Hallman
Apr 7 at 10:22pm, John W. Holmes wrote:
> > Uhhh, yeah--that's not templating, that's called spaghetti code :)
> 
> +1 - Use of buzzword

Right about here I could sense where this was going I don't know, what
would you call it? Is there a non-buzzword term you'd be happier with?  
That term predates PHP by a number of years, so I'm not sure about buzz...

> > For a designer or non-coder, Smarty will be easier to learn than PHP.
> 
> You must work with some real idiots.

Sigh... you must work with some really lousy designers!

> You can teach them to write {$variable} but you can't teach them to
> write  ?? Give your people some credit. If they can learn
> {section name="foo" loop=2 show=TRUE}{/section}, then they can learn
> for($x=0;$x<2;$x++){ }, can't they??

Sure, they could. However, take a look at all the newbie questions on this
list. Maybe you've got time for all that hand holding.. but Smarty is a
lot closer to HTML, which many of them already know.

> I'm sorry, but if Smarty takes your "template" and turns it into code 
> like the example above, EXACTLY what "limitations" are you going to run 
> into using the method above that Smarty solves?

How about the limitation of lack of infinite time? Seriously man, it's a
tool. If you think that I was claiming Smarty auto-magically did things
you couldn't do with PHP, you need to pay more attention...

> Fight it all you want, but PHP is a templating engine, too. That was 
> it's original purpose. And again, what "power" of Smarty are we missing 
> if Smarty just turns the template back into PHP code, anyhow?

Fight what? If you call inline code and variables a templating engine, I
can see why you don't get it. PHP can serve a templating purpose, but it
doesn't greatly facilitate that out of the box. It's not a strategy.

I don't want to get into a tit-for-tat, but there are a lot of things that
Smarty makes much easier and more flexible than coding straight PHP:

The ease of developing and applying different types of template plugins,
the ability to dynamically attach arbitrary functions as template plugins,
extending the Smarty class to encapsulate methods to control more complex 
template functionalities.. the list goes on..

Please read the next sentence twice. You can do it all with plain PHP, but
I can do it much faster with Smarty, which is merely a TOOL.

> > In other words: are your template designers already good PHP programmers?
> > It's not just hype, it solves real problems, even if you don't have them.
> 
> You can either teach your designers the Smarty language or you can teach 
> them PHP. Which one will set them up for success?

Again, very much not the point.

> Now, all that being said, I am a fan of Smarty and use it in some
> applications. But, there's no reason you can't use straight PHP and
> achieve the same results by simply separating presentation logic from
> your code.

It's clear you're just trying to be antagonistic, so I won't beleaguer the
point. I have a strong understanding of PHP, and I myself find Smarty
easier to work with from a template design standpoint.

Please feel free to call me a total idiot, question my intelligence,
belittle me or the people I work with, and other side topics relating to
the technical merits of Smarty or the use of templating systems.

I found it really educational and enriching.
Thanks for your contribution.


PS: I think this is tired at this point; thank you to Justin for a
thoughtful response that reassured me it was still a discussion. I realize
that many PHP 'experts' (let's call them) may find different solutions
that suit them differently. People have different levels and different
needs. I personally like Smarty, and Smarty was the original topic of the
thread. I'm open to ideas, but going back to mixing PHP and HTML is not a
new idea nor a true templating system, and there are valid reasons I
sought out a more comprehensive approaches after doing it that way for
many years. I found much benefit in Smarty, and hope others will too.

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



Re: [PHP] very large and long if statement

2004-04-07 Thread Richard Harb
Thursday, April 8, 2004, 3:59:39 AM, you wrote:

>> I have this very large and long if statement:
>> if
>>  (!empty($_SESSION['add']['type'])
>>  && !empty($_SESSION['add']['start_date']
>>  && !empty($_SESSION['add']['end_date'])
>>  && !empty($_SESSION['add']['name'])
>>  && !empty($_SESSION['add']['county'])
>>  && !empty($_SESSION['add']['discription'])
>>  && !empty($_SESSION['add']['StartingDay'])
>>  && !empty($_SESSION['add']['StartingMonth'])
>>  && !empty($_SESSION['add']['StartingYear'])
>>  && !empty($_SESSION['add']['EndingDay']})
>>  && !empty($_SESSION['add']['EndingMonth'])
>>  && !empty($_SESSION['add']['EndingYear']))
>>  {//run the insert query}



> As I understand it, !empty is redundant (at least, it's always worked for
> me, but I'm no expert).

In a perfect world you would be right, however if the var isn't set
then you'd get a notice (depending on your error reporting levels).

So I personally prefer to check against the !empty ...

---
That being said I have one more point to make:
Your if statement will fail if any  isn't satisfied. But you have no
way to tell which one was missing...

On pages where multiple fields are required I usually use something
like:

$errors = array();
$check_vars = array('type', 'start_date', 'end_date', ...);

foreach ($check_vars as $var) {
  if (empty($_SESSION['add']["$var"])) {
$errors[] = $var;
// or something like: $errors = get_error_desc_for($var);
// ... just making this up.
  }
}
if (count($errors)) {
  $output_errors = implode('', $errors);
} else {
  // run query
}

While I know that this contains a lot more code it's rather easy to
add another element to check against, and it allows me to pinpoint
exactly what's gone wrong ...

ok. not exactly what you asked for ... I was just in the mood :)

Richard

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



Re: [PHP] simple mysql_result() question

2004-04-07 Thread Richard Harb
Uhm .. I usually do:

SELECT COUNT(id) FROM users WHERE name='$username' AND
password='$password'

if (username is found)  // hopefully it's unique
  found ya
else
  sorry

This way you aleays have a value returned...

HTH

Richard

Thursday, April 8, 2004, 3:29:11 AM, you wrote:

> hello,
>  I am trying to authenticate users. I run this MySQL query using
> vars provided via a form

> select password from dealers where username = '$user'

> this works great if $user is actually a user in the database.
> otherwise i get this error

> Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3
> in /var/www/php/AuthTool.php on line 52

> its because of this

> $thePass = mysql_result($result,'0','password');

> is there a way to stop this error, should i be using mysql_fetch_array
> instead? Code below.

> Thanks,
> jd



> function auth(){
>  $user = $_POST['user'];
>  $pass = $_POST['pass'];
>  $query = "select password from dealers where username = '$user'";
>  $result = $this->sqlQuery($query);
>  if(!$result){
>   echo "Sorry there was a error\n";
>  }
>  else{
>   $thePass = mysql_result($result,'0','password');
>   if($thePass){
>echo "$thePass\n";
>   }
>   else{
>echo "no such user - $user\n";
>   }
>  }
> }
> -- 
> [EMAIL PROTECTED]

> "Bad spellers of the world untie!"

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



Re: [PHP] smarty

2004-04-07 Thread Justin French
On 08/04/2004, at 11:35 AM, Kelly Hallman wrote:

Apr 8 at 10:26am, Justin French wrote:
PHP itself is a great templating language :)



 


'>

Uhhh, yeah--that's not a templating, that's called spaghetti code :)
I fail to see the difference in complexity.  Taking an example straight 
form the smarty docs:


{section name=mysec loop=$users}
{strip}
   
  {$users[mysec].name}
  {$users[mysec].phone}
   
{/strip}
{/section}

Looks the same to me as:



   
  
  
   


(yes, I wrote a cycle() function in about 30 seconds)

I guarantee another person not as adept at PHP will screw that code up,
and there is less potential for that with a Smarty template. If you 
know
PHP as well as yourself, it should be plain to see how Smarty is just a
wrapper over PHP that makes templates easier to build and maintain.
For a designer or non-coder, Smarty will be easier to learn than PHP.
Not in my experience.  Smarty lies somewhere in between a programming 
language and pseudo tags... In *my* experience training template 
designers...
	{section name=mysec loop=$users}
was more confusing than:
	

Your mileage may vary, of course, but that's not my point.


Unless your needs never exceed the very basics like you have 
demonstrated
above, you'll be hosed when another person needs to modify your 
template.
Which goes back to a templating truism never in dispute: if this is all
you want templating for, it's six of one, half a dozen of the other.

However, there are practical limitations on what you can easily 
accomplish
with this approach, and Smarty addresses those issues. And you're worse
off if you invest a lot into building your sites this way, and then
realize you need some better templating strategies later.
WHAT??? Are you suggesting that smarty templates are MORE EXTENSIBLE 
than straight PHP???

This is exactly my point.  If you run with Smarty, you're LOCKED IN to 
that language virtually forever.  Anything Smarty can do, I can 
replicate with PHP (obviously), plus a whole heap more.  Smarty adds a 
layer of limitations and simplicity to your templates, but at huge 
cost:

You're locked into a proprietary templating language.  When that 
language fails to deliver everything you want/need, you have no where 
to go.

A agree Smarty is fantastic at imposing limitations on it's templates, 
but this is it's strength AND it's weakness.

You can consider it it's own language, but really it's more like PHP 
with
different formatting. Which is why it's different than what you're 
doing
above--it's designed to facilitate templating. Your method is just 
poking
in variables and PHP into inline'd HTML. It works, but you're missing 
some
of the power of Smarty if you think that's all it's good for.
I agree, there's more to smarty, but in the end, it's just an interface 
to PHP -- eventually you will hit the wall with the functionality that 
the interface allows.  Pure PHP templates however will only ever be 
limited by PHP itself.

In other words: are your template designers already good PHP 
programmers?
It's not just hype, it solves real problems, even if you don't have 
them.
As stated, this was not a problem for me, but it IS a problem for some. 
 Smarty is not a solution to every world problem.  It has it's place 
for sure, but I felt the need to point out that PHP alone is a great 
templating language, with limitless functionality.

It's up to the OP to take this thread and decide what he/she will do 
next.

---
Justin French
http://indent.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PDF Page Pulling

2004-04-07 Thread Evan Nemerson
http://marc.theaimsgroup.com/?l=php-general&m=107723910931417&w=2


On Wednesday 07 April 2004 05:53 pm, Jason Sheets wrote:
> I'd suggest taking a look at ghostscript it, it is available under AFPL and
> GPL licenses and offers the ability to convert individual pages to jpeg or
> other file formats.
>
> http://www.ghostscript.com
>
> Jason
>
>
> -Original Message-
> From: Adam Voigt [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 07, 2004 10:57 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] PDF Page Pulling
>
> I need to be able to pull a certain page out of a multi-page PDF, and then
> be able to save that single page to it's own PDF file.
>
> Anyone know how to do this with free tools?
>
> Thanks.
>
> --
>
> Adam Voigt
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php

-- 
Evan Nemerson
[EMAIL PROTECTED]
http://coeusgroup.com/en

--
"They that can give up essential liberty to obtain a little temporary safety 
deserve neither liberty nor safety."

-Benjamin Franklin

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



Re: [PHP] smarty

2004-04-07 Thread Kelly Hallman
Apr 7 at 10:01pm, Robert Cummings wrote:
> Smarty is a bit of a hack too... why do I need to declare my templates
> within the PHP code? If I'm an HTML designer I'd like to create a new
> page, include templates, use some data that's been made available and
> have it all in the template. I sure as heck wouldn't want to have joe
> programmer edit the main page, add support for importing my template.

I like Smarty because it solved many of the problems I was having trying
to tackle the problems manifest when using no templating strategy.

Actually, InterJinn has been on my radar screen for a while now, and 
thanks to your timely plug, I think I'll try it out and see how it 
compares. Incidentally, your posts on the Smarty list are what had me 
considering InterJinn in the first place.. how subversive of you! :)

I'm not married to Smarty, I just think that it's got a lot more to offer
than many PHP coders give it credit for after a mere cursory evaluation.  
Further, many of the people who shun templating systems aren't really
working with web applications as much as simple PHP scripts, where
templating solutions are much less necessary.

I think we're on the same side. Perhaps I just haven't yet seen the light.  
I'll give InterJinn a go. I hope it's all you say it is. One thing we can
both agree on is that templating is not inherently redundant with PHP.

--Kelly

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



Re: [PHP] smarty

2004-04-07 Thread John W. Holmes
Kelly Hallman wrote:
Apr 8 at 10:26am, Justin French wrote:

PHP itself is a great templating language :)



 


'>



Uhhh, yeah--that's not a templating, that's called spaghetti code :)
+1 - Use of buzzword

You get the concept. Smarty, as you know, basically takes a Smarty
template and writes PHP code similar to what you've done above, then
writes out the .php file, and includes it when you render your template.
So you'd get nearly the same effect by writing the PHP as a separate file
and including it as your last step, and it acts as your display logic.
That may be acceptable to you, as a PHP programmer. If you're the only one
who ever needs to modify your templates then that's great, more power to
you. I'm sure that you would have no problem having many levels of nesting
all over the place and not screwing anything up. So be it. But that's you.
I guarantee another person not as adept at PHP will screw that code up,
and there is less potential for that with a Smarty template. If you know
PHP as well as yourself, it should be plain to see how Smarty is just a
wrapper over PHP that makes templates easier to build and maintain.
For a designer or non-coder, Smarty will be easier to learn than PHP.
You must work with some real idiots. You can teach them to write 
{$variable} but you can't teach them to write  ?? Give 
your people some credit. If they can learn {section name="foo" loop=2 
show=TRUE}{/section}, then they can learn for($x=0;$x<2;$x++){ }, can't 
they??

However, there are practical limitations on what you can easily accomplish
with this approach, and Smarty addresses those issues. And you're worse
off if you invest a lot into building your sites this way, and then
realize you need some better templating strategies later.
I'm sorry, but if Smarty takes your "template" and turns it into code 
like the example above, EXACTLY what "limitations" are you going to run 
into using the method above that Smarty solves?

You can still separate your logic from your presentation, template 
designers can still use quick, simple "tags" to include code, and the 
upside is that people familiar with PHP don't need to learn ANOTHER 
language (that's what Smarty is) -- they can dive straight in.
You can consider it it's own language, but really it's more like PHP with
different formatting. Which is why it's different than what you're doing
above--it's designed to facilitate templating. Your method is just poking
in variables and PHP into inline'd HTML. It works, but you're missing some
of the power of Smarty if you think that's all it's good for.
Fight it all you want, but PHP is a templating engine, too. That was 
it's original purpose. And again, what "power" of Smarty are we missing 
if Smarty just turns the template back into PHP code, anyhow?

The question is, do you want to give your templater designers full 
access to the power of PHP, or not.


In other words: are your template designers already good PHP programmers?
It's not just hype, it solves real problems, even if you don't have them.
You can either teach your designers the Smarty language or you can teach 
them PHP. Which one will set them up for success?

Now, all that being said, I am a fan of Smarty and use it in some 
applications. But, there's no reason you can't use straight PHP and 
achieve the same results by simply separating presentation logic from 
your code.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] SMS from pc to mobile phone

2004-04-07 Thread saepudin
On Wednesday 07 April 2004 10:29, saepudin wrote:
> hi,
>  I want to send  an SMS(to mobile phone etc) based on a database trigger or
> on completion of an php page. the site runs on linux.
>  how to do this. How do i send the mobile no . what is the language,
> protocol, syntax and platform.
>  if anyone knows please inform. i am unable to
>  understand how to write the code so a sample code will be very welcome.
>  thanks a lot

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



Re: [PHP] smarty

2004-04-07 Thread Robert Cummings
On Wed, 2004-04-07 at 21:35, Kelly Hallman wrote:
> Apr 8 at 10:26am, Justin French wrote:
> > PHP itself is a great templating language :)
> > 
> > 
> > 
> >  
> > 
> > 
> > '>
> > 
> 
> Uhhh, yeah--that's not a templating, that's called spaghetti code :)
> 
> You get the concept. Smarty, as you know, basically takes a Smarty
> template and writes PHP code similar to what you've done above, then
> writes out the .php file, and includes it when you render your template.
> So you'd get nearly the same effect by writing the PHP as a separate file
> and including it as your last step, and it acts as your display logic.
> 
> That may be acceptable to you, as a PHP programmer. If you're the only one
> who ever needs to modify your templates then that's great, more power to
> you. I'm sure that you would have no problem having many levels of nesting
> all over the place and not screwing anything up. So be it. But that's you.
> 
> I guarantee another person not as adept at PHP will screw that code up,
> and there is less potential for that with a Smarty template. If you know
> PHP as well as yourself, it should be plain to see how Smarty is just a
> wrapper over PHP that makes templates easier to build and maintain.
> For a designer or non-coder, Smarty will be easier to learn than PHP.
>  
> Unless your needs never exceed the very basics like you have demonstrated
> above, you'll be hosed when another person needs to modify your template.  
> Which goes back to a templating truism never in dispute: if this is all
> you want templating for, it's six of one, half a dozen of the other.
> 
> However, there are practical limitations on what you can easily accomplish
> with this approach, and Smarty addresses those issues. And you're worse
> off if you invest a lot into building your sites this way, and then
> realize you need some better templating strategies later.
> 
> > You can still separate your logic from your presentation, template 
> > designers can still use quick, simple "tags" to include code, and the 
> > upside is that people familiar with PHP don't need to learn ANOTHER 
> > language (that's what Smarty is) -- they can dive straight in.
> 
> You can consider it it's own language, but really it's more like PHP with
> different formatting. Which is why it's different than what you're doing
> above--it's designed to facilitate templating. Your method is just poking
> in variables and PHP into inline'd HTML. It works, but you're missing some
> of the power of Smarty if you think that's all it's good for.
> 
> > The question is, do you want to give your templater designers full 
> > access to the power of PHP, or not.
> 
> In other words: are your template designers already good PHP programmers?
> It's not just hype, it solves real problems, even if you don't have them.

Smarty is a bit of a hack too... why do I need to declare my templates
within the PHP code? If I'm an HTML designer I'd like to create a new
page, include templates, use some data that's been made available and
have it all in the template. I sure as heck wouldn't want to have joe
programmer edit the main page, add support for importing my template.
This is the thing that bugs me about Smarty, its still got that hanging
dependency. And it's still got to include all those templates within the
source code.

InterJinn is superior in this respect. You use XML tags to import other
templates, you use XML tags to load modules and components, and you use
XML tags to do almost any kind of expansion you want. Of course, you can
go ahead and use something else, InterJinn provides the ability to plug
in custom compilers. InterJinn compiles to PHP code, includes are
INCLUDED at compile time not at run time. So given this scheme anyone
working on the HTML is already familiar with the syntax... hard to go
wrong with:



Hell you can even overload HTML tags. Not only that but Interjinn allows
recursive includes of templates and source files, and these includes can
be relative to the outer nested template or source file. Furthermore,
there's nothing forcing the use of the InterJinn application layer so
InterJinn can be used entirely for it's templating features, in which
case it provides a faster resulting PHP page than using PHP include().

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



RE: [PHP] very large and long if statement

2004-04-07 Thread Chris de Vidal
> I have this very large and long if statement:
> if
>  (!empty($_SESSION['add']['type'])
>  && !empty($_SESSION['add']['start_date']
>  && !empty($_SESSION['add']['end_date'])
>  && !empty($_SESSION['add']['name'])
>  && !empty($_SESSION['add']['county'])
>  && !empty($_SESSION['add']['discription'])
>  && !empty($_SESSION['add']['StartingDay'])
>  && !empty($_SESSION['add']['StartingMonth'])
>  && !empty($_SESSION['add']['StartingYear'])
>  && !empty($_SESSION['add']['EndingDay']})
>  && !empty($_SESSION['add']['EndingMonth'])
>  && !empty($_SESSION['add']['EndingYear']))
>  {//run the insert query}
> else
>  {//show error since one or more fields above are blank}
> was wondering if there was really any way to condense that down to
> something any better? all fields in the form that those came from are
> required...


Doubt you're going to make it smaller, but you can make it more readable.

As I understand it, !empty is redundant (at least, it's always worked for
me, but I'm no expert).  Plus the use of AND should make it more
human-readable, like so:
if ($_SESSION['add']['type']
AND $_SESSION['add']['start_date']
AND $_SESSION['add']['end_date']
AND $_SESSION['add']['name']
AND $_SESSION['add']['county']
AND $_SESSION['add']['discription']
AND $_SESSION['add']['StartingDay']
AND $_SESSION['add']['StartingMonth']
AND $_SESSION['add']['StartingYear']
AND $_SESSION['add']['EndingDay']
AND $_SESSION['add']['EndingMonth']
AND $_SESSION['add']['EndingYear'])
{//run the insert query}
else
{//show error since one or more fields above are blank}

Personally, I'd clean it up a tiny bit more:
$add = $_SESSION['add'];
if ($add['type']
AND $add['start_date']
...
{//show error since one or more fields above are blank}
unset ($add);

Again, I'm no expert, but hopefully that'll help.
/dev/idal

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



RE: [PHP] Cookies

2004-04-07 Thread Tyler Replogle
yes i do but here is a really good tutorial on it
http://www.phpfreaks.com/tutorials/120/0.php



From: "Wykis" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [PHP] Cookies
Date: Fri, 2 Apr 2004 16:52:23 +0100
Does Any One Knows How To Set And Get Cookies?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Persistent heartburn? Check out Digestive Health & Wellness for information 
and advice. http://gerd.msn.com/default.asp

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


RE: [PHP] very large and long if statement

2004-04-07 Thread Tyler Replogle
hey,
i don't know how to make it smaller but should it be
if
(!empty($_SESSION['add']['type'])
&& !empty($_SESSION['add']['start_date'])
&& !empty($_SESSION['add']['end_date'])
&& !empty($_SESSION['add']['name'])
&& !empty($_SESSION['add']['county'])
&& !empty($_SESSION['add']['discription'])
&& !empty($_SESSION['add']['StartingDay'])
&& !empty($_SESSION['add']['StartingMonth'])
&& !empty($_SESSION['add']['StartingYear'])
&& !empty($_SESSION['add']['EndingDay']})
&& !empty($_SESSION['add']['EndingMonth'])
&& !empty($_SESSION['add']['EndingYear']))
{//run the insert query}
else
{//show error since one or more fields above are blank}
?
From: "Andy B" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: [PHP] very large and long if statement
Date: Wed, 7 Apr 2004 18:47:02 -0400
I have this very large and long if statement:
if
 (!empty($_SESSION['add']['type'])
 && !empty($_SESSION['add']['start_date']
 && !empty($_SESSION['add']['end_date'])
 && !empty($_SESSION['add']['name'])
 && !empty($_SESSION['add']['county'])
 && !empty($_SESSION['add']['discription'])
 && !empty($_SESSION['add']['StartingDay'])
 && !empty($_SESSION['add']['StartingMonth'])
 && !empty($_SESSION['add']['StartingYear'])
 && !empty($_SESSION['add']['EndingDay']})
 && !empty($_SESSION['add']['EndingMonth'])
 && !empty($_SESSION['add']['EndingYear']))
 {//run the insert query}
else
 {//show error since one or more fields above are blank}
was wondering if there was really any way to condense that down to 
something
any better? all fields in the form that those came from are required...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Watch LIVE baseball games on your computer with MLB.TV, included with MSN 
Premium! 
http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/direct/01/

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


Re: [PHP] smarty

2004-04-07 Thread Kelly Hallman
Apr 8 at 10:26am, Justin French wrote:
> PHP itself is a great templating language :)
> 
> 
> 
>  
> 
> 
> '>
> 

Uhhh, yeah--that's not a templating, that's called spaghetti code :)

You get the concept. Smarty, as you know, basically takes a Smarty
template and writes PHP code similar to what you've done above, then
writes out the .php file, and includes it when you render your template.
So you'd get nearly the same effect by writing the PHP as a separate file
and including it as your last step, and it acts as your display logic.

That may be acceptable to you, as a PHP programmer. If you're the only one
who ever needs to modify your templates then that's great, more power to
you. I'm sure that you would have no problem having many levels of nesting
all over the place and not screwing anything up. So be it. But that's you.

I guarantee another person not as adept at PHP will screw that code up,
and there is less potential for that with a Smarty template. If you know
PHP as well as yourself, it should be plain to see how Smarty is just a
wrapper over PHP that makes templates easier to build and maintain.
For a designer or non-coder, Smarty will be easier to learn than PHP.
 
Unless your needs never exceed the very basics like you have demonstrated
above, you'll be hosed when another person needs to modify your template.  
Which goes back to a templating truism never in dispute: if this is all
you want templating for, it's six of one, half a dozen of the other.

However, there are practical limitations on what you can easily accomplish
with this approach, and Smarty addresses those issues. And you're worse
off if you invest a lot into building your sites this way, and then
realize you need some better templating strategies later.

> You can still separate your logic from your presentation, template 
> designers can still use quick, simple "tags" to include code, and the 
> upside is that people familiar with PHP don't need to learn ANOTHER 
> language (that's what Smarty is) -- they can dive straight in.

You can consider it it's own language, but really it's more like PHP with
different formatting. Which is why it's different than what you're doing
above--it's designed to facilitate templating. Your method is just poking
in variables and PHP into inline'd HTML. It works, but you're missing some
of the power of Smarty if you think that's all it's good for.

> The question is, do you want to give your templater designers full 
> access to the power of PHP, or not.

In other words: are your template designers already good PHP programmers?
It's not just hype, it solves real problems, even if you don't have them.

--Kelly

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



[PHP] Unsubscribe!!

2004-04-07 Thread Ken Heath
Please remove me from the mailing list.  Many different efforts has failed. 
:-(

I apology to everyone who receive this message.

_
Get rid of annoying pop-up ads with the new MSN Toolbar – FREE! 
http://toolbar.msn.com/go/onm00200414ave/direct/01/

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


[PHP] simple mysql_result() question

2004-04-07 Thread jdavis
hello,
 I am trying to authenticate users. I run this MySQL query using
vars provided via a form

select password from dealers where username = '$user'

this works great if $user is actually a user in the database.
otherwise i get this error

Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3
in /var/www/php/AuthTool.php on line 52

its because of this

$thePass = mysql_result($result,'0','password');

is there a way to stop this error, should i be using mysql_fetch_array
instead? Code below.

Thanks,
jd



function auth(){
 $user = $_POST['user'];
 $pass = $_POST['pass'];
 $query = "select password from dealers where username = '$user'";
 $result = $this->sqlQuery($query);
 if(!$result){
  echo "Sorry there was a error\n";
 }
 else{
  $thePass = mysql_result($result,'0','password');
  if($thePass){
   echo "$thePass\n";
  }
  else{
   echo "no such user - $user\n";
  }
 }
}
-- 
[EMAIL PROTECTED]

"Bad spellers of the world untie!"

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



Re: [PHP] Can someone with list access please remove these two?

2004-04-07 Thread Curt Zirzow
* Thus wrote Richard Davey ([EMAIL PROTECTED]):
> Hi,
> 
> Subject says it all - they're causing auto-responder junk to any list
> poster and it's annoying:
> 
> Information Desk <[EMAIL PROTECTED]>
> Advance Credit Suisse Bank <[EMAIL PROTECTED]>

Forwarding mail to [EMAIL PROTECTED] just gets rejected to :/

it seems that ipowerweb.com supports its clients to spam, even
though their Acceptable use policy says otherwise.  google tends to
agree with this theory.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



[PHP] Combining SimpleXML objects

2004-04-07 Thread Dan Phiffer
Another quickie: is there an easy way to combine SimpleXML objects?

Something Like:

$a = simplexml_load_string('');
$c = simplexml_load_string('Foo');
$a->b = $c->d;
print_r($a);
Here's what I get:

Warning: It is not possible to assign complex types to nodes in 
D:\...\test.php on line 5
simplexml_element Object ( [b] => simplexml_element Object ( ) )

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


RE: [PHP] PDF Page Pulling

2004-04-07 Thread Jason Sheets
I'd suggest taking a look at ghostscript it, it is available under AFPL and
GPL licenses and offers the ability to convert individual pages to jpeg or
other file formats.

http://www.ghostscript.com

Jason
 

-Original Message-
From: Adam Voigt [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 07, 2004 10:57 AM
To: [EMAIL PROTECTED]
Subject: [PHP] PDF Page Pulling

I need to be able to pull a certain page out of a multi-page PDF, and then
be able to save that single page to it's own PDF file. 

Anyone know how to do this with free tools?

Thanks.

-- 

Adam Voigt
[EMAIL PROTECTED]

--
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] smarty

2004-04-07 Thread Jason Sheets
I can see your point and have used this technique in very small applications
where the benefit of Smarty or other template engines are negated by the
performance/resource usage overhead.

However intermixing markup and PHP has introduced many problems in too many
PHP projects for me to use this technique in very many applications I have
to support.  Additionally the usage of mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 07, 2004 6:26 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] smarty

On 07/04/2004, at 1:33 AM, Angelo Zanetti wrote:

> hi all has anyone used smarty before? what do you think of it? I think 
> it's pretty nice to seperate your script (code) from your design.
>
> i would like to hear your comments and if you have any alternatives 
> let me know.

PHP itself is a great templating language :)





 


'>




You can still separate your logic from your presentation, template designers
can still use quick, simple "tags" to include code, and the upside is that
people familiar with PHP don't need to learn ANOTHER language (that's what
Smarty is) -- they can dive straight in.

The question is, do you want to give your templater designers full access to
the power of PHP, or not.  In my case, I did.


Justin

---
Justin French
http://indent.com.au

-- 
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: Adding a new entry using PHP

2004-04-07 Thread Justin Patrin
Alistair Hayward wrote:

Hi,

I am an ASP user, now learning PHP.

When adding a record in ASP, I do this:

Recordset.AddNew
Field1 = whatever
RecordSet.Update
How is this done in PHP?

I have built a recordset using a query, and have all the information 
needed to go into the different fields, but how do I 'Edit' or 'AddNew' 
and 'Update'?
This is what I have:



unset($price);
$price = $_GET['Price'];
unset($id);
$id = $_GET['id'];
unset($partnumber);
$partnumber = $_GET['PartNumber'];
unset($disc);
$disc = $_GET['Disc'];
$link = mysql_connect('localhost', 'root', 'password');
if (!$link) {
echo "Couldn't make a connection!";
exit;
}
$db = mysql_select_db("order", $link);
if (!$db) {
echo "Couldn't select database!";
exit;
}
$sql= "SELECT * FROM tborder WHERE sid='session.sessionid'";
$result = mysql_query($sql);
$total_records = mysql_num_rows($result);

?>
You need to do mysql_fetch_array() or associated methods to actually get 
your data back.

To update, use the UPDATE SQL syntax. To insert, use INSERT.

If you want a recordset, there are various packages in PEAR which might 
satisfy your needs.

http://pear.php.net

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


[PHP] Re: Password

2004-04-07 Thread Ligaya Turmelle
You have an error with your brackets.  Your code looks like this

 if (strlen($_POST['password1']) > 0)
{
 if ($_POST['password1'] ==($_POST['password2']
{
  $password = TRUE;
 }

 if (strlen($_POST['password1']) > 0)
{
if ($_POST['password1'] ==$_POST['password2'] ) <= your parenthesis here
was in the wrong place
{
   $password = TRUE;
 }
}<= and you forgot the closing bracket

Hope that helps.

Respectfully
Ligaya Turmelle

"Erik Gjertsen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I try to made a administrator page that I need to writ user name and
> password. But I have problem with the password. There comes one error
where
> I writ 1..(one)
> I have not made a table on MySql but in the book I read it scowl work.
> Can some one tell me why it not work.
> Here is the code:
>
>  if (isset($_POST['submit'])) { // Handel the form
>   // check for name
>if (strlen($_POST['name']) > 0) {
>$name = TRUE;
>  } else {
>$name = FALSE;
>echo 'you have forgot to enter your name';
>   }
>   // check for email adress
>  if (strlen($_POST['email']) > 0) {
>   $email = TRUE;
>  } else {
>   $email = FALSE;
>   echo 'you have forgot to enter your email adress';
>   }
>  // check for a usermame
>  if (strlen($_POST['usermame']) > 0) {
>   $usermame = TRUE;
>  } else {
>   $usermame = FALSE;
>   echo 'you have forgot to enter your usermame';
>   }
>
>  //check for a password and match against the comfirmed password.
>
>  if (strlen($_POST['password1']) > 0) {
> if ($_POST['password1'] ==
>($_POST['password2'] {
>  $password = TRUE;
>
> 1.. } else {
> $password = FALSE;
> echo ''
> }
>  } else {
>   $password = FALSE;
>   echo 'You forgot to enter your password!';
>  }
>  if ($name && $email && $username && $password)
>  { // if everyting's okayOK.
>   //Register the user.
>   echo 'you are now register.'
>   } else { //Something is not TRUE.
>   echo 'Please go back and try again.'
>  } else {
>
> ?>
>
>  
>  Enter your information in the form below
>  Name:  />
>  Email:  />
>  User name:  maxlength="40" />
>  Password:  maxlength="40" />
>  Confirm Password:  size="20" maxlength="40" />
>  
>   
>
>  
>
> Thanks fore any help
>
> Erik Gjertsen

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



Re: [PHP] smarty

2004-04-07 Thread Justin French
On 07/04/2004, at 1:33 AM, Angelo Zanetti wrote:

hi all has anyone used smarty before? what do you think of it? I think 
it's
pretty nice to seperate your script (code) from your design.

i would like to hear your comments and if you have any alternatives 
let me
know.
PHP itself is a great templating language :)





 


'>



You can still separate your logic from your presentation, template 
designers can still use quick, simple "tags" to include code, and the 
upside is that people familiar with PHP don't need to learn ANOTHER 
language (that's what Smarty is) -- they can dive straight in.

The question is, do you want to give your templater designers full 
access to the power of PHP, or not.  In my case, I did.

Justin

---
Justin French
http://indent.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Adding a new entry using PHP

2004-04-07 Thread Alistair Hayward
Hi,

I am an ASP user, now learning PHP.

When adding a record in ASP, I do this:

Recordset.AddNew
Field1 = whatever
RecordSet.Update
How is this done in PHP?

I have built a recordset using a query, and have all the information 
needed to go into the different fields, but how do I 'Edit' or 'AddNew' 
and 'Update'?
This is what I have:



unset($price);
$price = $_GET['Price'];
unset($id);
$id = $_GET['id'];
unset($partnumber);
$partnumber = $_GET['PartNumber'];
unset($disc);
$disc = $_GET['Disc'];
$link = mysql_connect('localhost', 'root', 'password');
if (!$link) {
echo "Couldn't make a connection!";
exit;
}
$db = mysql_select_db("order", $link);
if (!$db) {
echo "Couldn't select database!";
exit;
}
$sql= "SELECT * FROM tborder WHERE sid='session.sessionid'";
$result = mysql_query($sql);
$total_records = mysql_num_rows($result);

?>

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


[PHP] Re: Newbie question about operators

2004-04-07 Thread Ligaya Turmelle
it is refering to the associative array, specifically the $key => $value .
Note here (http://www.php.net/manual/en/language.types.array.php).

Respectfully,
Ligaya Turmelle

"Gabe" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Looking at the code below, what exactly is happening with the
$name=>$value
> part?  I looked in the PHP online documentation and I can't find that
> operator.  What is it doing exactly and what is it called?
>
> foreach ($some_array as $name=>$value)
> {
>  ... some code ...
> }
>
> Thanks alot!

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



Re: [PHP] Cookies

2004-04-07 Thread Larry E . Ullman
Does Any One Knows How To Set And Get Cookies?
The PHP manual is really good for stuff like this. Check out the 
setcookie() function.

Larry

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


Re: [PHP] path to binary for php on linux

2004-04-07 Thread Andy B
it was installed with get
and which php doesnt do anything just returns to the prompt with no output

- Original Message - 
From: "Curt Zirzow" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 07, 2004 8:11 PM
Subject: Re: [PHP] path to binary for php on linux


> * Thus wrote Andy B ([EMAIL PROTECTED]):
> > anybody know what the exact path for the php binary on linux is?
> 
> Depends on how it was installed, a common place is:
>   /usr/local/bin/php
> 
> Or you can type:
>   which php
> 
> and it will tell you where it is.
> 
> 
> Curt
> -- 
> "I used to think I was indecisive, but now I'm not so sure."
> 
> -- 
> 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] Cookies

2004-04-07 Thread Wykis
Does Any One Knows How To Set And Get Cookies?

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



[PHP] Re: stuck with simple query..... Plz have a look

2004-04-07 Thread Ligaya Turmelle
You need to do a join.

SELECT table1.ID AS PL_NAME, table1.ID AS PC_NAME, table1.ID AS PA_NAME FROM
table1, table2 WHERE (table2.PL =  table1.ID) AND (table2.PC = table1.ID)
and (table2.PA = table1.ID) ;

Or something like that.  Sorry I couldn't be of more help.

Respectfully,
Ligaya Turmelle

"Tariq Murtaza" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> We have two tables
>
> Table1:
> -
> ID |Name
> 
> 1   |name1
> 2   |name2
> 3   |name3
> 4   |name4
>
>
> Table2:
> --
-
> PL  |  PC   |PA| Description
> --
-
> 1|  2   |  4| Some description
> for Project 1
> 2|  3   |  1| Some description
> for Project 2
> 1|  2   |  4| Some description
> for Project 3
> 4|  1   |  3| Some description
> for Project 4
> 3|  1   |  4| Some description
> for Project 5
> 2|  3   |  1| Some description
> for Project 6
>
>
> I need the output like..
>
> --
---
> PL-Name|  PC-Name| PA-Name
> --
---
> name1 | name2   |name4
> name2 | name3   |name1
> name1 | name2   |name4
> name4 | name1   |name3
> name3 | name1   |name4
> name2 | name3   |name1
>
>
> Please guide me how can i achieve this kind of result set.
> Regards,
>
> Tariq
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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



Re: [PHP] path to binary for php on linux

2004-04-07 Thread Curt Zirzow
* Thus wrote Andy B ([EMAIL PROTECTED]):
> anybody know what the exact path for the php binary on linux is?

Depends on how it was installed, a common place is:
  /usr/local/bin/php

Or you can type:
  which php

and it will tell you where it is.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



[PHP] Re: APACHE

2004-04-07 Thread zerof
http://www.apache.org/foundation/mailinglists.html
-
zerof
-
"Wykis" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> Guys... I Think I Am In Wrong Place... But What  Is Address Of Apache
> Newsgroups? :)

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



[PHP] Re: stuck with simple query..... Plz have a look

2004-04-07 Thread Yayati Kasralikar
Try something like is:

select a.Name as PL_Name,b.Name as PC_Name,c.Name as PA_Name from
(select * from table1,table2 where table1.ID=table2.PL) a,
(select * from table1,table2 where table1.ID=table2.PC) b,
(select * from table1,table2 where table1.ID=table2.PA) c
where a.description=b.description and b.description=c.description
-Yayati

Tariq Murtaza wrote:

We have two tables

Table1:
-
ID |Name

1   |name1
2   |name2
3   |name3
4   |name4
Table2:
--- 

PL  |  PC   |PA| Description
--- 

1|  2   |  4| Some description 
for Project 1
2|  3   |  1| Some description 
for Project 2
1|  2   |  4| Some description 
for Project 3
4|  1   |  3| Some description 
for Project 4
3|  1   |  4| Some description 
for Project 5
2|  3   |  1| Some description 
for Project 6

I need the output like..

- 

PL-Name|  PC-Name| PA-Name
- 

name1 | name2   |name4
name2 | name3   |name1
name1 | name2   |name4
name4 | name1   |name3
name3 | name1   |name4
name2 | name3   |name1
Please guide me how can i achieve this kind of result set.
Regards,
Tariq

















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


[PHP] path to binary for php on linux

2004-04-07 Thread Andy B
anybody know what the exact path for the php binary on linux is?

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



Re: [PHP] Re: Administrator page and password problem

2004-04-07 Thread Red Wingate
Add this into the VERY last line :



[...]
 0) {
  $name = TRUE;
} else {
  $name = FALSE;
  echo 'you have forgot to enter your name';
 }
 // check for email adress
if (strlen($_POST['email']) > 0) {
 $email = TRUE;
} else {
 $email = FALSE;
 echo 'you have forgot to enter your email adress';
 }
// check for a usermame
if (strlen($_POST['usermame']) > 0) {
 $usermame = TRUE;
} else {
 $usermame = FALSE;
 echo 'you have forgot to enter your usermame';
 }
//check for a password and match against the comfirmed password.

if (strlen($_POST['password1']) > 0) {
   if ($_POST['password1'] ==
  ($_POST['password2'] {
1. $password = TRUE;
} else {
   $password = FALSE;
   echo ''
   }
} else {
 $password = FALSE;
 echo 'You forgot to enter your password!';
}
if ($name && $email && $username && $password)
{ // if everyting's okayOK.
 //Register the user.
 echo 'you are now register.'
 } else { //Something is not TRUE.
 echo 'Please go back and try again.'
} else {
?>


Enter your information in the form below
Name: 
Email: 
User name: 
Password: 
Confirm Password: 

 


[...]

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


Re: [PHP] Re: Dynamic method calling

2004-04-07 Thread Darren Beale
Justin Patrin wrote:

> For member fuctions:
> $a = 'nameOfMemberFunction';
> $this->$a();
Typically the only thing I didn't try

thanks++

Darren

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


Re: [PHP] PHP based Voice Chat Module

2004-04-07 Thread DvDmanDT
Hmm.. I'm pretty sure you can get Flash for Mac..

-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"Pushpinder Singh" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> Thanks Raditha,
>
>  Yes we are primarily looking at a PHP chat module which will allow
> us conduct an audio conference. I know there are Flash Voice Chat
> versions but they are all for Windoze... we are primarily a MAC
> environment and our hosting company uses LINUX.
>
> Please advise on the best course of action //  Thanks again
>
> --Pushpinder
>
>
>
>
> On Wednesday, April 7, 2004, at 12:06 PM, Raditha Dissanayake wrote:
>
> > Pushpinder Singh wrote:
> >
> >> Hello everyone,
> >>
> >>  I was wondering if anyone has used any PHP/MySQL based voice chat
> >> system. (for MAC OS X Platform)
> >
> > What kind of voice chat are you talking about? are you refering to one
> > user saying something into the microphone that the other users hears?
> > If so php is not the best way to do it.
> >
> >>
> >
> >
> > -- 
> > Raditha Dissanayake.
> > -
> > http://www.radinks.com/print/upload.php
> > SFTP, FTP and HTTP File Upload solutions
> > -- 
> > 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: Dynamic method calling

2004-04-07 Thread Justin Patrin
Darren Beale wrote:

Hi

I'm trying to dynamically choose and call a method from within a class 
but actually calling a method dynamically does not seem to work whatever 
I try using php 4.3.3

Hopefully this test script will illustrate my point better, I always get 
to the "I know we get to here" bit, but there is no other output.

Is what I want to achieve possible?

regs

Darren



class foo
{
var $lookup;

function foo()
{
$this->lookup  = array();
}

function getItem($entry)
{
if (!array_key_exists($entry, $this->lookup))
{
print "I know we get to here\r\n";
   
// random attempts at calling the 
relevant // method
   
$this->{"_foo_" . $entry . "()"};
   
$this->{"_foo_" . $entry};
   
$this->${"_foo_" . $entry . "()"};
   
$foo = "_foo_" . $entry . "()";
$this->$$foo;
   
$foo = "_foo_" . $entry;
$this->$$foo;
}
return $this->lookup[$entry];
}

function _foo_bar()
{   
print "bar\r\n";
$bar = 1;
$this->lookup["bar"] = $bar;
unset($bar);
}

function _foo_bar2()
{   
print "bar2\r\n";
$bar2 = 2;
$this->lookup["bar2"] = $bar2;
unset($bar2);
}
}

$foo = new foo();
print $foo->getItem("bar2");
?>
$$ is only for use when you're doing a regular var. In other cases you 
just add a $.

For instance, when accessing a member var, you use:
$this->a;
To access a dynamic one you use:
$a = 'nameOfVar';
$this->$a;
For member fuctions:
$a = 'nameOfMemberFunction';
$this->$a();
For functions:
$a = 'nameOfFunction';
$a();
--
paperCrane 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] very large and long if statement

2004-04-07 Thread Robert Cummings
On Wed, 2004-04-07 at 19:01, Justin Patrin wrote:
> Robert Cummings wrote:
> 
> > On Wed, 2004-04-07 at 18:47, Andy B wrote:
> > 
> >>I have this very large and long if statement:
> >>if
> >> (!empty($_SESSION['add']['type'])
> >> && !empty($_SESSION['add']['start_date']
> >> && !empty($_SESSION['add']['end_date'])
> >> && !empty($_SESSION['add']['name'])
> >> && !empty($_SESSION['add']['county'])
> >> && !empty($_SESSION['add']['discription'])
> >> && !empty($_SESSION['add']['StartingDay'])
> >> && !empty($_SESSION['add']['StartingMonth'])
> >> && !empty($_SESSION['add']['StartingYear'])
> >> && !empty($_SESSION['add']['EndingDay']})
> >> && !empty($_SESSION['add']['EndingMonth'])
> >> && !empty($_SESSION['add']['EndingYear']))
> >> {//run the insert query}
> >>else
> >> {//show error since one or more fields above are blank}
> >>was wondering if there was really any way to condense that down to something
> >>any better? all fields in the form that those came from are required...
> > 
> > 
> > $errors = array();
> > foreach( $_SESSION['add'] as $key => $value )
> > {
> > if( isempty( $value ) )
> > {
> > $errors[] = "You forgot to fill $key."
> > }
> > }
> > 
> > if( count( $array ) )
> > {
> > echo 'Hey MORON! You have the following errors:';
> > echo ''
> > .''
> > .implode( '', $errors );
> > .''
> > .'';
> > }
> > else
> > {
> > // Do SQL INSERT query.
> > }
> > 
> > Cheers,
> > Rob.
> 
> But if they didn't fill it in, it won't be in the array and therefore 
> won't be checked. You need to specify those keys manually.
> 
> foreach(array('type', 'start_date', etc...) as $key) {
>   if(empty($_SESSION['add'][$key])) {
>   $errors[] = $key.' not filled out';
>   }
> }

It was in the $_SESSION array, I assumed it was filled appropriately.
Also it isn't checkbox input (from what I can see) and other form fields
do provide an empty field when no content is input (if I'm not
mistaken).

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] Dynamic method calling

2004-04-07 Thread Darren Beale
Hi

I'm trying to dynamically choose and call a method from within a class 
but actually calling a method dynamically does not seem to work whatever 
I try using php 4.3.3

Hopefully this test script will illustrate my point better, I always get 
to the "I know we get to here" bit, but there is no other output.

Is what I want to achieve possible?

regs

Darren



class foo
{
var $lookup;

function foo()
{
$this->lookup  = array();
}
function getItem($entry)
{
if (!array_key_exists($entry, $this->lookup))
{
print "I know we get to here\r\n";

// random attempts at calling the relevant 
 // method

$this->{"_foo_" . $entry . "()"};

$this->{"_foo_" . $entry};

$this->${"_foo_" . $entry . "()"};

$foo = "_foo_" . $entry . "()";
$this->$$foo;

$foo = "_foo_" . $entry;
$this->$$foo;
}
return $this->lookup[$entry];
}
function _foo_bar()
{   
print "bar\r\n";
$bar = 1;
$this->lookup["bar"] = $bar;
unset($bar);
}
function _foo_bar2()
{   
print "bar2\r\n";
$bar2 = 2;
$this->lookup["bar2"] = $bar2;
unset($bar2);
}
}
$foo = new foo();
print $foo->getItem("bar2");
?>

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


Re: [PHP] PHP based Voice Chat Module

2004-04-07 Thread DvDmanDT
That's because he post to the newsgroup, Cc to the list, and the list system
automaticly sends one to you personally.. :p


-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"Raditha Dissanayake" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> Pushpinder, 1 message  is enough! (i recieved 6 messages from you 3
> copies each of two messages.)
> As as i said PHP is not the best option you will have to look at varius
> commercial voice chat systems. possibly on google.
>
>
>
>
>
> Pushpinder Singh wrote:
>
> > Sorry I did not answer your question in my earlier reply, Thats
> > right the user will use a headset and microphone to communicate.
> >
> > Thanks
> > Pushpinder
> >
> >
> >
> > On Wednesday, April 7, 2004, at 12:06 PM, Raditha Dissanayake wrote:
> >
> >>
> >> What kind of voice chat are you talking about? are you refering to
> >> one user saying something into the microphone that the other users
> >> hears? If so php is not the best way to do it.
> >
> >
>
>
> -- 
> Raditha Dissanayake.
> -
> http://www.radinks.com/print/upload.php
> SFTP, FTP and HTTP File Upload solutions

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



Re: [PHP] very large and long if statement

2004-04-07 Thread Justin Patrin
Robert Cummings wrote:

On Wed, 2004-04-07 at 18:47, Andy B wrote:

I have this very large and long if statement:
if
(!empty($_SESSION['add']['type'])
&& !empty($_SESSION['add']['start_date']
&& !empty($_SESSION['add']['end_date'])
&& !empty($_SESSION['add']['name'])
&& !empty($_SESSION['add']['county'])
&& !empty($_SESSION['add']['discription'])
&& !empty($_SESSION['add']['StartingDay'])
&& !empty($_SESSION['add']['StartingMonth'])
&& !empty($_SESSION['add']['StartingYear'])
&& !empty($_SESSION['add']['EndingDay']})
&& !empty($_SESSION['add']['EndingMonth'])
&& !empty($_SESSION['add']['EndingYear']))
{//run the insert query}
else
{//show error since one or more fields above are blank}
was wondering if there was really any way to condense that down to something
any better? all fields in the form that those came from are required...


$errors = array();
foreach( $_SESSION['add'] as $key => $value )
{
if( isempty( $value ) )
{
$errors[] = "You forgot to fill $key."
}
}
if( count( $array ) )
{
echo 'Hey MORON! You have the following errors:';
echo ''
.''
.implode( '', $errors );
.''
.'';
}
else
{
// Do SQL INSERT query.
}
Cheers,
Rob.
But if they didn't fill it in, it won't be in the array and therefore 
won't be checked. You need to specify those keys manually.

foreach(array('type', 'start_date', etc...) as $key) {
if(empty($_SESSION['add'][$key])) {
$errors[] = $key.' not filled out';
}
}
--
paperCrane 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] very large and long if statement

2004-04-07 Thread Robert Cummings
On Wed, 2004-04-07 at 18:47, Andy B wrote:
> I have this very large and long if statement:
> if
>  (!empty($_SESSION['add']['type'])
>  && !empty($_SESSION['add']['start_date']
>  && !empty($_SESSION['add']['end_date'])
>  && !empty($_SESSION['add']['name'])
>  && !empty($_SESSION['add']['county'])
>  && !empty($_SESSION['add']['discription'])
>  && !empty($_SESSION['add']['StartingDay'])
>  && !empty($_SESSION['add']['StartingMonth'])
>  && !empty($_SESSION['add']['StartingYear'])
>  && !empty($_SESSION['add']['EndingDay']})
>  && !empty($_SESSION['add']['EndingMonth'])
>  && !empty($_SESSION['add']['EndingYear']))
>  {//run the insert query}
> else
>  {//show error since one or more fields above are blank}
> was wondering if there was really any way to condense that down to something
> any better? all fields in the form that those came from are required...

$errors = array();
foreach( $_SESSION['add'] as $key => $value )
{
if( isempty( $value ) )
{
$errors[] = "You forgot to fill $key."
}
}

if( count( $array ) )
{
echo 'Hey MORON! You have the following errors:';
echo ''
.''
.implode( '', $errors );
.''
.'';
}
else
{
// Do SQL INSERT query.
}

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] very large and long if statement

2004-04-07 Thread Andy B
I have this very large and long if statement:
if
 (!empty($_SESSION['add']['type'])
 && !empty($_SESSION['add']['start_date']
 && !empty($_SESSION['add']['end_date'])
 && !empty($_SESSION['add']['name'])
 && !empty($_SESSION['add']['county'])
 && !empty($_SESSION['add']['discription'])
 && !empty($_SESSION['add']['StartingDay'])
 && !empty($_SESSION['add']['StartingMonth'])
 && !empty($_SESSION['add']['StartingYear'])
 && !empty($_SESSION['add']['EndingDay']})
 && !empty($_SESSION['add']['EndingMonth'])
 && !empty($_SESSION['add']['EndingYear']))
 {//run the insert query}
else
 {//show error since one or more fields above are blank}
was wondering if there was really any way to condense that down to something
any better? all fields in the form that those came from are required...

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



Re: [PHP] confused big time

2004-04-07 Thread Andy B

- Original Message - 
From: "Chris W. Parker" <[EMAIL PROTECTED]>
To: "Andy B" <[EMAIL PROTECTED]>
Sent: Wednesday, April 07, 2004 6:30 PM
Subject: RE: [PHP] confused big time


Andy B 
on Wednesday, April 07, 2004 2:09 PM said:

>> yes you can absolutely do it that way. in this case it's just >a
>> matter of preference. 
> 
> got it tnx
> 
> i think we can close this tread now

>ok. i hope i've been helpful.
sure arekeep up good work

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



[PHP] Re: Administrator page and password problem

2004-04-07 Thread Erik Gjertsen
Thanks for help Red.
Cut and past is not always wok
But I have a new problem in the last line.
I don't understand why it's problem here
Thanks
Erik Gjertsen


http://www.w3.org/TR/html4/loose.dtd";>
http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">


Black PHP script




 0) {
  $name = TRUE;
 } else {
  $name = FALSE;
  echo 'you have forgot to enter your name';
  }
 // check for email adress
 if (strlen($_POST["email"]) > 0) {
  $email = TRUE;
 } else {
  $email = FALSE;
  echo 'you have forgot to enter your email adress';
  }
 // check for a usermame
 if (strlen($_POST["usermame"]) > 0) {
  $usermame = TRUE;
 } else {
  $usermame = FALSE;
  echo 'you have forgot to enter your usermame';
  }

 //check for a password and match against the comfirmed password.

 if ( strlen ( $_POST['password1'] ) > 0 ) {
if ( $_POST['password1'] == $_POST['password2'] ) {
$password = TRUE ;
  } else {
$password = FALSE;
echo '';
  }
  } else {
   $password = FALSE;
   echo 'You forgot to enter your password!';
  }
  if ($name && $email && $username && $password)
  { // if everyting's okayOK.
  //Register the user.
  echo 'you are now register.';
  } else { //Something is not TRUE.
  echo 'Please go back and try again.';
  }
 } else {// Display the form
 ?>

 
 Enter your information in the form below
 Name: 
 Email: 
 User name: 
 Password: 
 Confirm Password: 
 
  

 

 
 

"Erik Gjertsen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I try to made a administrator page that I need to writ user name and
> password. But I have problem with the password. There comes one error
where
> I writ 1..(one)
> I have not made a table on MySql but in the book I read it scowl work.
> Can some one tell me why it not work.
> Here is the code:
>
>  if (isset($_POST['submit'])) { // Handel the form
>   // check for name
>if (strlen($_POST['name']) > 0) {
>$name = TRUE;
>  } else {
>$name = FALSE;
>echo 'you have forgot to enter your name';
>   }
>   // check for email adress
>  if (strlen($_POST['email']) > 0) {
>   $email = TRUE;
>  } else {
>   $email = FALSE;
>   echo 'you have forgot to enter your email adress';
>   }
>  // check for a usermame
>  if (strlen($_POST['usermame']) > 0) {
>   $usermame = TRUE;
>  } else {
>   $usermame = FALSE;
>   echo 'you have forgot to enter your usermame';
>   }
>
>  //check for a password and match against the comfirmed password.
>
>  if (strlen($_POST['password1']) > 0) {
> if ($_POST['password1'] ==
>($_POST['password2'] {
> 1. $password = TRUE;
>
>  } else {
> $password = FALSE;
> echo ''
> }
>  } else {
>   $password = FALSE;
>   echo 'You forgot to enter your password!';
>  }
>  if ($name && $email && $username && $password)
>  { // if everyting's okayOK.
>   //Register the user.
>   echo 'you are now register.'
>   } else { //Something is not TRUE.
>   echo 'Please go back and try again.'
>  } else {
>
> ?>
>
>  
>  Enter your information in the form below
>  Name:  />
>  Email:  />
>  User name:  maxlength="40" />
>  Password:  maxlength="40" />
>  Confirm Password:  size="20" maxlength="40" />
>  
>   
>
>  
>
> Thanks fore any help
>
> Erik Gjertsen

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



[PHP] Re: Administrator page and password problem

2004-04-07 Thread Erik Gjertsen
Thanks for help Red.
Cut and past is not always work
But I got a new problem in the last line.
I don't understand watt the problem is here

Thanks Erik Gjertsen

"Erik Gjertsen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I try to made a administrator page that I need to writ user name and
> password. But I have problem with the password. There comes one error
where
> I writ 1..(one)
> I have not made a table on MySql but in the book I read it scowl work.
> Can some one tell me why it not work.
> Here is the code:
>
>  if (isset($_POST['submit'])) { // Handel the form
>   // check for name
>if (strlen($_POST['name']) > 0) {
>$name = TRUE;
>  } else {
>$name = FALSE;
>echo 'you have forgot to enter your name';
>   }
>   // check for email adress
>  if (strlen($_POST['email']) > 0) {
>   $email = TRUE;
>  } else {
>   $email = FALSE;
>   echo 'you have forgot to enter your email adress';
>   }
>  // check for a usermame
>  if (strlen($_POST['usermame']) > 0) {
>   $usermame = TRUE;
>  } else {
>   $usermame = FALSE;
>   echo 'you have forgot to enter your usermame';
>   }
>
>  //check for a password and match against the comfirmed password.
>
>  if (strlen($_POST['password1']) > 0) {
> if ($_POST['password1'] ==
>($_POST['password2'] {
> 1. $password = TRUE;
>
>  } else {
> $password = FALSE;
> echo ''
> }
>  } else {
>   $password = FALSE;
>   echo 'You forgot to enter your password!';
>  }
>  if ($name && $email && $username && $password)
>  { // if everyting's okayOK.
>   //Register the user.
>   echo 'you are now register.'
>   } else { //Something is not TRUE.
>   echo 'Please go back and try again.'
>  } else {
>
> ?>
>
>  
>  Enter your information in the form below
>  Name:  />
>  Email:  />
>  User name:  maxlength="40" />
>  Password:  maxlength="40" />
>  Confirm Password:  size="20" maxlength="40" />
>  
>   
>
>  
>
> Thanks fore any help
>
> Erik Gjertsen

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



Re: [PHP] assigning NULL to a variable

2004-04-07 Thread Justin Patrin
Marek Kilimajer wrote:

William Lovaton wrote:

El mar, 06-04-2004 a las 07:41, Marek Kilimajer escribió:

Andy B wrote:

how would you assign NULL to a variable if its original value is ""? 
otherwise leave it with its value...


if($var === '') $var = NULL;


what about:  if ($var == '') unset($var);

No - NULL is not the same as unset() and the condition would evaluate to 
true even if $var === 0
And if $var = false or null or '0'

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


Re: [PHP] assigning NULL to a variable

2004-04-07 Thread Marek Kilimajer
William Lovaton wrote:
El mar, 06-04-2004 a las 07:41, Marek Kilimajer escribió:

Andy B wrote:

how would you assign NULL to a variable if its original value is ""? otherwise leave it with its value...
if($var === '') $var = NULL;


what about:  if ($var == '') unset($var);

No - NULL is not the same as unset() and the condition would evaluate to 
true even if $var === 0

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


Re: [PHP] Validating form field text input to be a specificvariable type

2004-04-07 Thread William Lovaton
Red, Chris,

Good advice, I rarely have to use it, though.


-William


El mi? 07-04-2004 a las 16:44, Chris Shiflett escribió:
> --- William Lovaton <[EMAIL PROTECTED]> wrote:
> > Yeah, sometimes this is an annoying problem with PHP. Somehow, "",
> > null, 0 and "0"  is the same thing.
> 
> You can always use === if you don't want it to cast.
> 
> Chris
> 
> =
> Chris Shiflett - http://shiflett.org/
> 
> PHP Security - O'Reilly
>  Coming Fall 2004
> HTTP Developer's Handbook - Sams
>  http://httphandbook.org/
> PHP Community Site
>  http://phpcommunity.org/

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



Re: [PHP] Re: session_exist() ?? Can this be done?

2004-04-07 Thread Jochem Maas
Jochem Maas wrote:

for those who haven't yet read it:

I meant to add a link above to a tutorial (which I later decided was 
rubbish!) - it was not meant to be some strange 'dis' to Monty.

BTW: if Monty is the Monty from Smarty fame: good on ya! :-)

Monty wrote:

Hi Red... Actually, I have my site set to only use cookies for storing
session ids to make it more secure and so that session ids aren't 
passed via



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


Re: [PHP] Re: Can someone with list access please remove these two?

2004-04-07 Thread Red Wingate
yep

William Lovaton wrote:

me too!

-William

El mi? 07-04-2004 a las 16:44, Justin Patrin escribió:

Richard Davey wrote:

Hi,

Subject says it all - they're causing auto-responder junk to any list
poster and it's annoying:
Information Desk <[EMAIL PROTECTED]>
Advance Credit Suisse Bank <[EMAIL PROTECTED]>
I second the motion!

--
paperCrane 


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


Re: [PHP] Re: Can someone with list access please remove these two?

2004-04-07 Thread William Lovaton
me too!

-William


El mi? 07-04-2004 a las 16:44, Justin Patrin escribió:
> Richard Davey wrote:
> > Hi,
> > 
> > Subject says it all - they're causing auto-responder junk to any list
> > poster and it's annoying:
> > 
> > Information Desk <[EMAIL PROTECTED]>
> > Advance Credit Suisse Bank <[EMAIL PROTECTED]>
> > 
> 
> I second the motion!
> 
> -- 
> paperCrane 

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



[PHP] Re: Hinding URL

2004-04-07 Thread Wykis
You Can try 

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



[PHP] Re: writing a class in php to print form elements

2004-04-07 Thread Justin Patrin
Andy B wrote:

hi...

is it totally usefull/reasonable to write a class in php that prints
different different form elements in html...
i.e. inputs, buttons, drop downs, multi selects and son? that way (at least
i think) then it would be easier to change the element attributes
dynamically...
Sure it is! But you may want to check out HTML_QuickForm from PEAR. It 
already does so much and there's lots of supporting classes there like 
DB_Databject_FormBuilder and HTML_QuickForm_Controller.

http://pear.php.net/package/HTML_QuickForm

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


Re: [PHP] Validating form field text input to be a specificvariable type

2004-04-07 Thread Chris Shiflett
--- William Lovaton <[EMAIL PROTECTED]> wrote:
> Yeah, sometimes this is an annoying problem with PHP. Somehow, "",
> null, 0 and "0"  is the same thing.

You can always use === if you don't want it to cast.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



[PHP] Re: Can someone with list access please remove these two?

2004-04-07 Thread Justin Patrin
Richard Davey wrote:
Hi,

Subject says it all - they're causing auto-responder junk to any list
poster and it's annoying:
Information Desk <[EMAIL PROTECTED]>
Advance Credit Suisse Bank <[EMAIL PROTECTED]>
I second the motion!

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


Re: [PHP] Validating form field text input to be a specificvariable type

2004-04-07 Thread Red Wingate
They are typecasted to match the current contexts needs - often a
problem but even - but this is one of PHPs strenghs :-)
 -- red

William Lovaton wrote:

Yeah, sometimes this is an annoying problem with PHP.  Somehow, "",
null, 0 and "0"  is the same thing.  The last two are considered empty()
too.
-William

El mi? 07-04-2004 a las 16:34, Red Wingate escribió:

JFYI :

var_dump ( '' == 0 ) eq TRUE

William Lovaton wrote:


I don't think so,

Wouldn't be better if ctype_digit() return false on an empty string??
any way an empty string is not a digit.
This change will brake backward compatibility so it is not an option.

if you look carefully the function that you propose is doing two things
at once... at this level this is not a good idea.
-William

El mi? 07-04-2004 a las 12:39, Red Wingate escribió:


No, as this would be yet another line of source. Maybe get those guys
to add another function
ctype_digit_and_not_empty();

-- red

[...]


* Thus wrote William Lovaton ([EMAIL PROTECTED]):


or modify is_numeric() to explictly perform an integer validation:
is_numeric(mixed value [, bool is_integer = false])
um.. ctype_digit().
Very nice! it works fine.  The only issue is that it will return true if
the parameter is an empty string ("").  Nothing that an empty() can't
fix.
[...]



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


[PHP] Password

2004-04-07 Thread Erik Gjertsen
I try to made a administrator page that I need to writ user name and
password. But I have problem with the password. There comes one error where
I writ 1..(one)
I have not made a table on MySql but in the book I read it scowl work.
Can some one tell me why it not work.
Here is the code:

 0) {
   $name = TRUE;
 } else {
   $name = FALSE;
   echo 'you have forgot to enter your name';
  }
  // check for email adress
 if (strlen($_POST['email']) > 0) {
  $email = TRUE;
 } else {
  $email = FALSE;
  echo 'you have forgot to enter your email adress';
  }
 // check for a usermame
 if (strlen($_POST['usermame']) > 0) {
  $usermame = TRUE;
 } else {
  $usermame = FALSE;
  echo 'you have forgot to enter your usermame';
  }

 //check for a password and match against the comfirmed password.

 if (strlen($_POST['password1']) > 0) {
if ($_POST['password1'] ==
   ($_POST['password2'] {
 $password = TRUE;

1.. } else {
$password = FALSE;
echo ''
}
 } else {
  $password = FALSE;
  echo 'You forgot to enter your password!';
 }
 if ($name && $email && $username && $password)
 { // if everyting's okayOK.
  //Register the user.
  echo 'you are now register.'
  } else { //Something is not TRUE.
  echo 'Please go back and try again.'
 } else {

?>

 
 Enter your information in the form below
 Name: 
 Email: 
 User name: 
 Password: 
 Confirm Password: 
 
  

 

Thanks fore any help

Erik Gjertsen

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



Re: [PHP] Validating form field text input to be a specificvariable type

2004-04-07 Thread William Lovaton
Yeah, sometimes this is an annoying problem with PHP.  Somehow, "",
null, 0 and "0"  is the same thing.  The last two are considered empty()
too.


-William


El mi? 07-04-2004 a las 16:34, Red Wingate escribió:
> JFYI :
> 
> var_dump ( '' == 0 ) eq TRUE
> 
> William Lovaton wrote:
> 
> > I don't think so,
> > 
> > Wouldn't be better if ctype_digit() return false on an empty string??
> > any way an empty string is not a digit.
> > 
> > This change will brake backward compatibility so it is not an option.
> > 
> > if you look carefully the function that you propose is doing two things
> > at once... at this level this is not a good idea.
> > 
> > 
> > -William
> > 
> > 
> > El mi? 07-04-2004 a las 12:39, Red Wingate escribió:
> > 
> >>No, as this would be yet another line of source. Maybe get those guys
> >>to add another function
> >>
> >>ctype_digit_and_not_empty();
> >>
> >> -- red
> >>
> >>[...]
> >>
> * Thus wrote William Lovaton ([EMAIL PROTECTED]):
> 
> >or modify is_numeric() to explictly perform an integer validation:
> >is_numeric(mixed value [, bool is_integer = false])
> 
> um.. ctype_digit().
> >>>
> >>>Very nice! it works fine.  The only issue is that it will return true if
> >>>the parameter is an empty string ("").  Nothing that an empty() can't
> >>>fix.
> >>
> >>[...]
> > 
> > 

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



Re: [PHP] Administrator page and password problem

2004-04-07 Thread Red Wingate
You mixed up here a little :-)

[...]
>  if (strlen($_POST['password1']) > 0) {
> if ($_POST['password1'] ==
>($_POST['password2'] {
> 1. $password = TRUE;
>
>  } else {
> $password = FALSE;
> echo ''
> }
>  } else {
>   $password = FALSE;
>   echo 'You forgot to enter your password!';
>  }
[...]
try :

if ( strlen ( $_POST['password1'] ) > 0 ) {
if ( $_POST['password1'] == $_POST['password2'] ) {
   $password = TRUE ;
} else {
   $password = FALSE;
   echo ''
}
} else {
$password = FALSE;
echo 'You forgot to enter your password!';
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] writing a class in php to print form elements

2004-04-07 Thread Andy B
hi...

is it totally usefull/reasonable to write a class in php that prints
different different form elements in html...

i.e. inputs, buttons, drop downs, multi selects and son? that way (at least
i think) then it would be easier to change the element attributes
dynamically...

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



[PHP] Administrator page and password problem

2004-04-07 Thread Erik Gjertsen
I try to made a administrator page that I need to writ user name and
password. But I have problem with the password. There comes one error where
I writ 1..(one)
I have not made a table on MySql but in the book I read it scowl work.
Can some one tell me why it not work.
Here is the code:

 0) {
   $name = TRUE;
 } else {
   $name = FALSE;
   echo 'you have forgot to enter your name';
  }
  // check for email adress
 if (strlen($_POST['email']) > 0) {
  $email = TRUE;
 } else {
  $email = FALSE;
  echo 'you have forgot to enter your email adress';
  }
 // check for a usermame
 if (strlen($_POST['usermame']) > 0) {
  $usermame = TRUE;
 } else {
  $usermame = FALSE;
  echo 'you have forgot to enter your usermame';
  }

 //check for a password and match against the comfirmed password.

 if (strlen($_POST['password1']) > 0) {
if ($_POST['password1'] ==
   ($_POST['password2'] {
1. $password = TRUE;

 } else {
$password = FALSE;
echo ''
}
 } else {
  $password = FALSE;
  echo 'You forgot to enter your password!';
 }
 if ($name && $email && $username && $password)
 { // if everyting's okayOK.
  //Register the user.
  echo 'you are now register.'
  } else { //Something is not TRUE.
  echo 'Please go back and try again.'
 } else {

?>

 
 Enter your information in the form below
 Name: 
 Email: 
 User name: 
 Password: 
 Confirm Password: 
 
  

 

Thanks fore any help

Erik Gjertsen

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



Re: [PHP] Validating form field text input to be a specificvariable type

2004-04-07 Thread Red Wingate
JFYI :

var_dump ( '' == 0 ) eq TRUE

William Lovaton wrote:

I don't think so,

Wouldn't be better if ctype_digit() return false on an empty string??
any way an empty string is not a digit.
This change will brake backward compatibility so it is not an option.

if you look carefully the function that you propose is doing two things
at once... at this level this is not a good idea.
-William

El mi? 07-04-2004 a las 12:39, Red Wingate escribió:

No, as this would be yet another line of source. Maybe get those guys
to add another function
ctype_digit_and_not_empty();

-- red

[...]

* Thus wrote William Lovaton ([EMAIL PROTECTED]):

or modify is_numeric() to explictly perform an integer validation:
is_numeric(mixed value [, bool is_integer = false])
um.. ctype_digit().
Very nice! it works fine.  The only issue is that it will return true if
the parameter is an empty string ("").  Nothing that an empty() can't
fix.
[...]


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


Re: [PHP] Validating form field text input to be a specificvariable type

2004-04-07 Thread William Lovaton
I don't think so,

Wouldn't be better if ctype_digit() return false on an empty string??
any way an empty string is not a digit.

This change will brake backward compatibility so it is not an option.

if you look carefully the function that you propose is doing two things
at once... at this level this is not a good idea.


-William


El mi? 07-04-2004 a las 12:39, Red Wingate escribió:
> No, as this would be yet another line of source. Maybe get those guys
> to add another function
> 
> ctype_digit_and_not_empty();
> 
>  -- red
> 
> [...]
> > > * Thus wrote William Lovaton ([EMAIL PROTECTED]):
> > > > or modify is_numeric() to explictly perform an integer validation:
> > > > is_numeric(mixed value [, bool is_integer = false])
> > >
> > > um.. ctype_digit().
> >
> > Very nice! it works fine.  The only issue is that it will return true if
> > the parameter is an empty string ("").  Nothing that an empty() can't
> > fix.
> [...]

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



Re: [PHP] Newbie question about operators

2004-04-07 Thread Red Wingate
arrays :-)

you are defining arrays like:

$x = array ( 'a' => 'Apple' , 'b' => 'Banana' , ... );

 -- red

Gabe wrote:

Thanks for the page.  That was helpful.  Just to make sure, is that
operator only typically used then with foreach loops and arrays?
"Matt Matijevich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
[snip]
foreach ($some_array as $name=>$value)
{
... some code ...
}
[/snip]
http://www.php.net/foreach

will give you a good explanation.


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


Re: [PHP] Newbie question about operators

2004-04-07 Thread Gabe
Thanks for the page.  That was helpful.  Just to make sure, is that
operator only typically used then with foreach loops and arrays?


"Matt Matijevich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> [snip]
> foreach ($some_array as $name=>$value)
> {
>  ... some code ...
> }
> [/snip]
>
> http://www.php.net/foreach
>
> will give you a good explanation.

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



Re: [PHP] OOP Question

2004-04-07 Thread Robert Cummings
On Wed, 2004-04-07 at 17:07, Richard Lewis wrote:
> What do members think that this code should do:
> 
> class A
> {
>   var $a, $b;
>   function A($a)
>   {
> $this->$a = $a;
>   }
>   function prnt()
>   {
> echo "a=" . $this->$a;
>   }
> }
> 
> class B extends A
> {
>   function B($a, $b)
>   {
> parent::A($a);
> $this->$b = $b;
>   }
>   function prnt()
>   {
> parent::prnt();
> echo "b=" . $this->$b;
>   }
> }
> 
> $obj = new B("a","b");
> $obj->prnt();
> 
> I think it should print
> a=a
> b=b
> 
> but it seems to print (on PHP4)
> a=
> b=

Looks like you're suffering from mad dollar disease. You should have the
following instead:

class A
{
  var $a, $b;
  function A($a)
  {
$this->a = $a;
  }
  function prnt()
  {
echo "a=" . $this->a;
  }
}

class B extends A
{
  function B($a, $b)
  {
parent::A($a);
$this->b = $b;
  }
  function prnt()
  {
parent::prnt();
echo "b=" . $this->b;
  }
}

$obj = new B("a","b");
$obj->prnt();

-- 
..
| 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] APACHE

2004-04-07 Thread Wykis
Guys... I Think I Am In Wrong Place... But What  Is Address Of Apache
Newsgroups? :)

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



Re: [PHP] PHP OO concepts

2004-04-07 Thread Red Wingate
You will find some usefull ressources over at

http://www.phppatterns.com/

 -- red

Robert Cummings wrote:

[...]
Hello,

I have am checking out PHP OOP and it's pretty smooth. I have a decent
amount of Java experience so PHP OOP is  really easy
to pick up. However I have a few questions I was hoping someone
could help me with.
Can php have a main()? If not ... how to you start a program that is
purley PHP OOP or is this even possible?
How popular is PHP OOP? Should I use PHP OOP for small dynamic web
pages? Is this the convention?
[...]

[...]
There is no main() for PHP. The concept of main is implied at the
beginning of you source file.
PHP OOP is fairly popular amongst those familiar with it's benefits and
techniques; however, many developers use it when they feel it is the
best solution for the task at hand. And so it is not uncommon to see
both procedural style code and OOP code intermingled. This is fairly
accepted in the PHP community. For examples of OOP code you could check
out the PEAR web site...
http://pear.php.net/

Or my own website:

http://www.interjinn.com

Or even PHP Classes

http://www.phpclasses.org/

And a multitude of other sites which you can probably find by doing a
search for OOP and PHP in google (or your favourite search engine).
[...]

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


Re: [PHP] Newbie question about operators

2004-04-07 Thread Matt Matijevich
[snip]
foreach ($some_array as $name=>$value)
{
 ... some code ...
}
[/snip]

http://www.php.net/foreach 

will give you a good explanation.

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



Re: [PHP] PHP 5: SimpleXML attributes

2004-04-07 Thread Red Wingate
Guess it was quite luck i saw the little note in the documentation:

Note: SimpleXML has made a rule of adding iterative properties to most 
methods. They cannot be viewed using var_dump() or anything else which 
can examine objects.

Guess i will have to take a look at my config parser again :-)

 -- red

Dan Phiffer wrote:

Red Wingate wrote:

So, this one will work out quite well ( maybe one should take
a look at the documentation of attributes() :-)


Wow I can't believe I missed that. Hehe.

I guess the lesson here is don't always trust what you get from print_r().

Thanks for the responses,
-Dan

foreach ( $xml->lib_error->param AS $param ) {
$n = 0 ;
while ( is_object ( $xml->lib_error->param[$n] ) ) {
foreach( $xml->lib_error->param[$n]->attributes() AS $a => $b ){
echo $a .' --> '. $b .'';
}
$n++;
}
}
 -- red

Dan Phiffer wrote:

Red Wingate wrote:



  
FALSE

  
  



 >

$xml = simplexml_load_file( 'config.xml' );

foreach ( $xml->lib_error->param AS $id => $param ) {
echo $param['name'] ; // will output 'boolean' !
}




I think you mean that would output 'error_logfile_write'. However, 
what I'm asking is if it's possible to iterate over the SimpleXML 
node attributes 'name' and 'type', without knowing ahead of time that 
'name' and 'type' are expected associative keys. There is an 
attributes() class method, but that just returns a numerically 
indexed array of the attribute values:

Array (
[0] => 'error_logfile_write',
[1] => 'boolean'
)
What I want is:

Array (
['name'] => 'error_logfile_write',
['type'] => 'boolean'
)
Thanks!
-Dan
Hello,

I have what I hope to be a simple question about SimpleXML. Is it 
possible to get the attributes of a SimpleXML node as an 
associative array?

Consider the following:

');
print_r($sxe->attributes());
// Gives: simplexml_element Object ( [0] => value )
?>
Is there some way to find out that 'value' is the attribute called 
'attr'? In other words, can I iterate over SimpleXML attributes 
without losing track of what their attribute name is? Or is this a 
case where I should switch over to DOM?




[...]





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


[PHP] Newbie question about operators

2004-04-07 Thread Gabe
Looking at the code below, what exactly is happening with the $name=>$value
part?  I looked in the PHP online documentation and I can't find that
operator.  What is it doing exactly and what is it called?

foreach ($some_array as $name=>$value)
{
 ... some code ...
}

Thanks alot!

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



Re: [PHP] PHP 5: SimpleXML attributes

2004-04-07 Thread Dan Phiffer
Red Wingate wrote:

So, this one will work out quite well ( maybe one should take
a look at the documentation of attributes() :-)
Wow I can't believe I missed that. Hehe.

I guess the lesson here is don't always trust what you get from print_r().

Thanks for the responses,
-Dan

foreach ( $xml->lib_error->param AS $param ) {
$n = 0 ;
while ( is_object ( $xml->lib_error->param[$n] ) ) {
foreach( $xml->lib_error->param[$n]->attributes() AS $a => $b ){
echo $a .' --> '. $b .'';
}
$n++;
}
}
 -- red

Dan Phiffer wrote:

Red Wingate wrote:



  
FALSE

  
  



 >

$xml = simplexml_load_file( 'config.xml' );

foreach ( $xml->lib_error->param AS $id => $param ) {
echo $param['name'] ; // will output 'boolean' !
}


I think you mean that would output 'error_logfile_write'. However, 
what I'm asking is if it's possible to iterate over the SimpleXML node 
attributes 'name' and 'type', without knowing ahead of time that 
'name' and 'type' are expected associative keys. There is an 
attributes() class method, but that just returns a numerically indexed 
array of the attribute values:

Array (
[0] => 'error_logfile_write',
[1] => 'boolean'
)
What I want is:

Array (
['name'] => 'error_logfile_write',
['type'] => 'boolean'
)
Thanks!
-Dan
Hello,

I have what I hope to be a simple question about SimpleXML. Is it 
possible to get the attributes of a SimpleXML node as an associative 
array?

Consider the following:

');
print_r($sxe->attributes());
// Gives: simplexml_element Object ( [0] => value )
?>
Is there some way to find out that 'value' is the attribute called 
'attr'? In other words, can I iterate over SimpleXML attributes 
without losing track of what their attribute name is? Or is this a 
case where I should switch over to DOM?


[...]



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


[PHP] OOP Question

2004-04-07 Thread Richard Lewis
What do members think that this code should do:

class A
{
  var $a, $b;
  function A($a)
  {
$this->$a = $a;
  }
  function prnt()
  {
echo "a=" . $this->$a;
  }
}

class B extends A
{
  function B($a, $b)
  {
parent::A($a);
$this->$b = $b;
  }
  function prnt()
  {
parent::prnt();
echo "b=" . $this->$b;
  }
}

$obj = new B("a","b");
$obj->prnt();

I think it should print
a=a
b=b

but it seems to print (on PHP4)
a=
b=

Cheers,
Richard

PS.
In C++ I would be thinking of virtual functions
and in Java I would be thinking of public/protected
properties.

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



Re: [PHP] PHP OO concepts

2004-04-07 Thread Robert Cummings
On Wed, 2004-04-07 at 16:44, jdavis wrote:
> Hello,
>  
>  I have am checking out PHP OOP and it's pretty smooth. I have a decent
> amount of Java experience so PHP OOP is  really easy
> to pick up. However I have a few questions I was hoping someone
> could help me with.
> 
> Can php have a main()? If not ... how to you start a program that is
> purley PHP OOP or is this even possible?
> 
> How popular is PHP OOP? Should I use PHP OOP for small dynamic web
> pages? Is this the convention?

There is no main() for PHP. The concept of main is implied at the
beginning of you source file.

PHP OOP is fairly popular amongst those familiar with it's benefits and
techniques; however, many developers use it when they feel it is the
best solution for the task at hand. And so it is not uncommon to see
both procedural style code and OOP code intermingled. This is fairly
accepted in the PHP community. For examples of OOP code you could check
out the PEAR web site...

http://pear.php.net/

Or my own website:

http://www.interjinn.com

Or even PHP Classes

http://www.phpclasses.org/

And a multitude of other sites which you can probably find by doing a
search for OOP and PHP in google (or your favourite search engine).

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



Re: [PHP] PHP 5: SimpleXML attributes

2004-04-07 Thread Red Wingate
So, this one will work out quite well ( maybe one should take
a look at the documentation of attributes() :-)
foreach ( $xml->lib_error->param AS $param ) {
$n = 0 ;
while ( is_object ( $xml->lib_error->param[$n] ) ) {
foreach( $xml->lib_error->param[$n]->attributes() AS $a => $b ){
echo $a .' --> '. $b .'';
}
$n++;
}
}
 -- red

Dan Phiffer wrote:

Red Wingate wrote:



  
FALSE

  
  

 >

$xml = simplexml_load_file( 'config.xml' );

foreach ( $xml->lib_error->param AS $id => $param ) {
echo $param['name'] ; // will output 'boolean' !
}


I think you mean that would output 'error_logfile_write'. However, what 
I'm asking is if it's possible to iterate over the SimpleXML node 
attributes 'name' and 'type', without knowing ahead of time that 'name' 
and 'type' are expected associative keys. There is an attributes() class 
method, but that just returns a numerically indexed array of the 
attribute values:

Array (
[0] => 'error_logfile_write',
[1] => 'boolean'
)
What I want is:

Array (
['name'] => 'error_logfile_write',
['type'] => 'boolean'
)
Thanks!
-Dan
Hello,

I have what I hope to be a simple question about SimpleXML. Is it 
possible to get the attributes of a SimpleXML node as an associative 
array?

Consider the following:

');
print_r($sxe->attributes());
// Gives: simplexml_element Object ( [0] => value )
?>
Is there some way to find out that 'value' is the attribute called 
'attr'? In other words, can I iterate over SimpleXML attributes 
without losing track of what their attribute name is? Or is this a 
case where I should switch over to DOM?


[...]


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


Re: [PHP] PHP 5: SimpleXML attributes

2004-04-07 Thread Dan Phiffer
John W. Holmes wrote:

Have you seen Example 4 here: http://us2.php.net/manual/en/ref.simplexml.php

Not sure if that helps or not, though, but it looks like it's already an
associative array.
It certainly looks like an associative array, but the array_keys() 
function chokes on it:

Warning: array_keys() [function.array-keys]: The first argument should 
be an array in D:\...\test.php on line 5

Explicitely casting it as an array doesn't work either. I guess I want 
something like example 4, but without having to hardcode in the 
$rating['type']. Something more like:

foreach ($xml->movie[0]->rating as $rating) {
foreach ($rating->attributes() as $key => $value) {
if ($key == 'type') {
switch ($rating['type']) {
...
}
}
}
}
Thanks,
-Dan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PHP OO concepts

2004-04-07 Thread jdavis
Hello,
 
 I have am checking out PHP OOP and it's pretty smooth. I have a decent
amount of Java experience so PHP OOP is  really easy
to pick up. However I have a few questions I was hoping someone
could help me with.

Can php have a main()? If not ... how to you start a program that is
purley PHP OOP or is this even possible?

How popular is PHP OOP? Should I use PHP OOP for small dynamic web
pages? Is this the convention?

Thanks,
jd




-- 
[EMAIL PROTECTED]

"Bad spellers of the world untie!"

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



Re: [PHP] PHP 5: SimpleXML attributes

2004-04-07 Thread Dan Phiffer
Red Wingate wrote:



  
FALSE

  
  

>
$xml = simplexml_load_file( 'config.xml' );

foreach ( $xml->lib_error->param AS $id => $param ) {
echo $param['name'] ; // will output 'boolean' !
}
I think you mean that would output 'error_logfile_write'. However, what 
I'm asking is if it's possible to iterate over the SimpleXML node 
attributes 'name' and 'type', without knowing ahead of time that 'name' 
and 'type' are expected associative keys. There is an attributes() class 
method, but that just returns a numerically indexed array of the 
attribute values:

Array (
[0] => 'error_logfile_write',
[1] => 'boolean'
)
What I want is:

Array (
['name'] => 'error_logfile_write',
['type'] => 'boolean'
)
Thanks!
-Dan
Hello,

I have what I hope to be a simple question about SimpleXML. Is it 
possible to get the attributes of a SimpleXML node as an associative 
array?

Consider the following:

');
print_r($sxe->attributes());
// Gives: simplexml_element Object ( [0] => value )
?>
Is there some way to find out that 'value' is the attribute called 
'attr'? In other words, can I iterate over SimpleXML attributes 
without losing track of what their attribute name is? Or is this a 
case where I should switch over to DOM?
[...]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] radio buttons checked or not

2004-04-07 Thread Andy B

- Original Message - 
From: "Daniel Clark" <[EMAIL PROTECTED]>
To: "Andy B" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, April 07, 2004 4:22 PM
Subject: Re: [PHP] radio buttons checked or not


> My understanding is if the variable "exists" then the radio button was
> checked.
>
>
> > i have this code:
> > 
> >  > accesskey="y">Yes
> > 
> >  > accesskey="n">No
> > was just wondering if that was the right way to determine the state of a
> > radio button...?
> > if the value of $old['Type']="Annual" then the yes button is
checked...if
> > not then the no button is checked instead...
>

nope..its pulled out of a db... its a field name called Type and its ENUM
('Annual', 'OneTime') and i have to load all of the record back into the
form so it can be changed and put back into the table


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



Re: [PHP] PHP 5: SimpleXML attributes

2004-04-07 Thread John W. Holmes
From: "Dan Phiffer" <[EMAIL PROTECTED]>

> I have what I hope to be a simple question about SimpleXML. Is it
> possible to get the attributes of a SimpleXML node as an associative
array?
>
> Consider the following:
>
>  $sxe = simplexml_load_string('');
> print_r($sxe->attributes());
> // Gives: simplexml_element Object ( [0] => value )
> ?>
>
> Is there some way to find out that 'value' is the attribute called
> 'attr'? In other words, can I iterate over SimpleXML attributes without
> losing track of what their attribute name is? Or is this a case where I
> should switch over to DOM?

Have you seen Example 4 here: http://us2.php.net/manual/en/ref.simplexml.php

Not sure if that helps or not, though, but it looks like it's already an
associative array.

---John Holmes...

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



Re: [PHP] radio buttons checked or not

2004-04-07 Thread Daniel Clark
My understanding is if the variable "exists" then the radio button was
checked.


> i have this code:
> 
>  accesskey="y">Yes
> 
>  accesskey="n">No
> was just wondering if that was the right way to determine the state of a
> radio button...?
> if the value of $old['Type']="Annual" then the yes button is checked...if
> not then the no button is checked instead...


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



Re: [PHP] PHP 5: SimpleXML attributes

2004-04-07 Thread Red Wingate
There is a way, but somehow i don't like it though ( but you
can find this in the documentation ):
This is config.xml:



  
FALSE

  
  

And my Testfile:

$xml = simplexml_load_file( 'config.xml' );

foreach ( $xml->lib_error->param AS $id => $param ) {
echo $param['name'] ; // will output 'boolean' !
}
 -- red

[...]
Hello,

I have what I hope to be a simple question about SimpleXML. Is it 
possible to get the attributes of a SimpleXML node as an associative array?

Consider the following:

');
print_r($sxe->attributes());
// Gives: simplexml_element Object ( [0] => value )
?>
Is there some way to find out that 'value' is the attribute called 
'attr'? In other words, can I iterate over SimpleXML attributes without 
losing track of what their attribute name is? Or is this a case where I 
should switch over to DOM?
[...]

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


[PHP] PHP 5: SimpleXML attributes

2004-04-07 Thread Dan Phiffer
Hello,

I have what I hope to be a simple question about SimpleXML. Is it 
possible to get the attributes of a SimpleXML node as an associative array?

Consider the following:

');
print_r($sxe->attributes());
// Gives: simplexml_element Object ( [0] => value )
?>
Is there some way to find out that 'value' is the attribute called 
'attr'? In other words, can I iterate over SimpleXML attributes without 
losing track of what their attribute name is? Or is this a case where I 
should switch over to DOM?

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


[PHP] creating sql statements?? was:confused big time

2004-04-07 Thread Andy B
> I always found this way of inserting data into a database messy. Here is
> a handy function to do array inserts and it builds the sql for you.
>
> function arrayINSERT($a,$tablename)
> {
> $sql = "INSERT INTO $tablename (";
> foreach($a as $key => $value)
> {
> $sql .= $key .",";
> }
> $sql[strlen($sql)-1] = ')';
> $sql .= " VALUES (";
> foreach($a as $key => $value)
> {
> if (gettype($value) == 'string')
> {
> $sql .= "'". addslashes($value) ."',";
> }
> else
> {
> $sql .= $value .",";
> }
> }
> $sql[strlen($sql)-1] = ')';
> return $sql;
> }
>
> if you do this :
>
> $a['field1'] = $blah;
> $a['field2'] = $here;
> $a['field3'] = $etc;
> $sql = arrayINSERT($a,"tablename");
>
>
> it builds the sql statement for you.  It covers 99.9% of the inserts
> your likely to need.  I use an update and insert function like this all
> the time. :-)
>
> Mark
>
>
>
> Richard Davey wrote:
>
> >
> > $sql = "
> > INSERT INTO
> >tablename
> >(
> > field1,
> > field2,
> > field3
> >)
> > VALUES
> >   (
> > '$blah',
> > $here',
> > '$etc'
> >   )
> > ";
>

ok sounds like fun and a way to keep code compacted but say inparticular
that i have an array that needs to be inserted in a certain way?? like
$_SESSION['add'][..] or something of that sort??the $_SESSION['add'] array
elements have to be inserted in a certain order...or is that just a matter
of creating the array in a certain order on the page before it??

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



Re: [PHP] update mysql from php web page

2004-04-07 Thread Daniel Clark
Something I like to do during troubleshooting is to have the page display
the SQL statement I'm processing.

Something like:  print sql_query ;

That was I can verify all the parameters are correct.


Do you have autocommit ON?   Or need to pass a commit statement?

Daniel Clark



> Of course, I didn't notice I left that line out of my code, although I did
> remember to put in the closing form tag. But, unfortumately, the update is
> not executed. The form button works, and it appears to do what it should,
> but the data is not changed.
> I changed the form method to get so I could see what is being passed and
> everything there is fine, but at the end of the url I see this-
> url...stuff...&submit=Update+Data
> Is this correct?
>
> What else can I do to see what was passed to the database (if anything)?
> --
> Chip

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



Re: [PHP] smarty

2004-04-07 Thread John W. Holmes
From: "Chris de Vidal" <[EMAIL PROTECTED]>

> Or are you saying:
> $pt = new MyPage;
> $pt->render('contact.tpl');
> OR
> $pt = new MyPage;
> $pt ->render('prices.tpl');
> OR
> $pt = new MyPage;
> $pt->render('index.tpl');
> 
> I can see the benefit of this method if that's what you mean.

That's what I meant. :) I guess I was too consise. 

---John Holmes...

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



Re: [PHP] smarty

2004-04-07 Thread Jochem Maas
Chris W. Parker wrote:
Chris de Vidal 
on Tuesday, April 06, 2004 11:43 AM said:

I could have put a tag in the template like {bio} but that'd mean
maintaining HTML in the PHP code which I wanted to avoid (left the
"prettyness" to the Front Page developer).  Instead, I put something
like this in the template:
{if $level > 2}
{bio}
{/if}


i've never used smarty* but i think i understand how it works. so my
question is this...
would it not be better to place that logic in your php code instead of
your template?
what you suggest is handy for situations where you want to limit access 
to anything remotely programmy from users/designers who have no 
understanding/experience etc (or who use tools like FrontPage...yuck!)
(Maybe DreamWeaver is a better option, has better HTML output/processing 
and can be made to work nicely with Smarty templates.)

BUT...

It's probably important to understand that templating is really about 
the seperation of presentation & application/business logic in order to 
allow, for example, better task seperation (interface/graphic designers 
edit templates and programmers edit PHP files) and not about the 
seperation of code & content (or HTML & PHP or somesuch): it is true 
that most ('so called' -- not all are really template engines) allow you 
to also seperate the HTML & PHP.

bare this in mind: PHP is also a templating engine! image 1 file which 
does calculation, DB transactions and setting output variables and 
another file which outputs HTML according to logic that reacts to the 
values of the output variables.

to me performance is second to everything else (I prefer slow code thats 
well documented, loosely coupled* and easily extentable to super fast 
unreadable tightly coupled code) - first make it do what you need it to 
do! you can always optimize later and if the code is still not fast 
enough then code accelerators (like the ZendAccelerator or PHPa) and 
faster hardware probably offer the cheapest (and mostly quickly 
implemented) performance boost.

I think Smarty is a really good tool and very well supported & 
documented. I have run into limitations regarding PHP5 dereferenced 
object syntax and static object call syntax which led me to investigate 
the template parsing mechanism of Smarty - I found regular expressions 
which exceeded 1000 chars in length!! this I found to be a little 
worrying, none the less Smarty is still faster & I see very little 
slowdown even when forcing a recompile on every page hit as opposed to 
not using Smarty at all.

I hope that adds to you understanding a bit. If anything is unclear or I 
have stated something that is incorrect I'd love to hear about it -- 
always looking to learn more about stuff, especially PHP!

Jochem

--
*coupling refers to the level of interdependency of various elements 
with you application. using Smarty _allows_ you to loosen the coupling 
between business & presentation logic (you can technically write all 
your business logic in Smarty templates but that is ill-advised) by 
creating a std API for transfering data from one layer to the next.

my thinking is this: if {bio} contains anything, it will print to the
page. if it doesn't contain anything, nothing will be printed. so
there's no need to check the value of $level within the template since
{bio} will simply contain something, or it will not.
i'm purely looking to understand this "smarty" thing a little better. :)

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


Re: [PHP] update mysql from php web page

2004-04-07 Thread Chip Wiegand
"Daniel Clark" <[EMAIL PROTECTED]> wrote on 04/07/2004 10:17:36 AM:

> For the submit button to work it has to be in a form.
> 
> 
>
> 
> 
> Hope this helps.
> 
> Daniel Clark

Of course, I didn't notice I left that line out of my code, although I did 
remember to put in the closing form tag. But, unfortumately, the update is 
not executed. The form button works, and it appears to do what it should, 
but the data is not changed. 
I changed the form method to get so I could see what is being passed and 
everything there is fine, but at the end of the url I see this-
url...stuff...&submit=Update+Data
Is this correct?

What else can I do to see what was passed to the database (if anything)?
--
Chip

> > 
> > ... more code ...
> > 
> >  > endif;
> > ?>
> > 
> > 
> > -
> >
> > I don't see any reason for the submit button to not work at all. What
> > should I look for now?
> > Thanks for the help,
> > Chip
> 
> 

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



  1   2   >