Re: [PHP] php 5 interfaces

2005-01-21 Thread Sergio Gorelyshev
On Thu, 20 Jan 2005 11:13:11 -0800 (PST)
"Richard Lynch" <[EMAIL PROTECTED]> wrote:

> Sergio Gorelyshev wrote:
> > Hi all.
> >
> > Situation:
> >
> > interface MyInterface {
> >  public static myMethod();
> > }
> >
> > class MyClass implements MyInterface {
> >   public static myMethod() {}
> > }
> >
> > This sample will crash with message
> > Fatal error: Access type for interface method MyInterface::myMethod() must
> > be omitted in somefile.php on line NN
> >
> > Why I'm not able to clarify call's type (static) for methods in interface?
> > I'm predict closely that method myMethod() in all classes which implements
> >  MyInterface must be called statically. A little trick allowed to me to
> > resolve this problem, but my question  more ideological than practical.
> 
> As I understand it, an 'interface' is, by definition, never gonna have an
> actualy object instantiated.
> 
> Thus, there can never *BE* an object for which private/public/protected
> have any meaning.
> 
> You can only use the private/public/protected on the 'class' definitions.

Thanks to all.
First sample of interface usage in php manual:
vars[$name] = $var;
  }
  
  public function getHtml($template)
  {
foreach($this->vars as $name => $value) {
  $template = str_replace('{'.$name.'}', $value, $template);
}

return $template;
  }
}
?> 
IMHO its normally to use access type for methods declaration in interfaces. Why 
not?
Maybe my first example was not sufficiently illustrative. But my question was 
"why it does not work in one environment and work fine in another". The problem 
has acquired when i try to add "static" in my interface definition. I don't 
think that this is a bug in PHP. I just want to be deep insight in OOP of PHP5 
engine.

> Even if you *KNOW* that all class definitions *should* for this to be
> 'public' it just doesn't make sense from the strictly technical
> stand-point of what an 'interface' is to declare it there.
> 
> Maybe somewhere over on php-dev you could make the case for the PHP Dev
> Team to implement something good/interesting when public/protected/private
> is used there, but currently it's semanticly undefined to have it there,
> so it can't be there.
> 
> Disclaimer: I could easily be 100% wrong in this entire post. :-)
> 
> -- 
> Like Music?
> http://l-i-e.com/artists.htm
> 


-- 
RE5PECT
Sergio Gorelyshev

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



[Fwd: Re: [PHP] php 5 interfaces]

2005-01-21 Thread Jochem Maas
Tbird switched the reply and reply-all buttons again ;-)...
?> 
IMHO its normally to use access type for methods declaration in interfaces. Why not?
Maybe my first example was not sufficiently illustrative. But my question was "why it does not work in one environment and work fine in another". 
it worked for a while because it was originally overlooked, then they
'fixed' it. -- you may not agree with the devs.
The problem has acquired when i try to add "static" in my interface definition. I don't think that this is a bug in PHP. 
I just want to be deep insight in OOP of PHP5 engine.

your right, its not a bug - although some have argued that its Sucks(tm).
in short it was decided by the devs that interfaces are not meant for
static classes, they only apply to objects - which is why 'static' is
not (no longer) allowed on interface methods. if you want to know more
then digging into the php internals mailing list archives will give you
long discussions and justifications as to why it works they way it does.
if you think about it you can see where they are coming from: passing
around classes (i.e. classNames) and then checking whether said class
implements something is really odd, instead you pass around objects.
or more simply:
class == blueprint
object == house
you can interface with a house (lets hope your house IMPLEMENTS a door
interface!) but you can't interface with a blueprint (possibly with the
piece of paper it may be printed on but not with the actual blueprint)
because the blueprint is an idea/concept.
hope that helps you to understand the rationale.
rgds,
JOchem

...

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


[PHP] PHP5: DOM->removeChild Problem

2005-01-21 Thread Mike Blank
Hi Guys!

I've got a problem with Dom and php 5.0.2. I'm trying to access an xml
node with $item = $objDom->documentElement->childNodes->item(0);. That
seems to work, because on the next line I can output the node Value with
echo $item->nodeValue. But when I use the command
$objDom->removeChild($item); on the next line, dom throws a
DOMException:

Fatal error: Uncaught exception 'DOMException' with message 'Not Found
Error' in
/opt/lampp/htdocs/www/snap_chubb/extensions/features/mitarbeiter/main.fe
a.php:13 Stack trace: #0
/opt/lampp/htdocs/www/snap_chubb/admin/admin.class.php(179): require()
#1 /opt/lampp/htdocs/www/snap_chubb/admin/admin.class.php(154) :
eval()'d code(1): Admin->editFeature(Object(DOMElement)) #2
/opt/lampp/htdocs/www/snap_chubb/admin/admin.class.php(154): eval() #3
/opt/lampp/htdocs/www/snap_chubb/admin/index.php(142):
Admin->drawContent() #4 {main} thrown in
/opt/lampp/htdocs/www/snap_chubb/extensions/features/mitarbeiter/main.fe
a.php on line 13

Below you can see my code:

Index.php
---

$objDom = new DomDocument(); // neues dom objekt
$strXML = $this->loadXMLTree($objDATA->fields['pfe_con_id']); //
funktion, die eine xml datei als string aus der db ausliest if ($strXML
!= false) {
$objDom->loadXML($strXML); // string wird in das dom objekt
geladen } $item = $objDom->documentElement->childNodes->item(0); //
adressierung eines knoten echo $item->nodeValue; // ausgabe funktioniert
ohne probleme
$objDom->removeChild($item); // diese zeile spuckt den oben genannten
Error aus!


Geladener XML string
---




/images/43/team_fabian-bischof_kl.jpg
Fabian Bischof
45


/images/43/team_sandra-varela_kl.jpg
Sandra Varela
0


/images/43/team_sandra-varela_kl.jpg
Sandra Varela
0


---

I hope somebody can help me somehow! I'm really desperate!

Cheers

mike

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



Re: [Fwd: Re: [PHP] php 5 interfaces]

2005-01-21 Thread Sergio Gorelyshev
On Fri, 21 Jan 2005 11:56:55 +0100
Jochem Maas <[EMAIL PROTECTED]> wrote:

> Tbird switched the reply and reply-all buttons again ;-)...
> 
> > ?> 
> > IMHO its normally to use access type for methods declaration in interfaces. 
> > Why not?
> > Maybe my first example was not sufficiently illustrative. But my question 
> > was "why it does not work in one environment and work fine in another". 
> 
> it worked for a while because it was originally overlooked, then they
> 'fixed' it. -- you may not agree with the devs.
> 
> > The problem has acquired when i try to add "static" in my interface 
> > definition. I don't think that this is a bug in PHP. 
> > I just want to be deep insight in OOP of PHP5 engine.
> > 
> 
> your right, its not a bug - although some have argued that its Sucks(tm).
> 
> in short it was decided by the devs that interfaces are not meant for
> static classes, they only apply to objects - which is why 'static' is
> not (no longer) allowed on interface methods. if you want to know more
> then digging into the php internals mailing list archives will give you
> long discussions and justifications as to why it works they way it does.
> 
> if you think about it you can see where they are coming from: passing
> around classes (i.e. classNames) and then checking whether said class
> implements something is really odd, instead you pass around objects.
> 
> or more simply:
> 
> class == blueprint
> object == house
> 
> you can interface with a house (lets hope your house IMPLEMENTS a door
> interface!) but you can't interface with a blueprint (possibly with the
> piece of paper it may be printed on but not with the actual blueprint)
> because the blueprint is an idea/concept.
> 
> hope that helps you to understand the rationale.

Thanks. This really helped me to understand php developer's way of thinking.

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


-- 
RE5PECT
Sergio Gorelyshev

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



[PHP] if then else short form

2005-01-21 Thread Ben Edwards
I seem to remember seing someone use a abreaviated form of a
if/them/else of the type that can be used in java.

It was something like

if ( a=b ) ? a=1 ; a=2;

Anybody know what the correct syntax is?

Ben
-- 
Ben Edwards - Poole, UK, England
WARNING:This email contained partisan views - dont ever accuse me of
using the veneer of objectivity
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

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



Re: [PHP] if then else short form

2005-01-21 Thread Richard Davey
Hello Ben,

Friday, January 21, 2005, 12:01:09 PM, you wrote:

BE> I seem to remember seing someone use a abreaviated form of a
BE> if/them/else of the type that can be used in java.

BE> It was something like

BE> if ( a=b ) ? a=1 ; a=2;

BE> Anybody know what the correct syntax is?

It's called a ternary operator.

$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

In the PHP manual under Comparison Operators.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

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



Re: [PHP] if then else short form

2005-01-21 Thread Sergio Gorelyshev
On Fri, 21 Jan 2005 12:01:09 +
Ben Edwards <[EMAIL PROTECTED]> wrote:

> I seem to remember seing someone use a abreaviated form of a
> if/them/else of the type that can be used in java.
> 
> It was something like
> 
> if ( a=b ) ? a=1 ; a=2;
> 
> Anybody know what the correct syntax is?

condition ? do_that_if_true : do_that_if_false;

> Ben
> -- 
> Ben Edwards - Poole, UK, England
> WARNING:This email contained partisan views - dont ever accuse me of
> using the veneer of objectivity
> If you have a problem emailing me use
> http://www.gurtlush.org.uk/profiles.php?uid=4
> (email address this email is sent from may be defunct)
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
RE5PECT
Sergio Gorelyshev

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



Re: [PHP] if then else short form

2005-01-21 Thread Jochem Maas
Ben Edwards wrote:
I seem to remember seing someone use a abreaviated form of a
if/them/else of the type that can be used in java.
It was something like
if ( a=b ) ? a=1 ; a=2;
$a = ($a == $b) ? 1: 2;
which meand: if $a is equal to $b then set $a to 1 otherwise set $a to 
2. that is equivalent to:

if ($a == $b) {
$a = 1;
} else {
$a = 1;
}
btw: its called the 'tertiary' syntax (because its the third form)
Anybody know what the correct syntax is?
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] if then else short form

2005-01-21 Thread Jochem Maas
Ben Edwards wrote:
I seem to remember seing someone use a abreaviated form of a
if/them/else of the type that can be used in java.
It was something like
if ( a=b ) ? a=1 ; a=2;
I called it the 'tertiary' syntax which is not correct:
to quote a page I found: "
that the book refers to a "tertiary" operator, instead of a "ternary" 
operator. Of course, "tertiary" means third. "Ternary" means having 
three parts and is the correct way to describe the ?: operator. 
Alternatively, this operator could be described as "trinary".
"

Anybody know what the correct syntax is?
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] if then else short form

2005-01-21 Thread Manoj
 language tutorial (basic)...

>if ( a=b ) ? a=1 ; a=2;
  a = a==b ? 1 : 2 ;
Cheer,
Manoj Kr. Sheoran 
Software Engg. 
Daffodil Software Ltd. 
web: www.daffodildb.com 
INDIA 






On Fri, 2005-01-21 at 17:31, Ben Edwards wrote:
> I seem to remember seing someone use a abreaviated form of a
> if/them/else of the type that can be used in java.
> 
> It was something like
> 
> if ( a=b ) ? a=1 ; a=2;
> 
> Anybody know what the correct syntax is?
> 
> Ben
> -- 
> Ben Edwards - Poole, UK, England
> WARNING:This email contained partisan views - dont ever accuse me of
> using the veneer of objectivity
> If you have a problem emailing me use
> http://www.gurtlush.org.uk/profiles.php?uid=4
> (email address this email is sent from may be defunct)

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



RE: [PHP] Seemingly weird regex problem

2005-01-21 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 20 January 2005 20:36, Tim Boring wrote:

> On Thu, 2005-01-20 at 14:40, Bret Hughes wrote:
> > On Thu, 2005-01-20 at 12:43, Jason Wong wrote:
> > > On Friday 21 January 2005 02:16, Tim Boring wrote:
> > > 
> > > > It's perfectly legit to use expressions.  Now perhaps there is
> > > > something wrong with the regex I'm trying to use, but using a
> > > > regex in and of itself is legal.
> > > > http://www.php.net/manual/en/control-structures.switch.php 
> > > 
> > > Yes, but comparing those expressions to:
> > > 
> > >   switch ($line)
> > > 
> > > where $line is a string, doesn't make sense. See my other post.
> > > 
> > 
> > Chaching ( sound of light bulb turning on)  I see that in the
> > example in the manual it needs to be compared to true ( a boolean
> > value) 
> > 
> > 
> > switch (true)
> > 
> > rather than switch ($line)
> > 
> > What is not apparent to me is why the first case matches if the preg
> > fails.  Wouldn't line evaluate to true in a boolean context?

Coming a little late to the discussion here, but I don't think anyone's
really cottoned on to the fact that:

   switch ($x):
   {
  case $e1:
 ...
 break;

  case $e2:
 ...
 break;

  ...

   }

is functionally equivalent to:

   if ($x==$e1):
  ...
   elseif($x==$e2):
  ...
   ...
   endif;

(except that the $x expression is evaluated only once, at the start, instead
of multiple times).

So it's important to be able to predict how an == comparison will perform,
but because of the way PHP does automatic type conversion, this isn't always
obvious (and, unfortunately, there's no switch() modifier to force ===
comparisons).  I can't remember all the minute details, but basically it
goes something like this:

0, 0.0, FALSE, '' and '0' all compare equal to each other.

if one expression is Boolean, the other is converted to Boolean before
comparison.

if one expression is a number, the other is converted to a number (using
usual PHP rules, so a string which does not start with a number is converted
to 0).

if both expressions are string, and both look like a number, both are
converted to numbers and a numeric comparison is performed (so "3"=="3.0",
for instance).

In addition, the tables at http://php.net/types.comparisons may be of help,
particularly table O-2.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Re: [suspicious - maybe spam] [PHP] Re: How to access remote files with php?

2005-01-21 Thread Jochem Maas
Sephiroth wrote:
The error message:
HTTP/1.0 400 Bad Request Server: squid/2.5.STABLE5 Mime-Version: 1.0 Date:
Fri, 21 Jan 2005 01:48:05 GMT Content-Type: text/html Content-Length: 1213
Expires: Fri, 21 Jan 2005 01:48:05 GMT X-Squid-Error: ERR_INVALID_URL 0
X-Cache: MISS from ns1.autoera.com.tw X-Cache-Lookup: NONE from
ns1.autoera.com.tw:3128 Proxy-Connection: close
looks like your talking to a badly configured Squid server. or that it 
is not getting the correct headers from PHP when you use file_*() 
functions on the url in question. does the URL work from a browser?

otherwise why not try hitting port 80 instead (assuming that allowed) 
and bypass the Squid server (port 3128, which is the default) and talk 
directly to the webserver, at least to test what your doing - I assume 
that Squid should be acting in reverse-proxy mode which when setup 
properly is transparent.

---
btw: Squid is a generic proxy/cache/reverse-proxy server which is:
a powerful
b complex
six people on the world understand it properly, and I'm not one of them 
;-) - my way of configuring Squid is to say to a colleague 'I need a 
reverse-proxy on site X , would you be so kind...', which actually makes 
it very easy to setup ;-)

ERROR
The requested URL could not be retrieved
so the URL wrappers for file streams (is my terminology correct? 
anyone?) is working - but the file you are opening is not available.


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


[PHP] [suspicious - maybe spam] Using heredocs

2005-01-21 Thread Tim Burgan
Hello,
I've just tried using heredocs [1] for the first time, but I am
receiving parse errors always on the very last line of my document.
The error is caused by my heredocs. Am I using it correctly? When I
replaced the heredoc with a string.. everything worked again.
Here's my code with heredocs (and the lines before and after for context):
/* Query the database */
$db_sql = <<
SELECT  id, expiry, permissions
FROMtblStudents
UNION ALL
SELECT  id, expiry, permissions
FROMtblStaff;
SQL;
$rs = $db_connection->execute($db_sql);
Here's my code without heredocs (and the lines before and after for
context) - this works fine:
/* Query the database */
$db_sql = 'SELECT id, expiry, permissions FROM tblStudents UNION ALL
SELECT id, expiry, permissions FROM tblStaff;';
$rs = $db_connection->execute($db_sql);
What am I doing wrong? Are there any requirements to using heredocs?
I'm using PHP4, Apache, Win XP.
[1]

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


[PHP] REPOST: Serving WML

2005-01-21 Thread Mikey
> Hi again - thought it best to keep the two topics separately...
> 
> I have just leased a virtual hosting package and want to provide GPRS
> access to my email server using WML.
> 
> Now I have a couple of test pages that I have put up on the server that I
> want to view, but can't seem to get to them.  I am not really sure about
> how GPRS works, but I thought that any internet server could serve WML as
> long as it was valid.
> 
> I have read a little about gateways and from what I have read it seems
> that it would be my phone company that was responsible for providing that.
> 
> Any ideas?
> 
> Mikey

Any takers for this question?

Pulease?!?!?

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



Re: [PHP] [suspicious - maybe spam] Using heredocs

2005-01-21 Thread Jochem Maas
Tim Burgan wrote:
Hello,
I've just tried using heredocs [1] for the first time, but I am
receiving parse errors always on the very last line of my document.
The error is caused by my heredocs. Am I using it correctly? When I
replaced the heredoc with a string.. everything worked again.
Here's my code with heredocs (and the lines before and after for context):
/* Query the database */
$db_sql = <<
SELECT  id, expiry, permissions
FROMtblStudents
UNION ALL
SELECT  id, expiry, permissions
FROMtblStaff;
SQL;

the token 'SQL' must be the first and only thing on that line (other 
than the terminating semi-colon):

$db_sql = <<
 SELECT  id, expiry, permissions
 FROMtblStudents
 UNION ALL
 SELECT  id, expiry, permissions
 FROMtblStaff;
SQL;
other that that your code was fine. :-)

$rs = $db_connection->execute($db_sql);
Here's my code without heredocs (and the lines before and after for
context) - this works fine:
/* Query the database */
$db_sql = 'SELECT id, expiry, permissions FROM tblStudents UNION ALL
SELECT id, expiry, permissions FROM tblStaff;';
$rs = $db_connection->execute($db_sql);
What am I doing wrong? Are there any requirements to using heredocs?
I'm using PHP4, Apache, Win XP.
[1]
 

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


Re: [PHP] REPOST: Serving WML

2005-01-21 Thread Jochem Maas
Mikey wrote:
Hi again - thought it best to keep the two topics separately...
I have just leased a virtual hosting package and want to provide GPRS
access to my email server using WML.
Now I have a couple of test pages that I have put up on the server that I
want to view, but can't seem to get to them.  I am not really sure about
how GPRS works, but I thought that any internet server could serve WML as
long as it was valid.
correct.
I have read a little about gateways and from what I have read it seems
that it would be my phone company that was responsible for providing that.
you own a phone company? get one of your lakey sysadmins to fix up what 
you need ;-)


just like with a std net connection you need to actually _have_ a 
connection, and in your case you need to be able to reach the machine in 
question (i.e. not connect thru a gateway that only give you access to 
servers run by your connection provider).

a 5 second google gave me this page: http://www.filesaveas.com/gprs.html
maybe that helps you on your way?
whatever you do you need to cough up money for a GPRS connection :-)
Any ideas?
Mikey

Any takers for this question?
Pulease?!?!?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: [suspicious - maybe spam] Using heredocs

2005-01-21 Thread Jason Barnett
Tim Burgan wrote:
Hello,
I've just tried using heredocs [1] for the first time, but I am
receiving parse errors always on the very last line of my document.
The error is caused by my heredocs. Am I using it correctly? When I
replaced the heredoc with a string.. everything worked again.
Here's my code with heredocs (and the lines before and after for context):
/* Query the database */
$db_sql = <<
SELECT  id, expiry, permissions
FROMtblStudents
UNION ALL
SELECT  id, expiry, permissions
FROMtblStaff;
Heredoc is a strict format.  the SQL; *must* be at the very beginning of 
the line, so if you simply remove the whitespace before it you should be 
fine.

SQL;
SQL;
$rs = $db_connection->execute($db_sql);

...

Thanks
Tim

--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | 
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

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


[PHP] Re: REPOST: Serving WML

2005-01-21 Thread Jason Barnett
Mikey wrote:
Hi again - thought it best to keep the two topics separately...
I have just leased a virtual hosting package and want to provide GPRS
access to my email server using WML.
I have never built a site that served WML, but I know a 
small bit about it

Now I have a couple of test pages that I have put up on the server that I
want to view, but can't seem to get to them.  I am not really sure about
how GPRS works, but I thought that any internet server could serve WML as
long as it was valid.
OK Google tells me GPRS is this: 
http://www.gsmworld.com/technology/gprs/intro.shtml#1
(Sorry, like I said I've never served WML before!)

I definitely have never treaded into these waters.  If GPRS is a 
protocol that is built on top of HTTP then I can think of no reason why 
your Apache server shouldn't be able to do this.  The main task, I 
think, would then be to check the browser's user-agent and generate WML 
if it is a browser built for a phone.

Lucky you... I actually looked through some packages once upon a time to 
 serve WML.  I remember liking what I saw from HAWHAW; perhaps it will 
work for you?

This link will probably help you out:
http://www.hawhaw.de/faq.htm
I have read a little about gateways and from what I have read it seems
that it would be my phone company that was responsible for providing that.
AFAIK yes, mobile phone companies provide the gateways to the net. 
Sprint actually has a lot of stuff out there to help developers provide 
content to their system, but I never got into it much (I remember it 
being more work than my just-for-fun project justified).

Any ideas?
Mikey

Any takers for this question?
Pulease?!?!?

--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | 
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

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


RE: [PHP] REPOST: Serving WML

2005-01-21 Thread Mikey
> you own a phone company? get one of your lakey sysadmins to fix up what
> you need ;-)

LOL!  The trouble with lackey sysadmins is that they never do what they are
told, always what's "kewl" - I have long since lost the energy required to
beat them into submission!

> just like with a std net connection you need to actually _have_ a
> connection, and in your case you need to be able to reach the machine in
> question (i.e. not connect thru a gateway that only give you access to
> servers run by your connection provider).
> 
> a 5 second google gave me this page: http://www.filesaveas.com/gprs.html
> maybe that helps you on your way?
>
> whatever you do you need to cough up money for a GPRS connection :-)
> 

All I want to do is to be able to allow access to my email from my phone, to
start off with and then move slowly from there.

Mikey

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



Re: [PHP] Extending a Class

2005-01-21 Thread Brent Baisley
You've got most of it. Just adding "extends MySQL" to your page result 
class will allow you to access all function in the MySQL class. I 
usually reference functions in the parent class like this:
parent::FunctionName()

You still reference functions in the current class using $this->, that 
way you can have functions of the same name in both classes.

On Jan 20, 2005, at 9:17 PM, Phillip S. Baker wrote:
Greetings all,
I have a class I use for MySQL connection and functions.
I also have a class that I use to create Paged Results.
The paged results class connects to a DB and uses allot of sql calls 
to make
this happen. I am noticing that it does allot that the MySQL class 
does.

What I would like to do is to Have the paged results extend the MySQL 
class
so it can use the functions within that class so I can keep them 
updated in
just one place. How would I go about doing that?? Is it as simple as
something like this (this is shortened for convience)??

class Mysql {
 var $results;
 var $dbcnx;
 function Mysql($query, $cnx) { // Constructor function
   $this->dbcnx = $cnx;
   if (!$this->results = @mysql_query($query))
$this->_error("There was an error with executing your query. Try 
again
later.", $query);
 }
}

class PageResultSet extends MySQL {
 var $results;
 function PageResultSet ($query,$pageSize,$resultpage,$cnx) {
  $this->results = @mysql_query($query,$cnx) or $this->_error('Error 
Running
your search. Try back later.', $query);
  $this->pageSize = $pageSize;
  if ((int)$resultpage <= 0) $resultpage = 1;
  if ($resultpage > $this->getNumPages())
  $resultpage = $this->getNumPages();
  $this->setPageNum($resultpage);
 }
}

I would like to be able to pass the results from the MySQL class to the
PageResultSet class without have to do the query over and such.
How would I go about coding that? I am not clear on that.
Also can I extend a function in PageResultSet that is started in 
MySQL??
In MySQL I have
 function fetchAssoc() {
  if (!$this->results) return FALSE;
  $this->row++;
  return mysql_fetch_assoc($this->results);
 }

In PageResultSet I have
 function fetchAssoc() {
  if (!$this->results) return FALSE;
  if ($this->row >= $this->pageSize) return FALSE;
  $this->row++;
  return mysql_fetch_assoc($this->results);
 }
Can I just write something like within PageResultSet
function fetchAssocPRS extends fetchAssoc () {
  if ($this->row >= $this->pageSize) return FALSE;
}
Thanks for the help.
--
Blessed Be
Phillip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

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


RE: [PHP] Re: REPOST: Serving WML

2005-01-21 Thread Mikey
> This link will probably help you out:
> http://www.hawhaw.de/faq.htm

Lovely jubbly!  That is all I need now.

I just got through with talking to Virgin (phone company) and they have told
me that they have been having problems with their GPRS gateway over the past
few days, and having checked I can't even see their own pages!!! So, maybe
my pages are OK after all.

Again, thanks a lot for the link - anyway of avoiding the steep part of the
learning curve is good with me.

Mikey

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



RE: [PHP] REPOST: Serving WML

2005-01-21 Thread tg-php
Sorry, I didn't completely follow this thread (deleted the messages before I 
really read them).

But I've served WAP/WML before.  Made a couple of basic WML scripts and was 
able to  access them via my cell phone.

I posted them on a regular web server, nothing fancy.  All I had to do is make 
sure the headers being output were correct.   There are a ton of cell phone 
emulator programs for the PC to test to see if your script is working properly 
(saving you from having to do all your testing on your cell phone).  OpenWave 
makes a browser for many many cell phones and I believe they have an emulator.  
There are a couple other big ones, some that will emulate different types of 
cell phones.  Forget the name now, but Google will tell you.

First I used this script as my index.php (default file that's served out):
### index.php
http://www.gryffyndevelopment.com/index2wap.php";; // ABSOLUTE URL 
to your WML file

header("302 Moved Temporarily");   // Force the browser to load the WML file 
instead
header("Location: ".$redirect);
?>
###

Here's the script that it was redirected to:

### index2wap.php
");
?>

http://www.wapforum.org/DTD/wml_1.1.xml";>




  
  
testing
  





  
  
testing2
  




###


I don't think it's any different for GRPS (I'm on SprintPCS so it's..err.. CDMA 
I believe for the network protocol).  As long as the header is correct and the 
script is correct (WML is VERY strict unlike HTML) then you shouldn't have a 
problem.

If you want to do graphics, look for a WBMP converter.

If you have a newer phone, you might be able to do regular HTML or something 
else.   My stuff was all made to use old green background/black LCD text type 
cell phone.  Havn't played with it in ages, but thought I'd post what I had as 
an example.  Everything else can be done with a PHP backend to snag your email 
via POP3 or whatever you're trying to do.   Everything after that is WML and 
not really pertenant (sp?) to this mailing list.

Good luck!

-TG




= = = Original message = = =

> you own a phone company? get one of your lakey sysadmins to fix up what
> you need ;-)

LOL!  The trouble with lackey sysadmins is that they never do what they are
told, always what's "kewl" - I have long since lost the energy required to
beat them into submission!

> just like with a std net connection you need to actually _have_ a
> connection, and in your case you need to be able to reach the machine in
> question (i.e. not connect thru a gateway that only give you access to
> servers run by your connection provider).
> 
> a 5 second google gave me this page: http://www.filesaveas.com/gprs.html
> maybe that helps you on your way?
>
> whatever you do you need to cough up money for a GPRS connection :-)
> 

All I want to do is to be able to allow access to my email from my phone, to
start off with and then move slowly from there.

Mikey

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



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] Re: REPOST: Serving WML

2005-01-21 Thread Jochem Maas
Jason Barnett wrote:
Mikey wrote:
Hi again - thought it best to keep the two topics separately...
I have just leased a virtual hosting package and want to provide GPRS
access to my email server using WML.

I have never built a site that served WML, but I know a 
small bit about it

Now I have a couple of test pages that I have put up on the server 
that I
want to view, but can't seem to get to them.  I am not really sure about
how GPRS works, but I thought that any internet server could serve 
WML as
long as it was valid.

OK Google tells me GPRS is this: 
http://www.gsmworld.com/technology/gprs/intro.shtml#1
(Sorry, like I said I've never served WML before!)
WML = wireless markup language - an XML definition not unlike XHTML but 
much more cutdown and geared toward, small mobile platforms (usually 
with tiny screens and a limited input system - i.e. no 104-key keyboard :-)

quoting the site above:"
Because it uses the same protocols, the GPRS network can be viewed as a 
sub-network of the Internet with GPRS capable mobile phones being viewed 
as mobile hosts. This means that each GPRS terminal can potentially have 
its own IP address and will be addressable as such.
"

I definitely have never treaded into these waters.  If GPRS is a 
protocol that is built on top of HTTP then I can think of no reason why 
lets not confuse the issue here - GPRS is NOT a protocol built on top of 
HTTP - if anything its the other way around. GPRS is a physical network 
spec (is my language correct there?) capable of hosting a TCP/IP 
environment upon which HTTP can travel so to speak.

your Apache server shouldn't be able to do this.  The main task, I 
think, would then be to check the browser's user-agent and generate WML 
if it is a browser built for a phone.
Jason is correct in this. a slightly different way would be to setup a 
seperate site (e.g. vhost) geared purely to WML output (e.g. 
wml.yourdomain.com) but the end result is the same.

obviously you will have to sort out the connection to the 'web' via your 
phone. then its just a case of pointing it at you WML server to view a 
page. when your at that stage you can actually get it to the fun side of 
writing a secure php app that will output your email as WML pages
hacing said that all those newfangled all-singing-all-dancing phones of 
yester-minute have minibrowsers that are capable of viewing std (X)HTML 
(e.g. the Opera mobile browser?) - in which case layout is your biggest 
problem (i.e. cos of the small screen)

there maybe a need to read/write special HTTP header 'by hand' in order 
to fully communicate with the WML device... PHP give access to raw 
request data so that should be a 'big' problem.

good luck on this - sounds interesting! keep us informed on how you get 
on :-)

Lucky you... I actually looked through some packages once upon a time to 
 serve WML.  I remember liking what I saw from HAWHAW; perhaps it will 
work for you?

This link will probably help you out:
http://www.hawhaw.de/faq.htm
I have read a little about gateways and from what I have read it seems
that it would be my phone company that was responsible for providing 
that.

AFAIK yes, mobile phone companies provide the gateways to the net. 
Sprint actually has a lot of stuff out there to help developers provide 
content to their system, but I never got into it much (I remember it 
being more work than my just-for-fun project justified).

Any ideas?
Mikey

Any takers for this question?
Pulease?!?!?


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


Re: [PHP] Re: REPOST: Serving WML

2005-01-21 Thread Jochem Maas
Mikey wrote:
This link will probably help you out:
http://www.hawhaw.de/faq.htm

Lovely jubbly!  That is all I need now.
I just got through with talking to Virgin (phone company) and they have told
me that they have been having problems with their GPRS gateway over the past
few days, and having checked I can't even see their own pages!!! So, maybe
my pages are OK after all.
Again, thanks a lot for the link - anyway of avoiding the steep part of the
learning curve is good with me.
the thing with the learning curve is that the only way to avoid the 
sleep part is by standing still ;-)

glad to hear you're making progress.
Mikey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] REPOST: Serving WML

2005-01-21 Thread Jochem Maas
top posting (ouch) just to say 'rocking info' TG!
[EMAIL PROTECTED] wrote:
Sorry, I didn't completely follow this thread (deleted the messages before I really read them).
...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] display imap attached files?

2005-01-21 Thread Fredrik Hampus
Hi!
Iam trying too make a page where the function is to display an attached  
.jpg file
from a imap mailbox. This is a small code i found and rewrote some...


include '/etc/labbuser';
$mbox = imap_open ("{localhost:993/imap/ssl/novalidate-cert}INBOX",  
"$imuser", "$impass");
$mno = "57";

$parttypes = array ("text", "multipart", "message", "application",  
"audio", "image", "video", "other");
 function buildparts ($struct, $mno = "") {
   global $parttypes;
   switch ($struct->type):
 case 1:
   $r = array ();
   $i = 1;
   foreach ($struct->parts as $part)
 $r[] = buildparts ($part, $mno.".".$i++);

   return implode (", ", $r);
 case 2:
   return "{".buildparts ($struct->parts[0], $mno)."}";
 default:
echo "--Size--";
echo $struct->bytes;
echo " ";
echo $struct->subtype;
echo "";
if ($struct->subtype == "JPEG") {
echo "MATCH";
echo "";
}
   return ''.$parttypes[$struct->type]."/".strtolower ($struct->subtype)."";
   endswitch;
 }
  $struct = imap_fetchstructure ($mbox, $mno);

  echo buildparts ($struct);
imap_close($mbox);
?>
This will display how many parts there is in the mail and the size of each  
one of them and what type they are.
but how do a display the image of an attached jpg file on a webpage?

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


[PHP] regular expression help

2005-01-21 Thread Jason
Simple functions to check & fix if necessary invalid formating of a MAC 
address... I seem to be having problems with the global variable $mac 
not being returned from the fix_mac() function.  Any help is appreciated.


/*
 * ex. 00:AA:11:BB:22:CC
 */
function chk_mac( $mac ) {
 if( eregi( 
"^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$", 
$mac ) ) {
  return 0;
 } else {
  return 1;
 }
}

/*
 * check validity of MAC & do replacements if necessary
 */
function fix_mac( $mac ) {
 global $mac;
 /* strip the dash & replace with a colon */
 if( eregi( 
"^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$", 
$mac ) ) {
  $mac = preg_replace( "/\-/", ":", $mac );
  return $mac;
 }
 /* add a colon for every two characters */
 if( eregi( "^[0-9A-Fa-f]{12}$", $mac ) ) {
  /* split up the MAC and assign new var names */
  @list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( $mac, 
2 );
  /* put it back together with the required colons */
  $mac = $mac1 . ":" . $mac2 . ":" . $mac3 . ":" . $mac4 . ":" . $mac5 
. ":" . $mac6;
  return $mac;
 }
}

// do our checks to make sure we are using these damn things right
$mac1 = "00aa11bb22cc";
$mac2 = "00-aa-11-bb-22-cc";
$mac3 = "00:aa:11:bb:22:cc";
// make sure it is global
global $mac;
// if mac submitted is invalid check & fix if necessary
if( chk_mac( $mac1 ) != 0 ) {
 $mac = fix_mac( $mac1 ); echo $mac1 . " converted to " . $mac . "";
}
if( chk_mac( $mac2 ) != 0 ) {
 $mac = fix_mac( $mac2 ); echo $mac2 . " converted to " . $mac . "";
}
if( chk_mac( $mac3 ) != 0 ) {
 $mac = fix_mac( $mac3 ); echo $mac3 . " converted to " . $mac . "";
}
?>
--
Jason Gerfen
"And remember... If the ladies
 don't find you handsome, they
 should at least find you handy..."
 ~The Red Green show
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: REPOST: Serving WML

2005-01-21 Thread Jason Barnett
Mikey wrote:
This link will probably help you out:
http://www.hawhaw.de/faq.htm

Lovely jubbly!  That is all I need now.
I just got through with talking to Virgin (phone company) and they have told
me that they have been having problems with their GPRS gateway over the past
few days, and having checked I can't even see their own pages!!! So, maybe
my pages are OK after all.
Again, thanks a lot for the link - anyway of avoiding the steep part of the
learning curve is good with me.
Mikey
Mikey: I'm not sure what your exact goals are here.  If email is all you 
need (which is what I was after as well) I found a cool shortcut.  You 
can just set up your server to page your phone with SMS whenever you get 
email.  You'll need to look into your provider's webpage to see the 
exact process, but basically there is an "inbox" for each phone 
number/account and you can send emails through SMS / MMS in that way. 
Obviously if you want to be able to receive anything but text you'll 
need MMS.

--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | 
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

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


Re: [PHP] Extending a Class

2005-01-21 Thread Matthew Weier O'Phinney
* Brent Baisley <[EMAIL PROTECTED]> :
> You've got most of it. Just adding "extends MySQL" to your page result 
> class will allow you to access all function in the MySQL class. I 
> usually reference functions in the parent class like this:
> parent::FunctionName()

This is a bad practice when inheriting, usually -- the whole point is
that the parent classes methods are directly available to the child
class without using such constructs. 

$this-> FunctionName()

will execute the method 'FunctionName' from the current class -- or any
parent class if it is not defined in the current class. There's one good
exception:

> You still reference functions in the current class using $this-> , that 
> way you can have functions of the same name in both classes.

To make a method in the child class of the same name as a method in the
parent class is called overriding -- and is usually done to either
change the behaviour of that method (for example, if you want to do
something completely different than what was done in the parent class)
or to supplement the behaviour of the parent method -- for instance, if
the child class wishes to do some processing before or after the parent
method is executed. In this latter case, you *will* use the
parent::FunctionName() construct -- so that you can actually access the
method you're currently overriding:

class parentClass 
{
// ...

function someMethod() 
{
// do something
}
}

class someClass extends parentClass 
{
// ...

function someMethod() 
{
// do some processing first
parent::someMethod();
// do some postprocessing
}
}

So, in the OP's case, he might want to have override the fetchAssoc()
method in his PageResultSet subclass so that it tacks on the LIMIT info
to the SQL statement, and then have it call the parent (Mysql class)
fetchAssoc() method with that modified SQL.

> On Jan 20, 2005, at 9:17 PM, Phillip S. Baker wrote:
>
> > Greetings all,
> >
> > I have a class I use for MySQL connection and functions.
> >
> > I also have a class that I use to create Paged Results.
> >
> > The paged results class connects to a DB and uses allot of sql calls
> > to make this happen. I am noticing that it does allot that the MySQL
> > class does.
> >
> > What I would like to do is to Have the paged results extend the
> > MySQL class so it can use the functions within that class so I can
> > keep them updated in just one place. How would I go about doing
> > that?? Is it as simple as something like this (this is shortened for
> > convience)??
> >
> > class Mysql {
> >  var $results;
> >  var $dbcnx;
> >
> >  function Mysql($query, $cnx) { // Constructor function
> >$this-> dbcnx = $cnx;
> >if (!$this-> results = @mysql_query($query))
> > $this-> _error("There was an error with executing your query. Try 
> > again
> > later.", $query);
> >  }
> > }
> >
> > class PageResultSet extends MySQL {
> >  var $results;
> >
> >  function PageResultSet ($query,$pageSize,$resultpage,$cnx) {
> >
> >   $this-> results = @mysql_query($query,$cnx) or $this-> _error('Error 
> > Running
> > your search. Try back later.', $query);
> >   $this-> pageSize = $pageSize;
> >   if ((int)$resultpage <= 0) $resultpage = 1;
> >   if ($resultpage > $this-> getNumPages())
> >   $resultpage = $this-> getNumPages();
> >   $this-> setPageNum($resultpage);
> >  }
> > }
> >
> > I would like to be able to pass the results from the MySQL class to the
> > PageResultSet class without have to do the query over and such.
> > How would I go about coding that? I am not clear on that.
> >
> > Also can I extend a function in PageResultSet that is started in 
> > MySQL??
> > In MySQL I have
> >  function fetchAssoc() {
> >   if (!$this-> results) return FALSE;
> >   $this-> row++;
> >   return mysql_fetch_assoc($this-> results);
> >  }
> >
> > In PageResultSet I have
> >  function fetchAssoc() {
> >   if (!$this-> results) return FALSE;
> >   if ($this-> row > = $this-> pageSize) return FALSE;
> >   $this-> row++;
> >   return mysql_fetch_assoc($this-> results);
> >  }
> >
> > Can I just write something like within PageResultSet
> > function fetchAssocPRS extends fetchAssoc () {
> >   if ($this-> row > = $this-> pageSize) return FALSE;
> > }
> >
> > Thanks for the help.
> >
> > --
> > Blessed Be
> >
> > Phillip
> >
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >


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

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



Re: [PHP] regular expression help

2005-01-21 Thread Jason Wong
On Saturday 22 January 2005 00:12, Jason wrote:
> Simple functions to check & fix if necessary invalid formating of a MAC
> address... I seem to be having problems with the global variable $mac
> not being returned from the fix_mac() function.  Any help is appreciated.

Your subject says "regular expression help" but your problem is "with the 
global variable $mac ...". So which is it? If you're going to declare a 
variable as 'global' then it has to be done in every function in which that 
variable is to be used.

Which means here:

> function chk_mac( $mac ) {
>   if( eregi(
> "^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-
>f]{2}\:[0-9A-Fa-f]{2}$", $mac ) ) {
>return 0;
>   } else {
>return 1;
>   }
> }

and wherever else.

-- 
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
--
New Year Resolution: Ignore top posted posts

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



[PHP] Re: regular expression help

2005-01-21 Thread Jason
Jason wrote:
Simple functions to check & fix if necessary invalid formating of a MAC 
address... I seem to be having problems with the global variable $mac 
not being returned from the fix_mac() function.  Any help is appreciated.

global $mac;
 if( eregi( 
"^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$", 
$mac ) ) {
  return 0;
 } else {
  return 1;
 }
}

/*
 * check validity of MAC & do replacements if necessary
 */
function fix_mac( $mac ) {
 global $mac;
 /* strip the dash & replace with a colon */
 if( eregi( 
"^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$", 
$mac ) ) {
  $mac = preg_replace( "/\-/", ":", $mac );
  return $mac;
 }
 /* add a colon for every two characters */
 if( eregi( "^[0-9A-Fa-f]{12}$", $mac ) ) {
  /* split up the MAC and assign new var names */
  @list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( $mac, 
2 );
  /* put it back together with the required colons */
  $mac = $mac1 . ":" . $mac2 . ":" . $mac3 . ":" . $mac4 . ":" . $mac5 . 
":" . $mac6;
  return $mac;
 }
}

// do our checks to make sure we are using these damn things right
$mac1 = "00aa11bb22cc";
$mac2 = "00-aa-11-bb-22-cc";
$mac3 = "00:aa:11:bb:22:cc";
// make sure it is global
global $mac;
// if mac submitted is invalid check & fix if necessary
if( chk_mac( $mac1 ) != 0 ) {
 $mac = fix_mac( $mac1 ); echo $mac1 . " converted to " . $mac . "";
}
if( chk_mac( $mac2 ) != 0 ) {
 $mac = fix_mac( $mac2 ); echo $mac2 . " converted to " . $mac . "";
}
if( chk_mac( $mac3 ) != 0 ) {
 $mac = fix_mac( $mac3 ); echo $mac3 . " converted to " . $mac . "";
}
?>
Still does not resolve the problem.  declaring $mac as global in the 
chk_mac() function.

--
Jason Gerfen
Student Computing
Marriott Library
801.585.9810
[EMAIL PROTECTED]
"And remember... If the ladies
 don't find you handsome, they
 should at least find you handy..."
 ~The Red Green show
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Categories and subcategories

2005-01-21 Thread Phpu
Hi,
I need to create multiple categories and subcategories using php and mysql. 
Something like that

- category 1
- subcat 1.1
- subcat 1.2
  - subcat 1.2.1
  - subcat 1.2.2
- category 2


Does anyone know a godd totorial how to create this in pahp and how to make the 
structure of the database?

Thanks in advance for your help 

[PHP] Hidden images.

2005-01-21 Thread Rob Adams
Ok - I've finally got something that sometimes works.

http://smada.com/images/hide_image.php

I talked to a Delphi programmer, who whipped something out in about 20 
minutes.  My code is a translation of his.

function colorParts($col)
{
  $parts['r'] = ($col >> 16) & 0xFF;
  $parts['g'] = ($col >> 8) & 0xFF;
  $parts['b'] = $col & 0xFF;
  return $parts;
}

function NewRange($oldval)
{
  return floor($oldval/255*80+87);
}

function ShiftVal($ov1, $ov2)
{
  $nv = floor($ov1 + 1.8 * (newrange(127) - $ov2));
  if ($nv < 0)
return 0;
  else if ($nv > 255)
return 255;
  else
return $nv;
}

function nrw ($oldcol)
{
  $newr = NewRange(($oldcol >> 16) & 0xFF);
  $newg = NewRange(($oldcol >> 8) & 0xFF);
  $newb = NewRange($oldcol & 0xFF);
  return ($newr << 16) + ($newg << 8) + $newb;
}

function svw($oc1, $oc2)
{
  $p1 = colorParts($oc1);
  $p2 = colorParts($oc2);
  $nvr = ShiftVal($p1['r'],$p2['r']);
  $nvg = ShiftVal($p1['g'],$p2['g']);
  $nvb = ShiftVal($p1['b'],$p2['b']);
  return ($nvr << 16) + ($nvg << 8) + $nvb;
}

function &openImage($file, $forcetruecolor = false)
{
 $data = getimagesize($file);
 $res = null;
 switch($data[2])
 {
  case 1:
   $res = imagecreatefromgif($file);
break;
  case 2:
   $res = imagecreatefromjpeg($file);
break;
  case 3:
   $res = imagecreatefrompng($file);
break;
 }
 if ($forcetruecolor && !imageistruecolor($res))
 {
  $size = getimagesize($file);
  $r2 = imagecreatetruecolor($size[0], $size[1]);
  imagecopy($r2, $res, 0, 0, 0, 0, $size[0], $size[1]);
  imagedestroy($res);
  $res =& $r2;
 }
 return $res;
}


include('two_image_upload.inc.php');
$main = openImage($main_file, true);
$hid = openImage($hid_file, true);
$size = getimagesize($main_file);
$size2 = getimagesize($hid_file);
$img = imagecreatetruecolor($size[0], $size[1]);

for ($y = 0; $y < $size[1]; $y++)
{
 $y2 = floor(($y / $size[1]) * $size2[1]);
 for ($x = 0; $x < $size[0]; $x++)
 {
  $x2 = floor(($x / $size[0]) * $size2[0]);
if (($x + $y) % 2 == 0) //use main image
  imagesetpixel($img, $x, $y, imagecolorat($main, $x, $y));
else //use hidden image
{
 $color = imagecolorat($hid, $x2, $y2);
 imagesetpixel($img, $x,$y, nrw($color));
  if ($y % 2 == 1)
$x3 = $x-1;
  else
$x3 = $x+1;
  if ($x3 >= 0 and $x3 < $size[0])
  {
   $color = svw(imagecolorat($img, $x3, $y), imagecolorat($img, $x, 
$y));
   imagesetpixel($img, $x3, $y, $color);
  }
}
 }
}

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



[PHP] Static Array declaration within class PHP5

2005-01-21 Thread Marek
Hello

I'm trying to create a public static array within a class.(PHP5). 

First - the following fails: 

class yadayada { 
public static $tester[0]="something"; 
public static $tester[1]="something 1"; 

Second - However the following works:

class yadayada { 
public static $tester = array (0 => "something", 1 >="something 1"); 

My question is this: I have an array that has about some 150 different values 
and using the second example would get very very messy, is there another method 
of doing this ? The first example(which fails) is the cleanest, is there 
anything I can do ? 

Thank you



[PHP] array problem

2005-01-21 Thread Ahmed Abdel-Aliem
hi
if i have an array 

$listing1 = array(array('title'=>'yahoo', 'redirect'=>'www.yahoo.com',
'info'=>'yahoo website'), array(title=>'msn',
'redirect'=>'www.msn.com', 'info=>'msn website'));

$listing2 = array(array('name'=>'lycos', 'link'=>'www.lycos.com',
'description'=>'lycos website'), array(name=>'me2resh',
'link'=>'www.me2resh.com', 'description'=>'me2resh website'));

how can i group them together into one array to be :

$listing3 = array(array('header'=>'lycos', 'url'=>'www.lycos.com',
'information'=>'lycos website'), array(header=>'me2resh',
'url'=>'www.me2resh.com', 'information'=>'me2resh website'),
array('header'=>'lycos', 'url'=>'www.lycos.com', 'information'=>'lycos
website'), array(header=>'me2resh', 'url'=>'www.me2resh.com',
'information'=>'me2resh website'));

and then how can i sort them by the value of information for example
can anyone help me please with this ?


Ahmed Abdel-Aliem
Web Developer
www.ApexScript.com
0101108551

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



Re: [PHP] Re: regular expression help

2005-01-21 Thread RaTT
Hi, 

>From what i can see you dont even need to call global, as your passing
variables to the function ? this could be causing the script to
confuse itself.

hth


On Fri, 21 Jan 2005 09:30:21 -0700, Jason <[EMAIL PROTECTED]> wrote:
> Jason wrote:
> > Simple functions to check & fix if necessary invalid formating of a MAC
> > address... I seem to be having problems with the global variable $mac
> > not being returned from the fix_mac() function.  Any help is appreciated.
> >
> >  > /*
> >  * ex. 00:AA:11:BB:22:CC
> >  */
> > function chk_mac( $mac ) {
>  global $mac;
> >  if( eregi(
> > "^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$",
> > $mac ) ) {
> >   return 0;
> >  } else {
> >   return 1;
> >  }
> > }
> >
> > /*
> >  * check validity of MAC & do replacements if necessary
> >  */
> > function fix_mac( $mac ) {
> >  global $mac;
> >  /* strip the dash & replace with a colon */
> >  if( eregi(
> > "^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$",
> > $mac ) ) {
> >   $mac = preg_replace( "/\-/", ":", $mac );
> >   return $mac;
> >  }
> >  /* add a colon for every two characters */
> >  if( eregi( "^[0-9A-Fa-f]{12}$", $mac ) ) {
> >   /* split up the MAC and assign new var names */
> >   @list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( $mac,
> > 2 );
> >   /* put it back together with the required colons */
> >   $mac = $mac1 . ":" . $mac2 . ":" . $mac3 . ":" . $mac4 . ":" . $mac5 .
> > ":" . $mac6;
> >   return $mac;
> >  }
> > }
> >
> > // do our checks to make sure we are using these damn things right
> > $mac1 = "00aa11bb22cc";
> > $mac2 = "00-aa-11-bb-22-cc";
> > $mac3 = "00:aa:11:bb:22:cc";
> >
> > // make sure it is global
> > global $mac;
> >
> > // if mac submitted is invalid check & fix if necessary
> > if( chk_mac( $mac1 ) != 0 ) {
> >  $mac = fix_mac( $mac1 ); echo $mac1 . " converted to " . $mac . "";
> > }
> > if( chk_mac( $mac2 ) != 0 ) {
> >  $mac = fix_mac( $mac2 ); echo $mac2 . " converted to " . $mac . "";
> > }
> > if( chk_mac( $mac3 ) != 0 ) {
> >  $mac = fix_mac( $mac3 ); echo $mac3 . " converted to " . $mac . "";
> > }
> >
> > ?>
> Still does not resolve the problem.  declaring $mac as global in the
> chk_mac() function.
> 
> --
> Jason Gerfen
> Student Computing
> Marriott Library
> 801.585.9810
> [EMAIL PROTECTED]
> 
> "And remember... If the ladies
>   don't find you handsome, they
>   should at least find you handy..."
>   ~The Red Green show
> 
> --
> 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: regular expression help

2005-01-21 Thread Jason
You were right, I removed the reference to global $mac and it started 
working great.  Thanks.  It seems sometimes another set of eyes to catch 
stuff really helps... thanks.

Jason wrote:
Jason wrote:
Simple functions to check & fix if necessary invalid formating of a 
MAC address... I seem to be having problems with the global variable 
$mac not being returned from the fix_mac() function.  Any help is 
appreciated.

global $mac;
 if( eregi( 
"^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$", 
$mac ) ) {
  return 0;
 } else {
  return 1;
 }
}

/*
 * check validity of MAC & do replacements if necessary
 */
function fix_mac( $mac ) {
 global $mac;
 /* strip the dash & replace with a colon */
 if( eregi( 
"^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$", 
$mac ) ) {
  $mac = preg_replace( "/\-/", ":", $mac );
  return $mac;
 }
 /* add a colon for every two characters */
 if( eregi( "^[0-9A-Fa-f]{12}$", $mac ) ) {
  /* split up the MAC and assign new var names */
  @list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( 
$mac, 2 );
  /* put it back together with the required colons */
  $mac = $mac1 . ":" . $mac2 . ":" . $mac3 . ":" . $mac4 . ":" . $mac5 
. ":" . $mac6;
  return $mac;
 }
}

// do our checks to make sure we are using these damn things right
$mac1 = "00aa11bb22cc";
$mac2 = "00-aa-11-bb-22-cc";
$mac3 = "00:aa:11:bb:22:cc";
// make sure it is global
global $mac;
// if mac submitted is invalid check & fix if necessary
if( chk_mac( $mac1 ) != 0 ) {
 $mac = fix_mac( $mac1 ); echo $mac1 . " converted to " . $mac . "";
}
if( chk_mac( $mac2 ) != 0 ) {
 $mac = fix_mac( $mac2 ); echo $mac2 . " converted to " . $mac . "";
}
if( chk_mac( $mac3 ) != 0 ) {
 $mac = fix_mac( $mac3 ); echo $mac3 . " converted to " . $mac . "";
}
?>
Still does not resolve the problem.  declaring $mac as global in the 
chk_mac() function.


--
Jason Gerfen
"And remember... If the ladies
 don't find you handsome, they
 should at least find you handy..."
 ~The Red Green show
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Extending a Class

2005-01-21 Thread Brent Baisley
You're absolutely correct. I was debating on whether to get into 
inheritance and overloading. I just settled on what PEAR tends to use 
rather than go into more detail.

Thanks for clarifying.
On Jan 21, 2005, at 11:18 AM, Matthew Weier O'Phinney wrote:
* Brent Baisley <[EMAIL PROTECTED]> :
You've got most of it. Just adding "extends MySQL" to your page result
class will allow you to access all function in the MySQL class. I
usually reference functions in the parent class like this:
parent::FunctionName()
This is a bad practice when inheriting, usually -- the whole point is
that the parent classes methods are directly available to the child
class without using such constructs.
$this-> FunctionName()
will execute the method 'FunctionName' from the current class -- or any
parent class if it is not defined in the current class. There's one 
good
exception:

You still reference functions in the current class using $this-> , 
that
way you can have functions of the same name in both classes.
To make a method in the child class of the same name as a method in the
parent class is called overriding -- and is usually done to either
change the behaviour of that method (for example, if you want to do
something completely different than what was done in the parent class)
or to supplement the behaviour of the parent method -- for instance, if
the child class wishes to do some processing before or after the parent
method is executed. In this latter case, you *will* use the
parent::FunctionName() construct -- so that you can actually access the
method you're currently overriding:
class parentClass
{
// ...
function someMethod()
{
// do something
}
}
class someClass extends parentClass
{
// ...
function someMethod()
{
// do some processing first
parent::someMethod();
// do some postprocessing
}
}
So, in the OP's case, he might want to have override the fetchAssoc()
method in his PageResultSet subclass so that it tacks on the LIMIT info
to the SQL statement, and then have it call the parent (Mysql class)
fetchAssoc() method with that modified SQL.
On Jan 20, 2005, at 9:17 PM, Phillip S. Baker wrote:
Greetings all,
I have a class I use for MySQL connection and functions.
I also have a class that I use to create Paged Results.
The paged results class connects to a DB and uses allot of sql calls
to make this happen. I am noticing that it does allot that the MySQL
class does.
What I would like to do is to Have the paged results extend the
MySQL class so it can use the functions within that class so I can
keep them updated in just one place. How would I go about doing
that?? Is it as simple as something like this (this is shortened for
convience)??
class Mysql {
 var $results;
 var $dbcnx;
 function Mysql($query, $cnx) { // Constructor function
   $this-> dbcnx = $cnx;
   if (!$this-> results = @mysql_query($query))
$this-> _error("There was an error with executing your query. Try
again
later.", $query);
 }
}
class PageResultSet extends MySQL {
 var $results;
 function PageResultSet ($query,$pageSize,$resultpage,$cnx) {
  $this-> results = @mysql_query($query,$cnx) or $this-> 
_error('Error
Running
your search. Try back later.', $query);
  $this-> pageSize = $pageSize;
  if ((int)$resultpage <= 0) $resultpage = 1;
  if ($resultpage > $this-> getNumPages())
  $resultpage = $this-> getNumPages();
  $this-> setPageNum($resultpage);
 }
}

I would like to be able to pass the results from the MySQL class to 
the
PageResultSet class without have to do the query over and such.
How would I go about coding that? I am not clear on that.

Also can I extend a function in PageResultSet that is started in
MySQL??
In MySQL I have
 function fetchAssoc() {
  if (!$this-> results) return FALSE;
  $this-> row++;
  return mysql_fetch_assoc($this-> results);
 }
In PageResultSet I have
 function fetchAssoc() {
  if (!$this-> results) return FALSE;
  if ($this-> row > = $this-> pageSize) return FALSE;
  $this-> row++;
  return mysql_fetch_assoc($this-> results);
 }
Can I just write something like within PageResultSet
function fetchAssocPRS extends fetchAssoc () {
  if ($this-> row > = $this-> pageSize) return FALSE;
}
Thanks for the help.
--
Blessed Be
Phillip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

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

Re: [PHP] regular expression help

2005-01-21 Thread Bret Hughes
On Fri, 2005-01-21 at 10:12, Jason wrote:
> Simple functions to check & fix if necessary invalid formating of a MAC 
> address... I seem to be having problems with the global variable $mac 
> not being returned from the fix_mac() function.  Any help is appreciated.
> 
>  /*
>   * ex. 00:AA:11:BB:22:CC
>   */
> function chk_mac( $mac ) {
>   if( eregi( 
> "^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$",
>  
> $mac ) ) {
>return 0;
>   } else {
>return 1;
>   }
> }
> 
> /*
>   * check validity of MAC & do replacements if necessary
>   */
> function fix_mac( $mac ) {
>   global $mac;
>   /* strip the dash & replace with a colon */
>   if( eregi( 
> "^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$",
>  
> $mac ) ) {
>$mac = preg_replace( "/\-/", ":", $mac );
>return $mac;
>   }
>   /* add a colon for every two characters */
>   if( eregi( "^[0-9A-Fa-f]{12}$", $mac ) ) {
>/* split up the MAC and assign new var names */
>@list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( $mac, 
> 2 );
>/* put it back together with the required colons */
>$mac = $mac1 . ":" . $mac2 . ":" . $mac3 . ":" . $mac4 . ":" . $mac5 
> . ":" . $mac6;
>return $mac;
>   }
> }
> 
> // do our checks to make sure we are using these damn things right
> $mac1 = "00aa11bb22cc";
> $mac2 = "00-aa-11-bb-22-cc";
> $mac3 = "00:aa:11:bb:22:cc";
> 
> // make sure it is global
> global $mac;
> 

if you want to use globals you need to use the global in the function
not the main body.

afaict you don't need globals at all you pass mac1 to each function and
use it as $mac in the function (exactly what you want to do) and return
local $mac to $mac in the main body.  perfectly legal.  If you set mac
to global in the function I suspect that you end up not using  the local
mac and are testing an empty var in the first pass of fix_mac.

remove the global statements and you are well on your way.

Bret

> // if mac submitted is invalid check & fix if necessary
> if( chk_mac( $mac1 ) != 0 ) {
>   $mac = fix_mac( $mac1 ); echo $mac1 . " converted to " . $mac . "";
> }
> if( chk_mac( $mac2 ) != 0 ) {
>   $mac = fix_mac( $mac2 ); echo $mac2 . " converted to " . $mac . "";
> }
> if( chk_mac( $mac3 ) != 0 ) {
>   $mac = fix_mac( $mac3 ); echo $mac3 . " converted to " . $mac . "";
> }
> 
> ?>
> -- 
> Jason Gerfen
> 
> "And remember... If the ladies
>   don't find you handsome, they
>   should at least find you handy..."
>   ~The Red Green show
> 
> -- 
> 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] oo arcitecture (Re: [PHP] Extending a Class)

2005-01-21 Thread Ben Edwards
Your email prompted me to think about architecture.  What I have is;_

a database class which is the only class with direct access to the database.

a table class, which is passed the database class on instantiation.  

a presenter class which is passed the table class during instantiation.

This means that if you want to render html you use and instance of the
presenter class but you can also call methods on the database object
directly to, for example, update the database.  You will probably want
a valuator class to validate user input.  If you have and extended
data dictionary (i.e. validation rules in the database) you would have
a extended data dictionary class you pass to the valuator (which
itself would have the database passed to in on instantiation).

What I cant quite work out is what to do about html related methods
that do not relate to a database table (i.e.rendering table
top/middle/bottom).  Maybe you want a html class which is a composite
of the presenter class or can be accessed directly for non-table
related presentation?

Ben

On Thu, 20 Jan 2005 18:17:47 -0800, Phillip S. Baker
<[EMAIL PROTECTED]> wrote:
> Greetings all,
> 
> I have a class I use for MySQL connection and functions.
> 
> I also have a class that I use to create Paged Results.
> 
> The paged results class connects to a DB and uses allot of sql calls to make
> this happen. I am noticing that it does allot that the MySQL class does.
> 
> What I would like to do is to Have the paged results extend the MySQL class
> so it can use the functions within that class so I can keep them updated in
> just one place. How would I go about doing that?? Is it as simple as
> something like this (this is shortened for convience)??
> 
> class Mysql {
> var $results;
> var $dbcnx;
> 
> function Mysql($query, $cnx) { // Constructor function
>   $this->dbcnx = $cnx;
>   if (!$this->results = @mysql_query($query))
>$this->_error("There was an error with executing your query. Try again
> later.", $query);
> }
> }
> 
> class PageResultSet extends MySQL {
> var $results;
> 
> function PageResultSet ($query,$pageSize,$resultpage,$cnx) {
> 
>  $this->results = @mysql_query($query,$cnx) or $this->_error('Error Running
> your search. Try back later.', $query);
>  $this->pageSize = $pageSize;
>  if ((int)$resultpage <= 0) $resultpage = 1;
>  if ($resultpage > $this->getNumPages())
>  $resultpage = $this->getNumPages();
>  $this->setPageNum($resultpage);
> }
> }
> 
> I would like to be able to pass the results from the MySQL class to the
> PageResultSet class without have to do the query over and such.
> How would I go about coding that? I am not clear on that.
> 
> Also can I extend a function in PageResultSet that is started in MySQL??
> In MySQL I have
> function fetchAssoc() {
>  if (!$this->results) return FALSE;
>  $this->row++;
>  return mysql_fetch_assoc($this->results);
> }
> 
> In PageResultSet I have
> function fetchAssoc() {
>  if (!$this->results) return FALSE;
>  if ($this->row >= $this->pageSize) return FALSE;
>  $this->row++;
>  return mysql_fetch_assoc($this->results);
> }
> 
> Can I just write something like within PageResultSet
> function fetchAssocPRS extends fetchAssoc () {
>  if ($this->row >= $this->pageSize) return FALSE;
> }
> 
> Thanks for the help.
> 
> --
> Blessed Be
> 
> Phillip
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Ben Edwards - Poole, UK, England
WARNING:This email contained partisan views - dont ever accuse me of
using the veneer of objectivity
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

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



[PHP] Re: Static Array declaration within class PHP5

2005-01-21 Thread Jason Barnett
Marek wrote:
Hello
I'm trying to create a public static array within a class.(PHP5). 

First - the following fails: 

class yadayada { 
public static $tester[0]="something"; 
public static $tester[1]="something 1"; 

Second - However the following works:
class yadayada { 
public static $tester = array (0 => "something", 1 >="something 1"); 
Since we are talking about a static variable then I think your only 
option is this.  I assume you want only one $tester array for this 
entire class, correct?

Visually another way of laying this out that looks less messy:
class yadayada {
public static $tester = array (
0   => "something",
1   => "something else",
2   => "...",
150 => "Finally done!"
  );
}

My question is this: I have an array that has about some 150 different values and using the second example would get very very messy, is there another method of doing this ? The first example(which fails) is the cleanest, is there anything I can do ? 

Thank you


--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | 
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

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


Re: [PHP] regular expression help

2005-01-21 Thread Richard Lynch
Jason wrote:
> Simple functions to check & fix if necessary invalid formating of a MAC
> address... I seem to be having problems with the global variable $mac
> not being returned from the fix_mac() function.  Any help is appreciated.
> function fix_mac( $mac ) {
>   global $mac;

It's really weird to both pass in $mac as an argument and to declare it
global...

Do one or the other, but not both.

Can't help you with the mess of Regex you've got though...

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

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



Re: [PHP] Extending a Class

2005-01-21 Thread Jason Barnett
Brent Baisley wrote:
You're absolutely correct. I was debating on whether to get into 
inheritance and overloading. I just settled on what PEAR tends to use 
rather than go into more detail.
Are you referring to the PEAR::isError (and similar function calls) that 
you see all over the place in PEAR code?  If this is what you meant, 
then let me add something.  Some PEAR classes don't require *any* object 
to exist.  These are what you call "static" classes and "static" methods.

When a class function is called statically (i.e. PEAR::isError) then it 
is pretty much like having a normal function called PEAR_isError(). 
There is no object and no properties except for static properties; and 
these static properties are variables that are tied to a class instead 
of an object.

The main benefits for PEAR developers doing things this way is so that 
they don't have to worry about name collisions and they can share 
certain variables between these "static" functions.

I'm starting to get off track (what else is new?  :) but if you like I 
can explain static variables a bit more as well.

Thanks for clarifying.
Long story short: inherit methods from parents.  Use those methods, 
unless there is a good reason not to use one.  If there is, then you 
override it in the child.  If you must use a *static* method from a 
class, then use the :: operator.


On Jan 21, 2005, at 11:18 AM, Matthew Weier O'Phinney wrote:
* Brent Baisley <[EMAIL PROTECTED]> :
You've got most of it. Just adding "extends MySQL" to your page result
class will allow you to access all function in the MySQL class. I
usually reference functions in the parent class like this:
parent::FunctionName()

This is a bad practice when inheriting, usually -- the whole point is
that the parent classes methods are directly available to the child
class without using such constructs.
$this-> FunctionName()
will execute the method 'FunctionName' from the current class -- or any
parent class if it is not defined in the current class. There's one good
exception:
You still reference functions in the current class using $this-> , that
way you can have functions of the same name in both classes.

To make a method in the child class of the same name as a method in the
parent class is called overriding -- and is usually done to either
change the behaviour of that method (for example, if you want to do
something completely different than what was done in the parent class)
or to supplement the behaviour of the parent method -- for instance, if
the child class wishes to do some processing before or after the parent
method is executed. In this latter case, you *will* use the
parent::FunctionName() construct -- so that you can actually access the
method you're currently overriding:
class parentClass
{
// ...
function someMethod()
{
// do something
}
}
class someClass extends parentClass
{
// ...
function someMethod()
{
// do some processing first
parent::someMethod();
// do some postprocessing
}
}
So, in the OP's case, he might want to have override the fetchAssoc()
method in his PageResultSet subclass so that it tacks on the LIMIT info
to the SQL statement, and then have it call the parent (Mysql class)
fetchAssoc() method with that modified SQL.
On Jan 20, 2005, at 9:17 PM, Phillip S. Baker wrote:
Greetings all,
I have a class I use for MySQL connection and functions.
I also have a class that I use to create Paged Results.
The paged results class connects to a DB and uses allot of sql calls
to make this happen. I am noticing that it does allot that the MySQL
class does.
What I would like to do is to Have the paged results extend the
MySQL class so it can use the functions within that class so I can
keep them updated in just one place. How would I go about doing
that?? Is it as simple as something like this (this is shortened for
convience)??
class Mysql {
 var $results;
 var $dbcnx;
 function Mysql($query, $cnx) { // Constructor function
   $this-> dbcnx = $cnx;
   if (!$this-> results = @mysql_query($query))
$this-> _error("There was an error with executing your query. Try
again
later.", $query);
 }
}
class PageResultSet extends MySQL {
 var $results;
 function PageResultSet ($query,$pageSize,$resultpage,$cnx) {
  $this-> results = @mysql_query($query,$cnx) or $this-> _error('Error
Running
your search. Try back later.', $query);
  $this-> pageSize = $pageSize;
  if ((int)$resultpage <= 0) $resultpage = 1;
  if ($resultpage > $this-> getNumPages())
  $resultpage = $this-> getNumPages();
  $this-> setPageNum($resultpage);
 }
}
I would like to be able to pass the results from the MySQL class to the
PageResultSet class without have to do the query over and such.
How would I go about coding that? I am not clear on that.
Also can I extend a function in PageResultSet that is started in
MySQL??
In MySQL I have
 function fetchAssoc() {
  if

[PHP] bug in str_split function?

2005-01-21 Thread chris
Sorry if this is a double post, I left the subject off the first one.
// I'm running this test code

/ start
";
 }
?>
/ end

// I'm expecting
this is a test
Array
t
h
i
s

i
s

a

t
e
s
t

// the output is 
this is test

The problem seems to be related to the str_split function not returning an
array. Any ideas?

Chris



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004 

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



Re: [PHP] Re: multiple sessions on same server/domain

2005-01-21 Thread Richard Lynch
Marek Kilimajer wrote:
> COKIES, I'm talking about COOKIES.
>
> Anytime you talk about cookies or cookie files, you mean session and
> session files, respectively. These are completely different things,
> please don't intermingle them.

session_set_cookie_params()
^^^

You're talking about a function whose name starts with session, which is
in the sessions section of the PHP Manual:
http://php.net/session_set_cookie_params

The Cookie in question is used to uniquely identify a surfer with PHP's
session files for that surfer.

What exactly to you think this function *DOES* if you aren't using
sessions and session files?

NOTHING!

It sets the file to be used when PHP sends the PHPSESSID Cookie which is
used for PHP's Session files.  Period.

Thus my point remains:
On a shared server, I don't need to resort to calling this function to
hijack your Cookie/session.  PHP can read the raw session files.  I can
write a PHP script to read the raw session files, regardless of what
directory the Cookie is set to use to store/retrieve the Cookie whose
purpose is to identify those files.

This is not something you can "fix" in any real-world scenario where it
matters.

If you don't like that, don't use a shared server.

It's that simple.

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

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



Re: [PHP] bug in str_split function?

2005-01-21 Thread Greg Donald
On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote:
>  $test2=str_split($test);

Do echo ''; print_r( $test2 ); right here and see if the $test2
array has the data you expect.


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

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



Re: [PHP] sendmail crash

2005-01-21 Thread Michiel van der Blonk
Hi

New results: This problem does not seem to be Smarty related, although it
did occur when
Smarty tried to read from memory. Probable cause: PEAR was missing a field
in the ini file where the email address was defined, which resulted in empty
addresses being given to sendmail. Sendmail doesn't return an error, but
does cause apache to crash later on. I will take this up with PEAR
DB_DataObject people.

Michiel
*
Michiel van der Blonk
CaribMedia Marketing & Consultancy N.V.
Oranjestad, Aruba
Tel: (297) 583-4144 Fax: (297) 582-6102
http://www.caribmedia.com
 
Website Design, Web Application Development,
Web Hosting, Internet Marketing
 
Operators of:
Visit Aruba - http://www.VisitAruba.com
Aruba Links - http://www.ArubaLinks.com
Aruba Business Directory - http://www.visitaruba.com/business/
Aruba Real Estate Locator - http://www.arubarealestate.com
Aruba Bulletin Board - http://bb.visitaruba.com/
Aruba Trip Reports - http://tripreports.visitaruba.com
Aruba Chat - http://chat.visitaruba.com
The VisitAruba Plus SAVINGS CARD - http://www.visitaruba.com/plus/
Contents of this communication are confidential and legally privileged. This
document is intended solely for use of the individual(s) or entity/entities
to whom it is addr
"Michiel van der Blonk" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi
>
> >  > Is the above the ACTUAL email you are sending?
> Haha. That would be a funny email. No, this is just sample text. The
actual
> email is 8KB and contains no images/attachments.
>
> > (I just tried googling the problem but the only thing that seemed
> > related that I came up with were Michiel posts :-S )
> Yeah I tried that too... I feel so alone..
>
> Anyway, some new information: I found a workaround. I am using the Smarty
> template engine. When I delete all smarty variables from the template I do
> get a page, instead of the 404. So, it must mean that Smarty trips over
> something that either sendmail or the PEAR code does. When I take out the
> sendmail line everything also works fine, so it's a combination of things.
>
> The only remaining problem is this pain in the back of my head in the
> 'Mental Frustration' lobe.
>
> Any new insights are welcome. I'll post the problem to the Smarty list.
>
> Michiel
>
> -- 
> *
> Michiel van der Blonk
> CaribMedia Marketing & Consultancy N.V.
> Oranjestad, Aruba
> Tel: (297) 583-4144 Fax: (297) 582-6102
> http://www.caribmedia.com
>  
> Website Design, Web Application Development,
> Web Hosting, Internet Marketing
>  
> Operators of:
> Visit Aruba - http://www.VisitAruba.com
> Aruba Links - http://www.ArubaLinks.com
> Aruba Business Directory - http://www.visitaruba.com/business/
> Aruba Real Estate Locator - http://www.arubarealestate.com
> Aruba Bulletin Board - http://bb.visitaruba.com/
> Aruba Trip Reports - http://tripreports.visitaruba.com
> Aruba Chat - http://chat.visitaruba.com
> The VisitAruba Plus SAVINGS CARD - http://www.visitaruba.com/plus/
> Contents of this communication are confidential and legally privileged.
This
> document is intended solely for use of the individual(s) or
entity/entities
> to whom it is addr
> "Jochem Maas" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Richard Lynch wrote:
> >  > Michiel van der Blonk wrote:
> >  >
> >
> > ...
> >
> >  >
> >  > Is the above the ACTUAL email you are sending?
> >  >
> >  > Or merely a demonstrative sample?
> >  >
> >  > Cuz, like, if the email you are REALLY sending is *HUGE* then I'd not
> be
> >  > surprised by the messages above...
> >  >
> >
> > Richard, what do you consider huge. I mean people (read: some of my
> > idiot co-worker) happily send 10Meg attachments via sendmail all day
> > long (okay so its not via PHP, but I sometimes use the phpMailer script
> > to send emails using PHP/sendmail and I have successfully done so with
> > 10+ Megs of files attached).
> >
> > is it possible he is hitting a PHP memory limit?
> >
> > (I just tried googling the problem but the only thing that seemed
> > related that I came up with were Michiel posts :-S )

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



Re: [PHP] regular expression help

2005-01-21 Thread Jochem Maas
Richard Lynch wrote:
Jason wrote:
Simple functions to check & fix if necessary invalid formating of a MAC
address... I seem to be having problems with the global variable $mac
not being returned from the fix_mac() function.  Any help is appreciated.
function fix_mac( $mac ) {
 global $mac;

It's really weird to both pass in $mac as an argument and to declare it
global...
Do one or the other, but not both.
quite.
Can't help you with the mess of Regex you've got though...
now I bet you can actually, chicken and egg: you have to have the skill 
to recognise the mess. ;-)

Jason - don't be dishearted:
a, regexp are/can be hard
b, anyone who is giving them a go, is probably trying hard to improve
their skills (we like that :-)) - regexps are quite a hurdle for most 
people.
c, we all start out writing regexps like yours (i.e. simple ones) and 
eventually they become more and more complex/arcane until you become 
Larry Wall.

---
"did someone say 'who is Larry Wall?'?, 10 lashes for that man"

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


[PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] Categories and subcategories

2005-01-21 Thread Jochem Maas
Phpu wrote:
Hi,
I need to create multiple categories and subcategories using php and mysql. 
Something like that
its bad practice to state the technology that must be used before you 
have determined the scope and function of the problem, besides you have 
to know whether php and mysql are capable of providing a solution
to your problem.

- category 1
- subcat 1.1
- subcat 1.2
  - subcat 1.2.1
  - subcat 1.2.2
- category 2

Does anyone know a godd totorial how to create this in pahp and how to make the structure of the database?
this is the first hit I got with google:
http://www.chipchapin.com/WebTools/MenuTools/
heres another:
Thanks in advance for your help 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] Categories and subcategories

2005-01-21 Thread Jochem Maas
(bl***dy CTRL+enter)...
Phpu wrote:
Hi,
I need to create multiple categories and subcategories using php and mysql. 
Something like that
its bad practice to state the technology that must be used before you
have determined the scope and function of the problem, besides you have
to know whether php and mysql are capable of providing a solution
to your problem. are they?
- category 1
- subcat 1.1
- subcat 1.2
  - subcat 1.2.1
  - subcat 1.2.2
- category 2

Does anyone know a godd totorial how to create this in pahp and how to make the structure of the database?
this is the first hit I got with google:
http://www.chipchapin.com/WebTools/MenuTools/
heres another:
http://www.phpmag.net/itr/online_artikel/psecom,id,387,nodeid,114.html
now either you have no idea that the basic term used for the structure 
you want is a 'tree' (in which case, you just didn't know - but now you 
do so there is nolonger any excuse :-) or you haven't searched for 
_anything_.

like for instance:
PHP+Tree
or
PHP+simple+Tree
or
PHP+simple+Tree+structure
feel free to cut in anytime and take over ;-)
so go and read lots of info, its definitely out their (literary hundreds 
of examples,tips,articles,code-samples,etc),  if you find something and 
get stuck come back and ask (just be prepared to show that you have made 
an effort.)

Thanks in advance for your help 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Hidden images.

2005-01-21 Thread Jochem Maas
Rob Adams wrote:
Ok - I've finally got something that sometimes works.
http://smada.com/images/hide_image.php
I talked to a Delphi programmer, who whipped something out in about 20 
you talked to a WHAT??? ;-) just kidding
minutes.  My code is a translation of his.
cool of you to share the code :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Static Array declaration within class PHP5

2005-01-21 Thread Jochem Maas
Marek wrote:
Hello
I'm trying to create a public static array within a class.(PHP5). 

First - the following fails: 

class yadayada { 
public static $tester[0]="something"; 
public static $tester[1]="something 1"; 
of course this doesn't (ok so its obvious to me)
first of its generally not good form to initialize a var in the class 
definition but rather do it with a function. often that would be 
   the constructor - but that won't do it this time.

here is how I would do it (given the facts you provided):
class Yadda
{
private static $myArr;
public static function getArr()
{
if (!isset(self::$myArr)) {
self::setupArr();
}
return self::$myArr;
}
private static function setupArr()
{
self::$myArr = array(
0 => 'something',
1 => 'something1',
2 => 'something2',
3 => 'something3',
4 => 'something4',
5 => 'something5',
6 => 'something6',
7 => 'something7', // notice the trailing comma!
);
}
}
print_r( Yadda::getArr() );

btw: I did not syntax check this code.
Second - However the following works:
class yadayada { 
public static $tester = array (0 => "something", 1 >="something 1"); 
you are not forced to write the whole array on 1 line :-)
also if you are using numeric keys there is no need to write them...:
$tester = array ("something", "something 1");
with or with out the keys its the same (assuming you keys start at zero 
and are always consecutive)


My question is this: I have an array that has about some 150 different values and using the second example 
would get very very messy, is there another method of doing this ? The first example(which fails) is the cleanest, is there anything I can do ? 
by clean do you mean readable per chance? how readable is the class I 
just defined according to you?

Thank you

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


Re: [PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] Categories and subcategories

2005-01-21 Thread Justin
Jochem Maas wrote:
Phpu wrote:
Hi,
I need to create multiple categories and subcategories using php and 
mysql. Something like that

its bad practice to state the technology that must be used before you 
have determined the scope and function of the problem, besides you have 
to know whether php and mysql are capable of providing a solution
to your problem.
This level of functionality is supported BY any language.

- category 1
- subcat 1.1
- subcat 1.2
  - subcat 1.2.1
  - subcat 1.2.2
- category 2

Does anyone know a godd totorial how to create this in pahp and how to 
make the structure of the database?
Although there are many many ways of doing this I would suggest looking 
at the Nested Set Model from Joe celko
www.intelligententerprise.com/001020/celko.shtml. A google search will 
bring up a lot more results.

In fact Joe has an entire book on do Hierarchies in SQL
(called Joe Celko's Trees and Hierarchies in SQL for Smarties)
 It is a little complicated up front, and there is a lot of 
housekeeping for inserts but it does have certain advantages  for very 
large datasets.

An alternative is this really simple method
id  pathcategory
=
1   1   root level
2   1   category1
3   1   category2
4   1.2 sub cat of category 1
5   1.3 sub cat of category 2
you can actually do nearly any queries you might need allowing you 
return all node under a level (sql.. where path like '1*'), just the 
nodes directly under the level (sql.. where path like '1.?') etc..

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


Re: [PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] Categories and subcategories

2005-01-21 Thread Jochem Maas
Justin wrote:
Jochem Maas wrote:
Phpu wrote:
Hi,
I need to create multiple categories and subcategories using php and 
mysql. Something like that

its bad practice to state the technology that must be used before you 
have determined the scope and function of the problem, besides you 
have to know whether php and mysql are capable of providing a solution
to your problem.

This level of functionality is supported BY any language.
no sh*t.
I was making a point: namely that you should scope the problem and know 
the technology before deciding upon - if he doesn't have a clue how to 
do this then its just as relevant to go for Perl and FlatFile storage - 
so why choose PHP+MySQL off the bat (and bother us with the rather 
stupid question - stupid because googling just about any combination of 
'tree' 'structure' 'hierarchy' 'php' brings up shed loads of good links)

granted he may not have had any idea what the thing he was looking for 
was called - that would make it alot harder to search for! but he knows 
now - so hopefully he comes back with a specific question regarding his 
'tree' problem.

Does anyone know a godd totorial how to create this in pahp and how 
to make the structure of the database?
in the words of the immortal: "Yes."

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


Re: [PHP] bug in str_split function?

2005-01-21 Thread chris
No good.

I made the change to this (note the echo ping statements)
/// start
ping 1';
 $test2=str_split($test);
 echo 'ping 2';
 echo '';
 for($i=0;$i';
?>
/// end

result is now
/
this is test
ping 1
/

"Greg Donald" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote:
>>  $test2=str_split($test);
>
> Do echo ''; print_r( $test2 ); right here and see if the $test2
> array has the data you expect.
>
>
> -- 
> Greg Donald
> Zend Certified Engineer
> http://destiney.com/


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004 

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



Re: [PHP] display imap attached files?

2005-01-21 Thread Jochem Maas
Fredrik Hampus wrote:
Hi!
Iam trying too make a page where the function is to display an attached  
.jpg file
from a imap mailbox. This is a small code i found and rewrote some...


include '/etc/labbuser';
$mbox = imap_open ("{localhost:993/imap/ssl/novalidate-cert}INBOX",  
"$imuser", "$impass");
$mno = "57";

$parttypes = array ("text", "multipart", "message", "application",  
"audio", "image", "video", "other");
 function buildparts ($struct, $mno = "") {
   global $parttypes;
   switch ($struct->type):
 case 1:
   $r = array ();
   $i = 1;
   foreach ($struct->parts as $part)
 $r[] = buildparts ($part, $mno.".".$i++);

   return implode (", ", $r);
 case 2:
   return "{".buildparts ($struct->parts[0], $mno)."}";
 default:
echo "--Size--";
echo $struct->bytes;
echo " ";
echo $struct->subtype;
echo "";
if ($struct->subtype == "JPEG") {
echo "MATCH";
echo "";
}
   return ''.$parttypes[$struct->type]."/".strtolower ($struct->subtype)."";
   endswitch;
 }
  $struct = imap_fetchstructure ($mbox, $mno);

  echo buildparts ($struct);
imap_close($mbox);
?>
This will display how many parts there is in the mail and the size of 
each  one of them and what type they are.
but how do a display the image of an attached jpg file on a webpage?
I have never worked with the imap funcs but:
you probably need to create an image output script which the above 
scripts' output points to. so if a struct is/contains an then you spit 
out an image tag:

echo "";
the imap-img.php script opens the request struct of the requested 
message and echos out the data contained (which would be the image data) 
- it also needs to echo out the correct headers so that the image data 
is recognized as an image.

needless to say both scripts should be checking that the user is logged 
in or something - unless we are all allowed to look in your inbox ;-)

hope that gives you an idea on how to continue.
good luck :-)
//Fredrik
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] too slow to unset big array (after mem fragment)

2005-01-21 Thread Richard Lynch
Xuefer Tinys wrote:
> if i have to unset portion of the $oldTracker. i have to scan? or any
> other way?

Perhaps you could store all data with an index of time rounded off to
minutes (hours, whatever).

Example:



If you make the $purge_time *TOO* small, smaller than the frequency with
which the loop runs, then old data will get "missed" and never purged.

The point being to break up your data into "chunks" at a level that
garbage collection won't kill you.

You basically need to run garbage collection more often with smaller
chunks of data to solve your problem.

Exactly how much more often, and how small, depends on your application
more than anything else.

The above will at least let you experiment with different $purge_time
settings to see if there's a "sweet spot" for your garbage collection.

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

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



[PHP] Storing key values in an array

2005-01-21 Thread Todd Cary
I am using an array to populate a drop-down and I would like to have the 
same value in the key as the value.  Using the following, the key is 
0,1,2,3...etc.  How can I correct that?

$file_list = array();
$dir = opendir($doc_dir);
while (false !== ($file = readdir($dir))) {
  if (($file != ".") && ($file != ".."))
$file_list[$file] = $file;  <---<
}
Todd
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] bug in str_split function?

2005-01-21 Thread Jochem Maas
chris wrote:
No good.
this should work, I rewrote you little test and no probs (as expected):
 php -r '
$test = "this is test";
echo $test,"\n";
$test2 = str_split($test);
foreach($test2 as $s) {
echo $s."\n";
}
'

I made the change to this (note the echo ping statements)
/// start
ping 1';
 $test2=str_split($test);
long shot: try specifying the second param to str_split()
e.g.:
$test2=str_split($test,1);
if that doesn't do it you can probably consider you php install borked - 
in which case reinstall!

 echo 'ping 2';
 echo '';
 for($i=0;$iwhile we're at it - don't put the count statement inside the loop, they 
way you have it now count() gets called on every iteration - thats 
wasteful. also notice the foreach syntax I used above, it will save to 
time in typing :-) (I believe its faster for simple array iteration as 
well - anyone care to correct?)

 {
  print_r($test2[$i]);
 }
 echo '';
?>
/// end
result is now
/
this is test
ping 1
/
"Greg Donald" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote:
$test2=str_split($test);
Do echo ''; print_r( $test2 ); right here and see if the $test2
array has the data you expect.
--
Greg Donald
Zend Certified Engineer
http://destiney.com/

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004 

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


Re: [PHP] Upgrading PHP 4.2.2 on Red Hat 9

2005-01-21 Thread Richard Lynch
James Butler wrote:
> My main issue is that libdb-4.0.so is needed by existing installations
> of curl, python, pam, cyrus, webalizer, db4, perl, postfix, sendmail,
> perl-DB_File and on and on. And that's not even close to the end of the
> old program dependencies list.
>
> Upgrading via rpm is going to be a humongous pain if I have to upgrade
> every program listed in the dependencies (rpm -Uvh --test), even if I
> can figure out which order they need to be done in.

One of the things I liked about RH9 was they FINALLY got up2date to
actually work.

Or, at least, that was the first time *I* was able to just use it and it
worked.  RH8 was only so-so, for awhile, before up2date got too confused
to be any use.

I dunno if that will get you the versions you want, or if it's any more or
less secure than what you've got, but at least it makes the nightmare of
RPM dependencies go away.

My RH9 box is behind a firewall, locked in a cabinet, and has no untrusted
users, so is less at-risk than most...

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

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



Re: [PHP] Storing key values in an array

2005-01-21 Thread Jochem Maas
Todd Cary wrote:
I am using an array to populate a drop-down and I would like to have the 
same value in the key as the value.  Using the following, the key is 
0,1,2,3...etc.  How can I correct that?
what is there to correct - you are telling me that the value of $file 
show up as a string and then magically it becomes an integer (but just 
while you are designating the key)

listen you've just shown us a simple loop to stuff some file/dir names 
into an array where by the file/dir name is the assoc. key as well as 
the value of any given item in said array - WHERE THE F*** IS THE 
DROPDOWN RELATED CODE?

$file_list = array();
$dir = opendir($doc_dir);
while (false !== ($file = readdir($dir))) {
  if (($file != ".") && ($file != ".."))
$file_list[$file] = $file;  <---<
}
what happens if you place the following right after the code you mention 
(just to prove that what you say about the key is wrong):

echo '';
print_r($file_list);
echo '';
Todd
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Hidden images.

2005-01-21 Thread Richard Lynch
Rob Adams wrote:
> Ok - I've finally got something that sometimes works.
>
> http://smada.com/images/hide_image.php

I dunno what you did to the first file upload button, but as soon as I
choose the FIRST file, I get:
Warning: imageistruecolor(): supplied argument is not a valid Image
resource in
/usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 60

Warning: imagecreatetruecolor(): Invalid image dimensions in
/usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 63

Warning: imagecopy(): supplied argument is not a valid Image resource in
/usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 64

Warning: imagedestroy(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 65

Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89

Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89

Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89

Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89

Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89

Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89

Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89

.
.
.


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

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



Re: [PHP] Static Array declaration within class PHP5

2005-01-21 Thread Richard Lynch
Marek wrote:
> Hello
>
> I'm trying to create a public static array within a class.(PHP5).
>
> First - the following fails:
>
> class yadayada {
> public static $tester[0]="something";
> public static $tester[1]="something 1";
>
> Second - However the following works:
>
> class yadayada {
> public static $tester = array (0 => "something", 1 >="something
> 1");
>
> My question is this: I have an array that has about some 150 different
> values and using the second example would get very very messy, is there
> another method of doing this ? The first example(which fails) is the
> cleanest, is there anything I can do ?

You could set the elements one by one in a constructor, I do believe.

You *MIGHT* be able to do:

$foo[0] = '0';
$foo[1] = '1';
$foo[2] = '2';
.
.
.
class yadayada {
  public static $tester = $foo;
}

but I doubt it...

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

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



Re: [PHP] Upgrading PHP 4.2.2 on Red Hat 9

2005-01-21 Thread Jochem Maas
Richard Lynch wrote:
James Butler wrote:
My main issue is that libdb-4.0.so is needed by existing installations
of curl, python, pam, cyrus, webalizer, db4, perl, postfix, sendmail,
perl-DB_File and on and on. And that's not even close to the end of the
old program dependencies list.
Upgrading via rpm is going to be a humongous pain if I have to upgrade
every program listed in the dependencies (rpm -Uvh --test), even if I
can figure out which order they need to be done in.

One of the things I liked about RH9 was they FINALLY got up2date to
actually work.
Or, at least, that was the first time *I* was able to just use it and it
worked.  RH8 was only so-so, for awhile, before up2date got too confused
to be any use.
I dunno if that will get you the versions you want, or if it's any more or
less secure than what you've got, but at least it makes the nightmare of
RPM dependencies go away.
My RH9 box is behind a firewall, locked in a cabinet, and has no untrusted
users, so is less at-risk than most...
I have one word to say in regard to redhat: DEBIAN.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] array problem

2005-01-21 Thread Richard Lynch
Ahmed Abdel-Aliem wrote:
> how can i group them together into one array to be :

http://php.net/array_merge

and friends should help

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

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



Re: [PHP] bug in str_split function?

2005-01-21 Thread chris
Still no goodI get the first echo but nothing after it.

:^(

What bothers me about this whole thing is the original code was working 
fine.
It was only today that this issue arose, when I was making documentation on 
my code.
Now, all of a sudden, it no longer works. After stepping through my code I 
was able to
isolate it to this function. I have not changed any of my settings, but then 
again other
people do have to my computer. But I could not think of anything that would 
just shutdown
a single function and not other too

If I can not get this resolve I will just make a work around

Chris



"Jochem Maas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> chris wrote:
>> No good.
>
> this should work, I rewrote you little test and no probs (as expected):
>
>  php -r '
>
> $test = "this is test";
> echo $test,"\n";
> $test2 = str_split($test);
> foreach($test2 as $s) {
> echo $s."\n";
> }
>
> '
>
>
>>
>> I made the change to this (note the echo ping statements)
>> /// start
>> >  $test='this is test';
>>  echo $test;
>>  echo 'ping 1';
>>  $test2=str_split($test);
>
> long shot: try specifying the second param to str_split()
> e.g.:
>
> $test2=str_split($test,1);
>
> if that doesn't do it you can probably consider you php install borked - 
> in which case reinstall!
>
>>  echo 'ping 2';
>>  echo '';
>>  for($i=0;$i
> while we're at it - don't put the count statement inside the loop, they 
> way you have it now count() gets called on every iteration - thats 
> wasteful. also notice the foreach syntax I used above, it will save to 
> time in typing :-) (I believe its faster for simple array iteration as 
> well - anyone care to correct?)
>
>>  {
>>   print_r($test2[$i]);
>>  }
>>  echo '';
>> ?>
>> /// end
>>
>> result is now
>> /
>> this is test
>> ping 1
>> /
>>
>> "Greg Donald" <[EMAIL PROTECTED]> wrote in message 
>> news:[EMAIL PROTECTED]
>>
>>>On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote:
>>>
 $test2=str_split($test);
>>>
>>>Do echo ''; print_r( $test2 ); right here and see if the $test2
>>>array has the data you expect.
>>>
>>>
>>>-- 
>>>Greg Donald
>>>Zend Certified Engineer
>>>http://destiney.com/
>>
>>
>>
>> ---
>> Outgoing mail is certified Virus Free.
>> Checked by AVG anti-virus system (http://www.grisoft.com).
>> Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004 

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



Re: [PHP] bug in str_split function?

2005-01-21 Thread Richard Lynch
chris wrote:
> No good.
>
> I made the change to this (note the echo ping statements)
> /// start
>   $test='this is test';
>  echo $test;
>  echo 'ping 1';
>  $test2=str_split($test);
>  echo 'ping 2';
>  echo '';
>  for($i=0;$i  {
>   print_r($test2[$i]);
>  }
>  echo '';
> ?>
> /// end
>
> result is now
> /
> this is test
> ping 1
> /

Most rational explanation:

Fact 1: str_split is only available in PHP 5, according to TFM.
Fact 2: It's *POSSIBLE* to set up error_reporting/error_log to not appear
in the browser.

Hypothesis:  You have an error message going somewhere telling you that
str_split is not a defined function, because you are running PHP 4 (or PHP
3, or even PHP 2, in theory)...

Lab Test: Does  say you are running PHP 5?

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


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



[PHP] Multiple select boxes - select in one box, populate from DB in second with no refresh!

2005-01-21 Thread Matt Babineau
Hi all -

I know this has been covered a lot but my searching has resulting in not
much success, was hoping someone had the link to a good page on this.

I have on select box that when I select something in it I need the other
select box to get vales from a database table with out having the page
refresh. I have thought about the Iframe solution - does this work in
Mozilla? Are there non-iFrame solutions?

Thanks,

Matt Babineau
Criticalcode
w: http://www.criticalcode.com
p: 858.733.0160
e: [EMAIL PROTECTED]



Re: [PHP] Hidden images.

2005-01-21 Thread Rob Adams
"Richard Lynch" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Rob Adams wrote:
>> Ok - I've finally got something that sometimes works.
>>
>> http://smada.com/images/hide_image.php
>
> I dunno what you did to the first file upload button, but as soon as I
> choose the FIRST file, I get:
> Warning: imageistruecolor(): supplied argument is not a valid Image
> resource in
> /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
> line 60

That is strange.  Doesn't happen to me.  The javascript should just be 
making sure the images are a supported type.

Here is my best so far:
http://smada.com/images/Snow.png  (2 MB)
(http://smada.com/images/Snow.jpg <-- not as big, but doesn't look as good 
either)

These have to be opened in IE.

  -- Rob

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



Re: [PHP] Hidden images.

2005-01-21 Thread Jochem Maas
Richard Lynch wrote:
Rob Adams wrote:
Ok - I've finally got something that sometimes works.
http://smada.com/images/hide_image.php

I dunno what you did to the first file upload button, but as soon as I
choose the FIRST file, I get:
use the BACK button. then fill in the second file upload widget...
it is weird tho... until you look at the source - he has some javascript 
 that a little too enthusiastic about hitting the submit button ;-)

Warning: imageistruecolor(): supplied argument is not a valid Image
resource in
/usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 60
Warning: imagecreatetruecolor(): Invalid image dimensions in
/usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 63
Warning: imagecopy(): supplied argument is not a valid Image resource in
/usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 64
Warning: imagedestroy(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 65
Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89
Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89
Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89
Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89
Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89
Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89
Warning: imagecolorat(): supplied argument is not a valid Image resource
in /usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 89
.
.
.

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


Re: [PHP] bug in str_split function?

2005-01-21 Thread chris
Thanks to Richard who pointed me in the right direction. I failed to notice 
that the str_split function is only for use with php v5, I was run 
4.3.10...DOH!

In case anyone what the solution here is a rewrite.

ping 1';
 $strSize=strlen($test);
 for($i=0;$i<$strSize;$i++)
 {
  array_push($test2,$test[$i]);
 }
 echo 'ping 2';
 for($i=0;$i<$strSize;$i++)
 {
  echo $test2[$i].'';
 }
?>


This will correctly produce

this is test
ping 1
ping 2
t
h
i
s

i
s

t
e
s
t

Jochem, thanks for pointing out the count inside the loop issue. This is a 
good point to remember...

Thank,
Chris

"Jochem Maas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> chris wrote:
>> No good.
>
> this should work, I rewrote you little test and no probs (as expected):
>
>  php -r '
>
> $test = "this is test";
> echo $test,"\n";
> $test2 = str_split($test);
> foreach($test2 as $s) {
> echo $s."\n";
> }
>
> '
>
>
>>
>> I made the change to this (note the echo ping statements)
>> /// start
>> >  $test='this is test';
>>  echo $test;
>>  echo 'ping 1';
>>  $test2=str_split($test);
>
> long shot: try specifying the second param to str_split()
> e.g.:
>
> $test2=str_split($test,1);
>
> if that doesn't do it you can probably consider you php install borked - 
> in which case reinstall!
>
>>  echo 'ping 2';
>>  echo '';
>>  for($i=0;$i
> while we're at it - don't put the count statement inside the loop, they 
> way you have it now count() gets called on every iteration - thats 
> wasteful. also notice the foreach syntax I used above, it will save to 
> time in typing :-) (I believe its faster for simple array iteration as 
> well - anyone care to correct?)
>
>>  {
>>   print_r($test2[$i]);
>>  }
>>  echo '';
>> ?>
>> /// end
>>
>> result is now
>> /
>> this is test
>> ping 1
>> /
>>
>> "Greg Donald" <[EMAIL PROTECTED]> wrote in message 
>> news:[EMAIL PROTECTED]
>>
>>>On Fri, 21 Jan 2005 12:07:34 -0600, chris <[EMAIL PROTECTED]> wrote:
>>>
 $test2=str_split($test);
>>>
>>>Do echo ''; print_r( $test2 ); right here and see if the $test2
>>>array has the data you expect.
>>>
>>>
>>>-- 
>>>Greg Donald
>>>Zend Certified Engineer
>>>http://destiney.com/
>>
>>
>>
>> ---
>> Outgoing mail is certified Virus Free.
>> Checked by AVG anti-virus system (http://www.grisoft.com).
>> Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004 

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



[PHP] changing emailadress

2005-01-21 Thread M H Topper
Pls tell me how I can change the emailadress with which I subscribed.
Thnx in advance Mark Topper
_
MSN Webmessenger overal en altijd beschikbaar http://webmessenger.msn.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Multiple select boxes - select in one box, populate from DB in second with no refresh!

2005-01-21 Thread Matt Babineau
I just found a descent tutorial after another 45 mins of searching and
pulling a php file into the ifram to output the data, then pulling the data
in from the iframe will work, thanks for your response! 

I was concerned with cross-browser compatability but hey who cares about
netscape4 anyway ;-)


Matt Babineau
Criticalcode
w: http://www.criticalcode.com
p: 858.733.0160
e: [EMAIL PROTECTED]

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 21, 2005 12:41 PM
To: Matt Babineau
Subject: Re: [PHP] Multiple select boxes - select in one box, populate from
DB in second with no refresh!

Matt Babineau wrote:
> I know this has been covered a lot but my searching has resulting in 
> not much success, was hoping someone had the link to a good page on this.
>
> I have on select box that when I select something in it I need the 
> other select box to get vales from a database table with out having 
> the page refresh. I have thought about the Iframe solution - does this 
> work in Mozilla? Are there non-iFrame solutions?

If the page isn't refreshing, then you aren't using PHP, because PHP only
runs on the server.

JavaScript could do this, if you dump all possible values for the second box
out as part of JavaScript data.

I have no idea how iFrame works, but you can probably get JavaScript to work
right in Mozilla for this.

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

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



[PHP] Procedural to OOP

2005-01-21 Thread Mike Smith
I am rewriting a project, and have decided to use/learn OOP. I am
using ADODB to connect to a MS SQL 2000 box. This code works, but I'd
like to know if I'm following good form or if I'm totally missing the
boat. I'd also like to include things like the
dbhost/username/password, etc in a seperate config file would I...

class foo{

function bar(){
include('my_config_file_here.php');// sets $dbhost etc...

var $db_host = $dbhost;
...
}
}

...or is there another way.

Here is my class and my index.php which will present it. I looked at
Smarty, but I think my head would explode trying to link
ADODB-OOP-SMARTY. Little of this is original, mostly borrowed from
what OOP tutorials and code I browsed at phpclasses.org, but I
understand what it's doing, which is important.


//class.php
include('../adodb/adodb.inc.php');

class PO {

var $db;

function Conn(){
$this->db = ADONewConnection("mssql");
$this->db->debug = false;
$this->db->Connect("MYSERVER","MYUSER","MYPASS","MYDB");
}

function PartList(){
$this->Conn();
$s = "SELECT partnumber FROM part_master ORDER BY partnumber\n";
$rs = $this->db->Execute($s);
$list = array();
while(!$rs->EOF){
array_push($list,$rs->fields[0]);
$rs->MoveNext();
}
return $list;
}

}
//class.php



//index.php
include('poman/class.php');

$po = new PO;



$parts = $po->PartList();

echo "\n";
foreach($parts AS $part){
echo "$part\n";
}
echo "\n";
//index.php

Any suggestions or I do I have the general idea?

TIA

Mike Smith

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



Re: [PHP] Hidden images.

2005-01-21 Thread Jochem Maas
Rob Adams wrote:
"Richard Lynch" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

Rob Adams wrote:
Ok - I've finally got something that sometimes works.
http://smada.com/images/hide_image.php
I dunno what you did to the first file upload button, but as soon as I
choose the FIRST file, I get:
Warning: imageistruecolor(): supplied argument is not a valid Image
resource in
/usr/local/psa/home/vhosts/smada.com/httpdocs/images/hide_image.php on
line 60

That is strange.  Doesn't happen to me.  The javascript should just be 
making sure the images are a supported type.
I was using firefox. the javscript also calls the submit button of the 
form (if the file extension is okay - which is a nice check to do for 
honest people but won't stop [EMAIL PROTECTED]@@[EMAIL PROTECTED] from uploading a binary or 
whatever - so check the mime-type on the sideserver also) - maybe the 
call to the submit button doesn't work in IE.

Here is my best so far:
http://smada.com/images/Snow.png  (2 MB)
(http://smada.com/images/Snow.jpg <-- not as big, but doesn't look as good 
either)

These have to be opened in IE.
indeed, and may I be one to congratulate you - I love to see people keep 
hacking the problem/challenge and get it working. especially since what 
you are trying to do is quite manic (image manipulation is a heavy 
science, just ask the 200K/year guys at Adobe ;-).

very cool indeed (pun intended!) :-)

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


Re: [PHP] Multiple select boxes - select in one box, populate from DB in second with no refresh!

2005-01-21 Thread Jochem Maas
Matt Babineau wrote:
I just found a descent tutorial after another 45 mins of searching and
pulling a php file into the ifram to output the data, then pulling the data
in from the iframe will work, thanks for your response! 

I was concerned with cross-browser compatability but hey who cares about
netscape4 anyway ;-)
good man, the gods will be with you :-)
ie. we can only create a stds compliant open web if we chuck out the shite.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Extending a Class

2005-01-21 Thread Phillip S. Baker
Thank you,

This makes allot of sense.
However one last question about this.

If I access the overrided function from the child class do I access it by.

$instanceofchildclass->parent::someMethod();

OR would I still simply just call it

$instanceofchildclass->someMethod();

And it would get to use the overrided function in the child class??

--
Blessed Be

Phillip

"Matthew Weier O'Phinney" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> * Brent Baisley <[EMAIL PROTECTED]> :
> > You've got most of it. Just adding "extends MySQL" to your page result
> > class will allow you to access all function in the MySQL class. I
> > usually reference functions in the parent class like this:
> > parent::FunctionName()
>
> This is a bad practice when inheriting, usually -- the whole point is
> that the parent classes methods are directly available to the child
> class without using such constructs.
>
> $this-> FunctionName()
>
> will execute the method 'FunctionName' from the current class -- or any
> parent class if it is not defined in the current class. There's one good
> exception:
>
> > You still reference functions in the current class using $this-> , that
> > way you can have functions of the same name in both classes.
>
> To make a method in the child class of the same name as a method in the
> parent class is called overriding -- and is usually done to either
> change the behaviour of that method (for example, if you want to do
> something completely different than what was done in the parent class)
> or to supplement the behaviour of the parent method -- for instance, if
> the child class wishes to do some processing before or after the parent
> method is executed. In this latter case, you *will* use the
> parent::FunctionName() construct -- so that you can actually access the
> method you're currently overriding:
>
> class parentClass
> {
> // ...
>
> function someMethod()
> {
> // do something
> }
> }
>
> class someClass extends parentClass
> {
> // ...
>
> function someMethod()
> {
> // do some processing first
> parent::someMethod();
> // do some postprocessing
> }
> }
>
> So, in the OP's case, he might want to have override the fetchAssoc()
> method in his PageResultSet subclass so that it tacks on the LIMIT info
> to the SQL statement, and then have it call the parent (Mysql class)
> fetchAssoc() method with that modified SQL.
>
> > On Jan 20, 2005, at 9:17 PM, Phillip S. Baker wrote:
> >
> > > Greetings all,
> > >
> > > I have a class I use for MySQL connection and functions.
> > >
> > > I also have a class that I use to create Paged Results.
> > >
> > > The paged results class connects to a DB and uses allot of sql calls
> > > to make this happen. I am noticing that it does allot that the MySQL
> > > class does.
> > >
> > > What I would like to do is to Have the paged results extend the
> > > MySQL class so it can use the functions within that class so I can
> > > keep them updated in just one place. How would I go about doing
> > > that?? Is it as simple as something like this (this is shortened for
> > > convience)??
> > >
> > > class Mysql {
> > >  var $results;
> > >  var $dbcnx;
> > >
> > >  function Mysql($query, $cnx) { // Constructor function
> > >$this-> dbcnx = $cnx;
> > >if (!$this-> results = @mysql_query($query))
> > > $this-> _error("There was an error with executing your query. Try
> > > again
> > > later.", $query);
> > >  }
> > > }
> > >
> > > class PageResultSet extends MySQL {
> > >  var $results;
> > >
> > >  function PageResultSet ($query,$pageSize,$resultpage,$cnx) {
> > >
> > >   $this-> results = @mysql_query($query,$cnx) or $this-> _error('Error
> > > Running
> > > your search. Try back later.', $query);
> > >   $this-> pageSize = $pageSize;
> > >   if ((int)$resultpage <= 0) $resultpage = 1;
> > >   if ($resultpage > $this-> getNumPages())
> > >   $resultpage = $this-> getNumPages();
> > >   $this-> setPageNum($resultpage);
> > >  }
> > > }
> > >
> > > I would like to be able to pass the results from the MySQL class to
the
> > > PageResultSet class without have to do the query over and such.
> > > How would I go about coding that? I am not clear on that.
> > >
> > > Also can I extend a function in PageResultSet that is started in
> > > MySQL??
> > > In MySQL I have
> > >  function fetchAssoc() {
> > >   if (!$this-> results) return FALSE;
> > >   $this-> row++;
> > >   return mysql_fetch_assoc($this-> results);
> > >  }
> > >
> > > In PageResultSet I have
> > >  function fetchAssoc() {
> > >   if (!$this-> results) return FALSE;
> > >   if ($this-> row > = $this-> pageSize) return FALSE;
> > >   $this-> row++;
> > >   return mysql_fetch_assoc($this-> results);
> > >  }
> > >
> > > Can I just write something like within PageResultSet
> > > function fetchAssocPRS extends fetchAssoc () {
> > >   if ($this-> row > = 

Re: [PHP] changing emailadress

2005-01-21 Thread R'twick Niceorgaw
On Fri, January 21, 2005 3:48 pm, M H Topper said:
> Pls tell me how I can change the emailadress with which I subscribed.
>
>
> Thnx in advance Mark Topper
>

just unsubscribe using your old address and subscribe using new address

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



[Fwd: [PHP] changing emailadress]

2005-01-21 Thread Jochem Maas
see all those headers below: they are in every email that goes via the 
list (its a defacto std thing these days) and it tells you everything 
you need to know. (hint there are bot email addrs mentioned with which 
you can communicate to manage you subscription)

unfortunately you use hotmail - which I doubt even lets you look at the 
headers of an email (don't know cos I don't use it.)

 Original Message 
Return-Path: <[EMAIL PROTECTED]>
X-Original-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Received: from localhost (localhost [127.0.0.1])	by mx1.moulin.nl 
(Postfix) with ESMTP id AE72ADC688	for <[EMAIL PROTECTED]>; Fri, 21 
Jan 2005 22:06:17 +0100 (CET)
Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (moulin 
[127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 11426-02 for 
<[EMAIL PROTECTED]>; Fri, 21 Jan 2005 22:06:14 +0100 (CET)
Received: from lists.php.net (lists.php.net [216.92.131.4])	by 
mx1.moulin.nl (Postfix) with ESMTP id 33049DC0C7	for 
<[EMAIL PROTECTED]>; Fri, 21 Jan 2005 22:06:14 +0100 (CET)
X-Host-Fingerprint: 216.92.131.4 lists.php.net
Received: from ([216.92.131.4:19883] helo=lists.php.net)	by pb1.pair.com 
(ecelerity HEAD (r4105:4106)) with SMTP	id FA/AB-19710-FBE61F14 for 
<[EMAIL PROTECTED]>; Fri, 21 Jan 2005 16:06:07 -0500
Received: (qmail 7629 invoked by uid 1010); 21 Jan 2005 20:50:13 -
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
list-help: 
list-unsubscribe: 
list-post: 
Delivered-To: mailing list php-general@lists.php.net
Received: (qmail 7604 invoked by uid 1010); 21 Jan 2005 20:50:12 -
Delivered-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
X-Host-Fingerprint: 65.54.233.104 bay21-f15.bay21.hotmail.com Windows 
2000 SP2+, XP SP1 (seldom 98 4.10.)
Message-ID: <[EMAIL PROTECTED]>
X-Originating-IP: [81.59.169.229]
X-Originating-Email: [EMAIL PROTECTED]
X-Sender: [EMAIL PROTECTED]
From: M H Topper <[EMAIL PROTECTED]>
To: php-general@lists.php.net
Date: Fri, 21 Jan 2005 21:48:18 +0100
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1; format=flowed
X-OriginalArrivalTime: 21 Jan 2005 20:50:00.0492 (UTC) 
FILETIME=[C62C5EC0:01C4FFFA]
Subject: [PHP] changing emailadress
X-Virus-Scanned: by amavisd-new at moulin.nl

Pls tell me how I can change the emailadress with which I subscribed.
Thnx in advance Mark Topper
_
MSN Webmessenger overal en altijd beschikbaar http://webmessenger.msn.com/
--
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] Issue with virtual() calls...

2005-01-21 Thread Potter, Jeff
Hello,

Could someone help me understand why later versions of PHP (4.3.9,
4.3.10, & 5.0.3) do not maintain the same 
ordering for virtual() call output as the older versions?   Basically,
generated pages that worked in 
PHP 4.3.7 & PHP 4.3.8 are now broken.   Setting the "output_buffering=0"
seems to help on some pages, but it
is still broken on others.  The content generated from the virtual()
call inside a page ends up in the browser
before the opening  tag.   See the simplified example below:

Source page:


 




   

  

Re: [PHP] Storing key values in an array

2005-01-21 Thread Todd Cary
Jochem -
The problem is the sort()!  I did not realize that it replaces the key 
with an integer.  Instead, I should have used ksort().

$dir = opendir($doc_dir);
while (false !== ($file = readdir($dir))) {
  if (($file != ".") && ($file != ".."))
$file_list[$file] = $file;
}
// Debug code
echo '';
print_r($file_list);
echo '';
sort($file_list);  <---
foreach ($file_list as $key => $val) {
  echo $key . " => " . $val . "";
}
Here are the result:
Array
(
[mailings] => mailings
[cases] => cases
)
0 => cases
1 => mailings

Todd
Jochem Maas wrote:
Todd Cary wrote:
I am using an array to populate a drop-down and I would like to have 
the same value in the key as the value.  Using the following, the key 
is 0,1,2,3...etc.  How can I correct that?

what is there to correct - you are telling me that the value of $file 
show up as a string and then magically it becomes an integer (but just 
while you are designating the key)

listen you've just shown us a simple loop to stuff some file/dir names 
into an array where by the file/dir name is the assoc. key as well as 
the value of any given item in said array - WHERE THE F*** IS THE 
DROPDOWN RELATED CODE?

$file_list = array();
$dir = opendir($doc_dir);
while (false !== ($file = readdir($dir))) {
  if (($file != ".") && ($file != ".."))
$file_list[$file] = $file;  <---<
}

what happens if you place the following right after the code you mention 
(just to prove that what you say about the key is wrong):

echo '';
print_r($file_list);
echo '';
Todd
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] help with nl2br

2005-01-21 Thread Phillip S. Baker
Greetings all,

Due to style sheet stuff I need to modify the nl2br (IE create or use a
different function).

I am pulling data from a database and using nl2br, which does the standard.

some text copy

Some more copy

What I want instead is
Some text copy

some more text copy

Again this is because of css and the designer I am workign with. Is there a
built in function that can do something like this or another function out
there. So far I cannot see anything. Or is there a way to view the coding of
the nl2br function so I can create a new function modifying how it does it.

Just asking so I do not have to create something from scratch.
Thanks.

--
Blessed Be

Phillip

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



RE: [PHP] help with nl2br

2005-01-21 Thread Jay Blanchard
[snip]
some text copy

Some more copy

What I want instead is
Some text copy

some more text copy
[/snip]

What you want to do is start with a , then when you run into 2 \n\n
you want to replace it with  and then end with a 
http://www.php.net/preg_replace

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



[PHP] Notice:Use of undefined constant

2005-01-21 Thread Tamas Hegedus
Hi,
On my system (Fedora 2) we (users) can use the following php:
PHP 4.3.10 (cgi) (built: Dec 21 2004 09:18:25)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
According to our system administrator php works in safe mode. I do not 
know (think) if there is any other special setup or not.

In a file, which is included into all my scripts, I defined constants 
(for MySQL access). PHP claims these constants as undifined constants, 
however, if I let them print out they have the right values 
(HOST='localhost'; NOT: HOST='HOST').

The output of my script:

PHP Notice:  Use of undefined constant HOST - assumed 'HOST' in 
/home/hegedus/bin/hae_chng.php on line 4
PHP Notice:  Use of undefined constant USER - assumed 'USER' in 
/home/hegedus/bin/hae_chng.php on line 5
PHP Notice:  Use of undefined constant PWD - assumed 'PWD' in 
/home/hegedus/bin/hae_chng.php on line 6
PHP Notice:  Use of undefined constant DB - assumed 'DB' in 
/home/hegedus/bin/hae_chng.php on line 7
User: haetu
Host: localhost


One solution could be to suppress php notices, but I think this is not 
the right treatment. Do you have any idea?

Thanks for your help in advance,
Tamas
--
Tamas Hegedus, Research Fellow | phone: (1) 480-301-6041
Mayo Clinic Scottsdale | fax:   (1) 480-301-7017
13000 E. Shea Blvd | mailto:[EMAIL PROTECTED]
Scottsdale, AZ, 85259  | http://hegedus.brumart.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: [PHP-DB] checkboxes

2005-01-21 Thread Joe Harman
Well.. i just got done doing something like what you are trying to
accomplish... you will need to name your check boxes like so :
name="completed[]"

when the form is submitted, I use something like this and shove it
into a field in the database:

if($_POST['completed'] <> NULL)
{
// This makes one string of all the check boxes
$completed_separated = implode(":", $_POST['completed']);
}
else
{
$comma_separated = NULL;
}

anyhow... use explode to get thte values out... not sure how you are
using this... but i made each check box equal to a value when checked
i.e. 23, 34

so, not sure if this is the right way to do it, but i find it to be a
pretty simple solution for my uses.

cheers




On Fri, 21 Jan 2005 16:47:11 -0500, Hutchins, Richard
<[EMAIL PROTECTED]> wrote:
> You can't just echo out an array. You have to either use print_r() or
> iterate over it with a while or for...next loop. But if you just want to see
> what's in the array, print_r() it.
> 
> As to why it doesn't bring over the other checkboxes...
> 
> If you have (pseudocode)
> 
> 
>  Checkbox 1
>  Checkbox 2
>  Checkbox 3
> 
> 
> 
> And you check the first two checkboxes, then the resulting array will be
> (pseudocode again):
> completed(value1,value2)
> 
> And from there, you just access the array contents as you would with any
> other multidimensional array.
> 
> If you don't check anything on the page, then the array will be empty and, I
> think, won't even be sent in the $_POST array. I'm sure somebody will
> correct me there if my memory has failed me.
> 
> -Original Message-
> From: Craig Hoffman [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 21, 2005 4:32 PM
> To: php-db@lists.php.net
> Cc: Richard Hutchins
> Subject: Re: [PHP-DB] checkboxes
> 
> I've tried that and it still doesn't bring over the other checkboxes
> that have been checked.  Plus when I echo it out I get
> Array  instead of the variable name.
> 
> On Jan 21, 2005, at 3:14 PM, Hutchins, Richard wrote:
> 
> > Probably all you need to do is name your checkboxes as an array thusly:
> >
> > name="completed[]"
> >
> > Then you can access the array on your update page and do whatever you
> > wish
> > with it.
> >
> > Hope this helps.
> >
> > Rich
> >
> > -Original Message-
> > From: Craig Hoffman [mailto:[EMAIL PROTECTED]
> > Sent: Friday, January 21, 2005 4:03 PM
> > To: php-db@lists.php.net
> > Subject: [PHP-DB] checkboxes
> >
> >
> > I have a form that display's a checkbox if the value is NULL. The form
> > is in a do... while loop, so the user may check multiple checkboxes.
> > I am trying to pass the variable of each checkboxes to an update
> > statement in MySQL.  THe problem is I am only getting one of the
> > checkboxes, even if all of them are checked.  Here is my code block,
> > any help would be great.  - Craig
> >
> > //From form page
> > 
> >   
> > 
> >
> > //MySQL Update Page
> > $email = $_POST['email'] == $route;
> >   $completed = $_POST["completed"] == $route;
> >$route_name = trim($_POST["route_name"]) == $route;
> >   $user_id = $_POST['user_id'] == $route;
> >   $id = $_POST['id'] == $route;
> >
> > $route = array(id => "$_POST[id]", completed => "$_POST[completed]",
> > route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");
> >
> >  foreach ($route as $key => $values) {
> > echo("");
> > echo $values;
> >//MySQL Update statement will go here.
> >   }
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> --
> PHP Database 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] nl2br misprint

2005-01-21 Thread Scott DeMers
>From the function page on php.net (
http://us4.php.net/manual/en/function.nl2br.php ):

"Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions
before 4.0.5 will return string with '' inserted before newlines instead
of ''."

Is this a misprint, ot does the revised function actually do this? According
to the w3c, "' is compliant, while "" is not; see
http://www.w3.org/TR/xhtml1/.

Scott DeMers
Web Coordinator
International Studies and Programs
Michigan State University
209 International Center
East Lansing, MI 48824-1035 U.S.A.
(517)355-2350 | Fax:(517)353-7254
[EMAIL PROTECTED]

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



[PHP] Re: [PHP-DB] checkboxes

2005-01-21 Thread M. Sokolewicz
Joe Harman wrote:
Well.. i just got done doing something like what you are trying to
accomplish... you will need to name your check boxes like so :
name="completed[]"
when the form is submitted, I use something like this and shove it
into a field in the database:
if($_POST['completed'] <> NULL)
{
// This makes one string of all the check boxes
$completed_separated = implode(":", $_POST['completed']);
}
else
{
$comma_separated = NULL;
}
anyhow... use explode to get thte values out... 
why would you implode and explode it in the same piece of code? sounds 
pretty... useless... to me. I'd just say, loop over the array, and do 
whatever you want with it.


is equivalent to $_POST['array_name'][] (Or $_GET['array_name'][]).

is equivalent to $_POST['array_name'][126] (Or $_GET['array_name'][126]).
etc. etc.
Not that hard it seems ;)
not sure how you are
using this... but i made each check box equal to a value when checked
i.e. 23, 34
so, not sure if this is the right way to do it, but i find it to be a
pretty simple solution for my uses.
cheers

On Fri, 21 Jan 2005 16:47:11 -0500, Hutchins, Richard
<[EMAIL PROTECTED]> wrote:
You can't just echo out an array. You have to either use print_r() or
iterate over it with a while or for...next loop. But if you just want to see
what's in the array, print_r() it.
As to why it doesn't bring over the other checkboxes...
If you have (pseudocode)


 Checkbox 1
 Checkbox 2
 Checkbox 3


And you check the first two checkboxes, then the resulting array will be
(pseudocode again):
completed(value1,value2)
And from there, you just access the array contents as you would with any
other multidimensional array.
If you don't check anything on the page, then the array will be empty and, I
think, won't even be sent in the $_POST array. I'm sure somebody will
correct me there if my memory has failed me.
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:32 PM
To: php-db@lists.php.net
Cc: Richard Hutchins
Subject: Re: [PHP-DB] checkboxes
I've tried that and it still doesn't bring over the other checkboxes
that have been checked.  Plus when I echo it out I get
Array  instead of the variable name.
On Jan 21, 2005, at 3:14 PM, Hutchins, Richard wrote:

Probably all you need to do is name your checkboxes as an array thusly:
name="completed[]"
Then you can access the array on your update page and do whatever you
wish
with it.
Hope this helps.
Rich
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:03 PM
To: php-db@lists.php.net
Subject: [PHP-DB] checkboxes
I have a form that display's a checkbox if the value is NULL. The form
is in a do... while loop, so the user may check multiple checkboxes.
I am trying to pass the variable of each checkboxes to an update
statement in MySQL.  THe problem is I am only getting one of the
checkboxes, even if all of them are checked.  Here is my code block,
any help would be great.  - Craig
//From form page

 

//MySQL Update Page
$email = $_POST['email'] == $route;
 $completed = $_POST["completed"] == $route;
  $route_name = trim($_POST["route_name"]) == $route;
 $user_id = $_POST['user_id'] == $route;
 $id = $_POST['id'] == $route;
$route = array(id => "$_POST[id]", completed => "$_POST[completed]",
route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");
foreach ($route as $key => $values) {
   echo("");
   echo $values;
  //MySQL Update statement will go here.
 }
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database 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: [PHP-DB] checkboxes

2005-01-21 Thread M. Sokolewicz
M. Sokolewicz wrote:
Joe Harman wrote:
Well.. i just got done doing something like what you are trying to
accomplish... you will need to name your check boxes like so :
name="completed[]"
when the form is submitted, I use something like this and shove it
into a field in the database:
if($_POST['completed'] <> NULL)
{
// This makes one string of all the check boxes
$completed_separated = implode(":", $_POST['completed']);
}
else
{
$comma_separated = NULL;
}
anyhow... use explode to get thte values out... 
why would you implode and explode it in the same piece of code? sounds 
pretty... useless... to me. I'd just say, loop over the array, and do 
whatever you want with it.


is equivalent to $_POST['array_name'][] (Or $_GET['array_name'][]).

is equivalent to $_POST['array_name'][126] (Or $_GET['array_name'][126]).
that should obviously say "is equivalent to 
$_POST['array_name'][key_126] (Or $_GET['array_name'][key_126])." instead
etc. etc.
Not that hard it seems ;)
not sure how you are
using this... but i made each check box equal to a value when checked
i.e. 23, 34
so, not sure if this is the right way to do it, but i find it to be a
pretty simple solution for my uses.
cheers

On Fri, 21 Jan 2005 16:47:11 -0500, Hutchins, Richard
<[EMAIL PROTECTED]> wrote:
You can't just echo out an array. You have to either use print_r() or
iterate over it with a while or for...next loop. But if you just want 
to see
what's in the array, print_r() it.

As to why it doesn't bring over the other checkboxes...
If you have (pseudocode)


 Checkbox 1
 Checkbox 2
 Checkbox 3



And you check the first two checkboxes, then the resulting array will be
(pseudocode again):
completed(value1,value2)
And from there, you just access the array contents as you would with any
other multidimensional array.
If you don't check anything on the page, then the array will be empty 
and, I
think, won't even be sent in the $_POST array. I'm sure somebody will
correct me there if my memory has failed me.

-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:32 PM
To: php-db@lists.php.net
Cc: Richard Hutchins
Subject: Re: [PHP-DB] checkboxes
I've tried that and it still doesn't bring over the other checkboxes
that have been checked.  Plus when I echo it out I get
Array  instead of the variable name.
On Jan 21, 2005, at 3:14 PM, Hutchins, Richard wrote:

Probably all you need to do is name your checkboxes as an array thusly:
name="completed[]"
Then you can access the array on your update page and do whatever you
wish
with it.
Hope this helps.
Rich
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:03 PM
To: php-db@lists.php.net
Subject: [PHP-DB] checkboxes
I have a form that display's a checkbox if the value is NULL. The form
is in a do... while loop, so the user may check multiple checkboxes.
I am trying to pass the variable of each checkboxes to an update
statement in MySQL.  THe problem is I am only getting one of the
checkboxes, even if all of them are checked.  Here is my code block,
any help would be great.  - Craig
//From form page

 

//MySQL Update Page
$email = $_POST['email'] == $route;
 $completed = $_POST["completed"] == $route;
  $route_name = trim($_POST["route_name"]) == $route;
 $user_id = $_POST['user_id'] == $route;
 $id = $_POST['id'] == $route;
$route = array(id => "$_POST[id]", completed => "$_POST[completed]",
route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");
foreach ($route as $key => $values) {
   echo("");
   echo $values;
  //MySQL Update statement will go here.
 }
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database 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: nl2br misprint

2005-01-21 Thread M. Sokolewicz
Scott DeMers wrote:
From the function page on php.net (
http://us4.php.net/manual/en/function.nl2br.php ):
"Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions
before 4.0.5 will return string with '' inserted before newlines instead
of ''."
Is this a misprint, ot does the revised function actually do this? According
to the w3c, "' is compliant, while "" is not; see
http://www.w3.org/TR/xhtml1/.
yes, that's what the text says. Maybe you missed the "*before* 4.0.5 
will return ''" part ;)
Scott DeMers
Web Coordinator
International Studies and Programs
Michigan State University
209 International Center
East Lansing, MI 48824-1035 U.S.A.
(517)355-2350 | Fax:(517)353-7254
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] nl2br misprint

2005-01-21 Thread Jason Wong
On Saturday 22 January 2005 07:36, Scott DeMers wrote:
> From the function page on php.net (
> http://us4.php.net/manual/en/function.nl2br.php ):
>
> "Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions
> before 4.0.5 will return string with '' inserted before newlines
> instead of ''."
>
> Is this a misprint, ot does the revised function actually do this?
> According to the w3c, "' is compliant, while "" is not; see
> http://www.w3.org/TR/xhtml1/.

Versions before 4.0.5 returns ""
Versions after 4.0.5 returns ""

There is no misprint, you're just interpreting it incorrectly.

-- 
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
--
New Year Resolution: Ignore top posted posts

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



RE: [PHP] nl2br misprint

2005-01-21 Thread Scott DeMers
Please disregard - I read it wrong.

-Original Message-
From: Scott DeMers [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 6:37 PM
To: php-general@lists.php.net
Subject: [PHP] nl2br misprint


>From the function page on php.net (
http://us4.php.net/manual/en/function.nl2br.php ):

"Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions
before 4.0.5 will return string with '' inserted before newlines instead
of ''."

Is this a misprint, ot does the revised function actually do this? According
to the w3c, "' is compliant, while "" is not; see
http://www.w3.org/TR/xhtml1/.

Scott DeMers
Web Coordinator
International Studies and Programs
Michigan State University
209 International Center
East Lansing, MI 48824-1035 U.S.A.
(517)355-2350 | Fax:(517)353-7254
[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] Notice:Use of undefined constant

2005-01-21 Thread Jason Wong
On Saturday 22 January 2005 06:20, Tamas Hegedus wrote:

> In a file, which is included into all my scripts, I defined constants
> (for MySQL access). PHP claims these constants as undifined constants,
> however, if I let them print out they have the right values
> (HOST='localhost'; NOT: HOST='HOST').

Where do you print them out? In the file in which they're defined or somewhere 
else?

> The output of my script:
> 
> PHP Notice:  Use of undefined constant HOST - assumed 'HOST' in
> /home/hegedus/bin/hae_chng.php on line 4

This suggests that your file containing the constants definitions was not 
included. Which means you're not going to be able to connect to mysql (unless 
by some fluke that your host happens to be 'HOST', etc).

> One solution could be to suppress php notices, but I think this is not
> the right treatment. Do you have any idea?

Suppressing notices/warnings/errors is never a solution. The solution is to 
not give them an excuse in appear in the first place.

-- 
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
--
New Year Resolution: Ignore top posted posts

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



[PHP] Using List() and a do-while loop with MySQL results.

2005-01-21 Thread Phillip S. Baker
Greetings all,

I am pulling records from a MySQL DB.
I am walking through the array using the whole.
if (  $row = mysql_fetch_assoc($result)) {
do{
//Some stuff
   }while (  $row = mysql_fetch_assoc($result));
}

What I am wondering is if there is something I can do like.

if (  list ($id, $someinfo) = mysql_fetch_assoc($result)) {
do{
//Some stuff
   }while (   list ($id, $someinfo) = mysql_fetch_assoc($result));
}

When I tried something like that
The variables where not populated.
Is there something I am doing wrong, or is this just something that cannot
be done (or is bad programming practice??)

Thanks.

--
Blessed Be

Phillip

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



Re: [PHP] Using List() and a do-while loop with MySQL results.

2005-01-21 Thread Jason Wong
On Saturday 22 January 2005 08:02, Phillip S. Baker wrote:

> I am pulling records from a MySQL DB.
> I am walking through the array using the whole.

You do realise that doing this ...

> if (  $row = mysql_fetch_assoc($result)) {
> do{
> //Some stuff
>}while (  $row = mysql_fetch_assoc($result));
> }

... effectively discards the first result of any resultset that you get? 
Unless that really is your intention then simply use a while-loop. If there 
aren't any results nothing in the while-loop will be executed (which means 
there is no need for the IF).

-- 
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
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Using List() and a do-while loop with MySQL results.

2005-01-21 Thread Jason Wong
On Saturday 22 January 2005 08:11, Jason Wong wrote:
> On Saturday 22 January 2005 08:02, Phillip S. Baker wrote:
> > I am pulling records from a MySQL DB.
> > I am walking through the array using the whole.
>
> You do realise that doing this ...
>
> > if (  $row = mysql_fetch_assoc($result)) {
> > do{
> > //Some stuff
> >}while (  $row = mysql_fetch_assoc($result));
> > }
>
> ... effectively discards the first result of any resultset that you get?
> Unless that really is your intention then simply use a while-loop. If there
> aren't any results nothing in the while-loop will be executed (which means
> there is no need for the IF).

Sorry, no it doesn't. But it's much clumsier than simply using a while-loop.

> --
> 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
> --
> New Year Resolution: Ignore top posted posts

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



Re: [PHP] Re: multiple sessions on same server/domain

2005-01-21 Thread Jordi Canals
On Fri, 21 Jan 2005 09:43:38 -0800 (PST), Richard Lynch <[EMAIL PROTECTED]> 
wrote:

> Thus my point remains:
> On a shared server, I don't need to resort to calling this function to
> hijack your Cookie/session.  PHP can read the raw session files.  I can
> write a PHP script to read the raw session files, regardless of what
> directory the Cookie is set to use to store/retrieve the Cookie whose
> purpose is to identify those files.
> 
> This is not something you can "fix" in any real-world scenario where it
> matters.

Of course you can fix it! You can change your sessions handler and
save your session data in a database. For that you can use the
session_set_save_handler().

Best regards,
Jordi.

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



[PHP] suspicious? maybe spam? what?

2005-01-21 Thread Chris W. Parker


Will whoever is causing "[suspicious - maybe spam]" to appear in the
subject of the PHP emails PLEASE WHITELIST THE PHP LIST. Ugh.. it's so
annoying.





Chris.

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



Re: [PHP] Notice:Use of undefined constant

2005-01-21 Thread Tamas Hegedus
In a file, which is included into all my scripts, I defined constants
(for MySQL access). PHP claims these constants as undifined constants,
however, if I let them print out they have the right values
(HOST='localhost'; NOT: HOST='HOST').
Where do you print them out? In the file in which they're defined or somewhere 
else?
I was wrong. In my test scritp I do not include any other file, just 
define the constants, and print them out.

This suggests that your file containing the constants definitions was not 
included. Which means you're not going to be able to connect to mysql (unless 
by some fluke that your host happens to be 'HOST', etc).
This could not happen, since I did not inserted any other file in my 
test script.

===
But now I run the test script on my local machine without any notice.
My php -v:
PHP 4.3.2 (cgi), Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
The script:
---

//-- Ez a teszt
define( HOST, 'localhost');
define( USER, 'hae');
define( PWD, 'hae');
define( DB, 'haetest');
echo 'Host/User/db: ' . HOST . USER . DB;
exit;
/*-- Ez az eredeti
define( HOST, 'localhost');
define( USER, 'h');
define( PWD, 'h');
define( DB, 'hae');
*/
$link = mysql_connect( HOST, USER, PWD);
mysql_select_db( DB);
...
Thanks,
Tamas
--
Tamas Hegedus, Research Fellow | phone: (1) 480-301-6041
Mayo Clinic Scottsdale | fax:   (1) 480-301-7017
13000 E. Shea Blvd | mailto:[EMAIL PROTECTED]
Scottsdale, AZ, 85259  | http://hegedus.brumart.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Notice:Use of undefined constant

2005-01-21 Thread Jason Wong
On Saturday 22 January 2005 08:28, Tamas Hegedus wrote:

> define( HOST, 'localhost');

  define('HOST', 'localhost');

-- 
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
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Using List() and a do-while loop with MySQL results.

2005-01-21 Thread Chris
Excerpt from http://www.php.net/list
"*Note: * *list()* only works on numerical arrays and assumes the 
numerical indices start at 0."

So the best way , in my opinion, to achieve this effect would be:
while(list($id, $someinfo) = mysql_fetch_row($result))
{
//Some stuff
}
Chris
Phillip S. Baker wrote:
Greetings all,
I am pulling records from a MySQL DB.
I am walking through the array using the whole.
if (  $row = mysql_fetch_assoc($result)) {
   do{
   //Some stuff
  }while (  $row = mysql_fetch_assoc($result));
}
What I am wondering is if there is something I can do like.
if (  list ($id, $someinfo) = mysql_fetch_assoc($result)) {
   do{
   //Some stuff
  }while (   list ($id, $someinfo) = mysql_fetch_assoc($result));
}
When I tried something like that
The variables where not populated.
Is there something I am doing wrong, or is this just something that cannot
be done (or is bad programming practice??)
Thanks.
--
Blessed Be
Phillip
 

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


  1   2   >