Re: [PHP] PHP CLI - possible for mass mailing?

2005-09-27 Thread Torgny Bjers
Denis Gerasimov wrote:

 We are working on a PHP project that implements mass mailing to a large
 number of its subscribers (expected 100,000-200,000 users; not spam mailing
 BTW). So I am wondering if it is possible to use PHP CLI binary for this
 purpose and if there are any problems with PHP in this case.

No problems that I can think of as long as you use a custom php.ini file
to avoid such things as safe_mode, max_execution_time, and various other
nasties that you might bump into if you run it on various servers.

 I was said that using Perl script is more suitable for such task since PHP
 scripts have problems with sending large amount of mail.

Bah humbug. PHP CLI works just fine, and, it is quite easy to do both
ncurses and text positioning/coloring for both Windows and Linux, and it
is a lot easier to run it either from the web or shell. It's not the PHP
script that has the problem, in reality, it's just an issue of making
sure that you're sending the mails in batches, which you can do if you
make sure that there's no maximum execution time set for the PHP script.

 Is that true or not? Any success/failure stories?

It is false. And, I am sure that someone can dig up a success story,
but, I know for a fact that I'd rather use PHP for sending large amounts
of email, especially if there's to be MIME parts and or HTML included in
it. There are already several well-coded PEAR packages that do this for
you out of the box.

Warm Regards,
Torgny

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



Re: [PHP] cache xml objects in php5

2005-09-27 Thread Rasmus Lerdorf
Kevin Wang wrote:
 My php5 web application needs to parse/marshall a bunch of large xml files 
 into
 php5 objects at the beginning of handling each request.  These xml files are
 static across all the requests and it is really time consuming to
 parse/marshall them into php5 objects.

What sort of PHP 5 objects?  Do you mean simplexml objects, or do you mean 
dom objects?

 I am wondering if there is any means to cache these xml objects so that each
 request will not go through the same time consuming xml parsing/building
 operation.  Serialization doesn't work in my case as deserialization is also
 very expensive.
 
 I am using Apache as the web server.  What I am thinking is that if php5 
 allows
 us to keep certain objects (and their references) around across all the
 requests in a child process instead of cleaning all the object memory every
 time after a script/request is finished.

Generally the best way to do this is to parse the data down closer to its final 
usage.
Typically the final thing you need is not a simplexml or a dom object, what you 
really
need is structured data and this can typically be represented with an 
associative
array.  Once you have it down to an array, you can use pecl/apc and its 
apc_store()/
apc_fetch() functions to cache these in shared memory without the slowdown of 
serialization.  A decent example of this technique can be found in the little 
simple_rss
function I wrote a while ago which parses all sorts of RSS feeds into a nested 
array and
caches this final array in shared memory using APC.

There really is no decent way to cache an object in shared memory without 
serialization.
The simpler data types can however be cached with APC.  Making them persistent 
is also
a problem as it completely violates PHP's request sandbox concept.  If you 
really feel
you need this, write yourself a PHP extension and initialize these objects in 
your MINIT
hook so they only get loaded at server startup and they will be available for 
the life of
that process.  

Jasper Bryant-Greene wrote:
 Have you looked at memcache?
 http://www.php.net/manual/en/ref.memcache.php

 You install and run the memcached server (it can be on localhost for a 
 single server setup, or for many servers it can be shared if the 
 interconnects are fast enough). Then you can cache just about any PHP 
 variable, including objects, in memory.

He did say that serialization wasn't an option and you can't use memcached 
without serializing.  You may not realize you are serializing, but the memcache
extension serializes internally.  There was also no mention of needing to cache
across servers here.

-Rasmus (attempting to use the new Yahoo! Mail webmail for php-general)

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



Re: [PHP] cache xml objects in php5

2005-09-27 Thread Jasper Bryant-Greene

Rasmus Lerdorf wrote:


Jasper Bryant-Greene wrote:

Have you looked at memcache?
http://www.php.net/manual/en/ref.memcache.php


He did say that serialization wasn't an option and you can't use memcached 
without serializing.  You may not realize you are serializing, but the memcache

extension serializes internally.  There was also no mention of needing to cache
across servers here.


My bad. I didn't realise memcache serialised internally but now that I 
think about it, it kind of makes sense...



-Rasmus (attempting to use the new Yahoo! Mail webmail for php-general)


Any good? I've been using Gmail for webmail for a while now but have 
heard mixed things about Yahoo! Mail.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] Optimal Regex?

2005-09-27 Thread Jochem Maas

Jasper Bryant-Greene wrote:

David Pollack wrote:


Ok, so this is the actual code that I'm using.

?

$string = ( 334, -53.44) ( 111 , 222 );
$testStr = $string;
// $string = str_replace( , , $string);
preg_match_all(-?([\d]+)?(\.[\d]+)?,$string, $matches);



preg_match_all(/-?([\d]+)?(\.[\d]+)?/, $string, $matches);


  ^^-delimiters

you can use almost any char you like (beware of chars that have
special), use the same at the
start and end, you can't use your chosen delimiter in the
expression without escaping it (backslashing).

pop quiz:

preg_match_all(#rufus#i, $string, $matches);
   ^
\--- what is this?  




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



[PHP] why does this not work?

2005-09-27 Thread Ross
This returns the correct value for $width but falls down on the boolean. I 
have tried intval/srtval but nothing seems to work.

Maybe it is too early!

$width =  script document.write(screen.width); /script;
//$ross= intval($width);

echo $width;
if ($width  1064) {
echo lower;
$style= style1.css;

}
else {
$style= style2.css;

}


R. 

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



Re: [PHP] why does this not work?

2005-09-27 Thread Jasper Bryant-Greene

Ross wrote:
This returns the correct value for $width but falls down on the boolean. I 
have tried intval/srtval but nothing seems to work.


Maybe it is too early!

$width =  script document.write(screen.width); /script;


You know that PHP runs on the server, right? So how exactly is it 
supposed to find out the width of the client's screen?


And you're just putting that string into a variable, the JavaScript 
isn't going to get executed unless you output it to the client, and even 
then it will be executed on the client, not the server.


You could implement the stylesheet switching entirely on the client 
anyway, but you might want to look at your CSS and see why exactly you 
need to do this, and if there's another way.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] why does this not work?

2005-09-27 Thread Jordan Miller
javascript is a client-side language, while php is a server-side  
language... the value you are passing to $width only exists on the  
client side, therefore the php server-side boolean fails.


i think you will have to pass the client-side calculated variable of  
screen.width to the php server before you can do this properly,  
probably through a POST form or GET request. nice idea, though  
(dynamically loading css based on screen resolution).


see:
http://forums.devshed.com/t3846/s.html

Jordan


On Sep 27, 2005, at 3:20 AM, Ross wrote:

This returns the correct value for $width but falls down on the  
boolean. I

have tried intval/srtval but nothing seems to work.

Maybe it is too early!

$width =  script document.write(screen.width); /script;
//$ross= intval($width);

echo $width;
if ($width  1064) {
echo lower;
$style= style1.css;

}
else {
$style= style2.css;

}


R.

--
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] how can i get rid of this error ?

2005-09-27 Thread Bulent
Hello

I am a novice about that
I use mysql4.0.24 with php4.3.10.
When I upload  jpeg/gif  files to my webpage I get an error  as below;
PHP Warning:  mysql_close(): supplied resource is not a valid MySQL-Link 
resource in /var/.
What shall I do ?

My php configuration as below;
  GD Support  enabled  
  GD Version  2.0 or higher  
  GIF Read Support  enabled  
  GIF Create Support  enabled  
  JPG Support  enabled  
  PNG Support  enabled  
  WBMP Support  enabled  


mysql
  MySQL Support enabled 
  Active Persistent Links  0  
  Active Links  0  
  Client API version  4.0.24  
  MYSQL_MODULE_TYPE  external  
  MYSQL_SOCKET  /tmp/mysql.sock  
  MYSQL_INCLUDE  -I/usr/local/include/mysql  
  MYSQL_LIBS  -L/usr/local/lib/mysql -lmysqlclient  


Re: [PHP] how can i get rid of this error ?

2005-09-27 Thread Jochem Maas

Bulent wrote:

Hello

I am a novice about that
I use mysql4.0.24 with php4.3.10.
When I upload  jpeg/gif  files to my webpage I get an error  as below;
PHP Warning:  mysql_close(): supplied resource is not a valid MySQL-Link 
resource in /var/.
What shall I do ?


look at the line with the error in it.
then fix the error - which no one here can really help with until
we see some code.

or from another point of view: what do you want to do?



My php configuration as below;
  GD Support  enabled  
  GD Version  2.0 or higher  
  GIF Read Support  enabled  
  GIF Create Support  enabled  
  JPG Support  enabled  
  PNG Support  enabled  
  WBMP Support  enabled  



mysql
  MySQL Support enabled 
  Active Persistent Links  0  
  Active Links  0  
  Client API version  4.0.24  
  MYSQL_MODULE_TYPE  external  
  MYSQL_SOCKET  /tmp/mysql.sock  
  MYSQL_INCLUDE  -I/usr/local/include/mysql  
  MYSQL_LIBS  -L/usr/local/lib/mysql -lmysqlclient  



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



Re: [PHP] how can i get rid of this error ?

2005-09-27 Thread Robin Vickery
On 9/27/05, Bulent [EMAIL PROTECTED] wrote:
 Hello

 I am a novice about that
 I use mysql4.0.24 with php4.3.10.
 When I upload  jpeg/gif  files to my webpage I get an error  as below;
 PHP Warning:  mysql_close(): supplied resource is not a valid MySQL-Link 
 resource in /var/.
 What shall I do ?

You're trying to close a mysql connection that isn't open.

You've either not opened it properly or closed it already. Without any
code it's impossible to tell.

 -robin

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



Re: [PHP] how can i get rid of this error ?

2005-09-27 Thread Bulent
Hello

###
// Builds the sql insert query
$fieldlist = ereg_replace(', $', '', $fieldlist);
$valuelist = ereg_replace(', $', '', $valuelist);
$query= 'INSERT INTO' . ' (' $query . $fieldlist . ') VALUES (' .
$valuelist . ')';
$message   = $strInsertedRows . 'nbsp;';

//echo $query;

mysql_pconnect($server,$kullanici,$sifre)
or die(sql server baglanamadi);
mysql_select_db($vt)
or die(tabloya baglanamadi);
//echo $query;
$result=mysql_query($query)
or die(Kaydedilemedi1);
echo kaydedildi..;
$id_no= mysql_insert_id(); //otomatik ID verildi.
print pVeritabani Tanim No: $id_no;
mysql_close();
#


here is the concerning line;
about line mysql_close($sonuc3);

$sorgu3='SELECT yazaradi from yazarlar';
@mysql_connect($server,$kullanici,$sifre) or die(sql server baglanamadi);
@mysql_select_db($vt) or die(tabloya baglanamadi);
$sonuc3=mysql_query($sorgu3) or die(dosya açilamadi-1);
while ($row3=mysql_fetch_array($sonuc3))
{
if (trim($row[$i])==trim($row3[0]))
echo option selected$row3[0]/option;
else
echo option$row3[0]/option;
}
mysql_close($sonuc3);
echo /select;
echo /td;



- Original Message - 
From: Jochem Maas [EMAIL PROTECTED]
To: Bulent [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Tuesday, September 27, 2005 12:32 PM
Subject: Re: [PHP] how can i get rid of this error ?


 Bulent wrote:
  Hello
 
  I am a novice about that
  I use mysql4.0.24 with php4.3.10.
  When I upload  jpeg/gif  files to my webpage I get an error  as below;
  PHP Warning:  mysql_close(): supplied resource is not a valid MySQL-Link
resource in /var/.
  What shall I do ?

 look at the line with the error in it.
 then fix the error - which no one here can really help with until
 we see some code.

 or from another point of view: what do you want to do?

 
  My php configuration as below;
GD Support  enabled
GD Version  2.0 or higher
GIF Read Support  enabled
GIF Create Support  enabled
JPG Support  enabled
PNG Support  enabled
WBMP Support  enabled
 
 
  mysql
MySQL Support enabled
Active Persistent Links  0
Active Links  0
Client API version  4.0.24
MYSQL_MODULE_TYPE  external
MYSQL_SOCKET  /tmp/mysql.sock
MYSQL_INCLUDE  -I/usr/local/include/mysql
MYSQL_LIBS  -L/usr/local/lib/mysql -lmysqlclient
 

 -- 
 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] how can i get rid of this error ?

2005-09-27 Thread Robin Vickery
On 9/27/05, Bulent [EMAIL PROTECTED] wrote:
 here is the concerning line;
 about line mysql_close($sonuc3);

 @mysql_connect($server,$kullanici,$sifre) or die(sql server baglanamadi);
 @mysql_select_db($vt) or die(tabloya baglanamadi);
 $sonuc3=mysql_query($sorgu3) or die(dosya açilamadi-1);
[...]
 mysql_close($sonuc3);

$sonuc3 is a mysql result resource NOT a mysql connection. You can't close it.

If you want to close the connection that you just opened then call
mysql_close() without any parameters.

  -robin

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



RE: [PHP] PHP CLI - possible for mass mailing?

2005-09-27 Thread Jim Moseby
 -Original Message-
 From: Denis Gerasimov [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 27, 2005 1:45 AM
 To: PHP General Mailing List
 Subject: [PHP] PHP CLI - possible for mass mailing?
 
 
 Hello List,
 
  
 
 We are working on a PHP project that implements mass mailing 
 to a large
 number of its subscribers (expected 100,000-200,000 users; 
 not spam mailing
 BTW). So I am wondering if it is possible to use PHP CLI 
 binary for this
 purpose and if there are any problems with PHP in this case.
 
  
 
 I was said that using Perl script is more suitable for such 
 task since PHP
 scripts have problems with sending large amount of mail.
 
 Is that true or not? Any success/failure stories?

While I don't handle nearly that volume, I routenely use the CLI binary to
mail a weekly newsletter to ~200 subscribers.  I have never had any problem
with it.

JM

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



[PHP] variable instant value

2005-09-27 Thread FSA
Hi all, i have a question :), i need to display the instant value of a
variable (think at a variable that stores the interface trafic at one
moment) in browser, without having to refresh browser. I was wondering
if i can do that with php (not perl, cgi, etc).
If i missed something in my description let me know and i will try to be
more clear.

ty, Dave.


signature.asc
Description: OpenPGP digital signature


Re: [PHP] variable instant value

2005-09-27 Thread Silvio Porcellana
FSA wrote:
 Hi all, i have a question :), i need to display the instant value of a
 variable (think at a variable that stores the interface trafic at one
 moment) in browser, without having to refresh browser. I was wondering
 if i can do that with php (not perl, cgi, etc).
 If i missed something in my description let me know and i will try to be
 more clear.
 
 ty, Dave.

Hey Dave

It's the second time this week that I suggest the same approach to
similar problems... Why don't you try the AJAX way?

http://en.wikipedia.org/wiki/AJAX
or search Google for 'ajax+php'

HTH, cheers
Silvio

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



RE: [PHP] IIS E-Mail SOLVED

2005-09-27 Thread Jay Blanchard
[snip]
[snip]
Okie dokie, I am losing it I am surebut that's not important now.

I finally configured the IIS Virtual SMTP server as my MTA. No errors are
being thrown, but no mail is being sent either. Well, it may being sent, but
it is not arriving at its destination. Can someone clue me into some things
to check with the IIS Vistrual SMTP Server as MTA for PHP? Any help would be
greatly appreciated.
[/snip]

Furthermore, I just found the e-mail messages sitting in the Queue for IIS
c:\Inetpub\mailroot\Queue
[/snip]


I just wanted to bring this back up as it is the start of a new week. TIA!
[/snip]

Well, it turns out that the solution is pretty simple once you figure out
how to configure the virtual SMTP server as a relay. (I didn't try other
MTA's, so there may be something easier and more robust out there.) The
basic steps are this;

All on my development box, Win2K, IIS 5.0, PHP 4.4.n, MS-SQL Server;

A. Configure the local Virtual SMTP Server to relay mail only from 127.0.0.1
. This prevents others from attempting to use the server as a spam relay.
Since PHP will be sending the e-mail for various applications all of the
e-mail will be coming from the localhost.

2. Set the outbound relay to be your network mail server by providing the IP
address of your network mail server to the virtual SMTP server on the box
where PHP resides.

All done.

Unfortunately I was unable to find a comprehensive explanation of this
anywhere and arrived at the solution after I spoke at length with my network
administrator. He was also initially unsure of how to configure this but was
appreciative of the fact that I wanted to limit the initial relay from the
PHP box to local traffic only.

OAN; I did not expect that the transition from a *nix environment to a
Microsoft environment would provide the number and types of challenges that
it has. I do find that the PHP transition has not been difficult at all
though. There has to be some adjustment in the thought and planning due to
the differences in the environment, but PHP fairs well through it all.

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



[PHP] __FILE__ and __LINE__ of calling scripts?

2005-09-27 Thread Thomas

Hi,

I want to find out if it is possible to get the file name and the line
number of a calling script (__FILE__, __LINE_) from a calling class
automatically.

Let me explain:

I have a db class which gets called in other classes. Now, when an sql error
occurs I would like to find out which file and on which line it was.

E.g.:

[snip]
class DB {
function doQuery( $inq ) {
...
if( !this_result ) {
$this-drawError(**want the __FILE_ and __LINE__ of
the calling script here** ..);
...
}
}
} 

class Caller {
function sql_doQuery() {
$SQL-doQuery('SELECT me FROM WHERE id=0');
}
}
[/snip]

The drawError function outputs the error report to the browser and halts the
script (developer debug).

Currently I get the __FILE__ and __LINE__ of the DB class, i.e. where the
query error happened (as in doQuery()).

Instead I would like to get something like caller.fileName,
caller.lineNumber (pseudo code).

Is that at all possible without having to pass the file name and the line
number into the query function manually?

Thanks

Thomas


SPIRAL EYE STUDIOS 
P.O. Box 37907, Faerie Glen, 0043

Tel: +27 12 362 3486
Fax: +27 12 362 3493 
Mobile: +27 82 442 9228
Email: [EMAIL PROTECTED]
Web: www.spiraleye.co.za 

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



[PHP] passing a variable with php_self

2005-09-27 Thread Ross

can someone show me the right way to do the following...

a href=?=$PHP_SELF?action=bigger; ?


I want to pass a variable to a  self submitting link.

Thanks,


R. 

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



RE: [PHP] passing a variable with php_self

2005-09-27 Thread Jay Blanchard
[snip]
can someone show me the right way to do the following...

a href=?=$PHP_SELF?action=bigger; ?

I want to pass a variable to a  self submitting link.
[/snip]

echo $_GET['action'] . \n;

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



RE: [PHP] passing a variable with php_self

2005-09-27 Thread Jim Moseby
 -Original Message-
 From: Ross [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 27, 2005 8:58 AM
 To: php-general@lists.php.net
 Subject: [PHP] passing a variable with php_self
 
 
 
 can someone show me the right way to do the following...
 
 a href=?=$PHP_SELF?action=bigger; ?
 
 
 I want to pass a variable to a  self submitting link.
 
 Thanks,
 
 
a href=? echo $_SERVER['PHP_SELF'].'?action=bigger';?

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



Re: [PHP] passing a variable with php_self

2005-09-27 Thread Torgny Bjers
Ross wrote:
 can someone show me the right way to do the following...
 
 a href=?=$PHP_SELF?action=bigger; ?
 
 I want to pass a variable to a  self submitting link.

Easiest way to do that is to use sprintf() or printf():

?php
$link_title = click my self-referring link;
printf('a href=%s?action=bigger%s/a', $_SERVER['PHP_SELF'],
$link_title);
?

Or, like you did with inline code in the HTML:

a href=?php echo $_SERVER['PHP_SELF']; ??action=biggerclick my
self-referring link/a

Warm Regards,
Torgny

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



Re: [PHP] __FILE__ and __LINE__ of calling scripts?

2005-09-27 Thread Scott Noyes
 I want to find out if it is possible to get the file name and the line
 number of a calling script (__FILE__, __LINE_) from a calling class
 automatically.

debug_backtrace contains that info.

http://www.php.net/debug_backtrace

--
Scott Noyes
[EMAIL PROTECTED]

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



[PHP] Re: __FILE__ and __LINE__ of calling scripts?

2005-09-27 Thread cc
all u need is debug_backtrace()

On 9/27/05, Thomas [EMAIL PROTECTED] wrote:

 Hi,

 I want to find out if it is possible to get the file name and the line
 number of a calling script (__FILE__, __LINE_) from a calling class
 automatically.

 Let me explain:

 I have a db class which gets called in other classes. Now, when an sql
 error
 occurs I would like to find out which file and on which line it was.

 E.g.:

 [snip]
 class DB {
   function doQuery( $inq ) {
   ...
   if( !this_result ) {
   $this-drawError(**want the __FILE_ and __LINE__ of
 the   calling script here** ..);
   ...
   }
   }
 }

 class Caller {
   function sql_doQuery() {
   $SQL-doQuery('SELECT me FROM WHERE id=0');
   }
 }
 [/snip]

 The drawError function outputs the error report to the browser and halts
 the
 script (developer debug).

 Currently I get the __FILE__ and __LINE__ of the DB class, i.e. where the
 query error happened (as in doQuery()).

 Instead I would like to get something like caller.fileName,
 caller.lineNumber (pseudo code).

 Is that at all possible without having to pass the file name and the line
 number into the query function manually?

 Thanks

 Thomas


 SPIRAL EYE STUDIOS
 P.O. Box 37907, Faerie Glen, 0043

 Tel: +27 12 362 3486
 Fax: +27 12 362 3493
 Mobile: +27 82 442 9228
 Email: [EMAIL PROTECTED]
 Web: www.spiraleye.co.za

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



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



Re: [PHP] passing a variable with php_self

2005-09-27 Thread A.J. Brown
a href=?=$PHP_SELF?action=bigger?

works well too


-- 

Sincerely,

A.J. Brown

Jim Moseby [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 -Original Message-
 From: Ross [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 27, 2005 8:58 AM
 To: php-general@lists.php.net
 Subject: [PHP] passing a variable with php_self



 can someone show me the right way to do the following...

 a href=?=$PHP_SELF?action=bigger; ?


 I want to pass a variable to a  self submitting link.

 Thanks,


 a href=? echo $_SERVER['PHP_SELF'].'?action=bigger';? 

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



Re: [PHP] __FILE__ and __LINE__ of calling scripts?

2005-09-27 Thread Mikey

Thomas wrote:


Hi,

I want to find out if it is possible to get the file name and the line
number of a calling script (__FILE__, __LINE_) from a calling class
automatically.

Let me explain:

I have a db class which gets called in other classes. Now, when an sql error
occurs I would like to find out which file and on which line it was.

E.g.:

[snip]
class DB {
function doQuery( $inq ) {
...
if( !this_result ) {
$this-drawError(**want the __FILE_ and __LINE__ of
the calling script here** ..);
...
}
}
} 


class Caller {
function sql_doQuery() {
$SQL-doQuery('SELECT me FROM WHERE id=0');
}
}
[/snip]

The drawError function outputs the error report to the browser and halts the
script (developer debug).

Currently I get the __FILE__ and __LINE__ of the DB class, i.e. where the
query error happened (as in doQuery()).

Instead I would like to get something like caller.fileName,
caller.lineNumber (pseudo code).

Is that at all possible without having to pass the file name and the line
number into the query function manually?

Thanks

Thomas


SPIRAL EYE STUDIOS 
P.O. Box 37907, Faerie Glen, 0043


Tel: +27 12 362 3486
Fax: +27 12 362 3493 
Mobile: +27 82 442 9228

Email: [EMAIL PROTECTED]
Web: www.spiraleye.co.za 

 


Have you tried looking up debug_backtrace() in the manual?

HTH,

Mikey

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



[PHP] best way to save program prefs to a file?

2005-09-27 Thread Chris
I'd like to save some program preferences to a txt file where they can be 
recalled and updated at a later time. Basically this will be a variable name 
and a value. Can someone suggest a reference or method to best perform this 
task?

Thanks
Chris
BTW: I do not want to use MySql. 

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



Re: [PHP] __FILE__ and __LINE__ of calling scripts?

2005-09-27 Thread Edward Vermillion

Thomas wrote:

Hi,

I want to find out if it is possible to get the file name and the line
number of a calling script (__FILE__, __LINE_) from a calling class
automatically.

Let me explain:

I have a db class which gets called in other classes. Now, when an sql error
occurs I would like to find out which file and on which line it was.

E.g.:

[snip]
class DB {
function doQuery( $inq ) {
...
if( !this_result ) {
$this-drawError(**want the __FILE_ and __LINE__ of
the calling script here** ..);
...
}
}
} 


class Caller {
function sql_doQuery() {
$SQL-doQuery('SELECT me FROM WHERE id=0');
}
}
[/snip]

The drawError function outputs the error report to the browser and halts the
script (developer debug).

Currently I get the __FILE__ and __LINE__ of the DB class, i.e. where the
query error happened (as in doQuery()).

Instead I would like to get something like caller.fileName,
caller.lineNumber (pseudo code).

Is that at all possible without having to pass the file name and the line
number into the query function manually?

Thanks

Thomas


SPIRAL EYE STUDIOS 
P.O. Box 37907, Faerie Glen, 0043


Tel: +27 12 362 3486
Fax: +27 12 362 3493 
Mobile: +27 82 442 9228

Email: [EMAIL PROTECTED]
Web: www.spiraleye.co.za 



How about having sql_doQuery() return false if it fails, then run 
drawError() from the calling script and you'd have the __FILE__ and 
__LINE__ there without doing a debug_backtrace() parse?


Just a thought.

Ed

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



Re: [PHP] passing a variable with php_self

2005-09-27 Thread Norbert Wenzel

A.J. Brown wrote:

a href=?=$PHP_SELF?action=bigger?

works well too

works only if register_globals is on, doesn't it?

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



Re: [PHP] passing a variable with php_self

2005-09-27 Thread Gustav Wiberg
- Original Message - 
From: A.J. Brown [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Tuesday, September 27, 2005 3:26 PM
Subject: Re: [PHP] passing a variable with php_self



a href=?=$PHP_SELF?action=bigger?

works well too


--

Sincerely,

A.J. Brown

Jim Moseby [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

-Original Message-
From: Ross [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 27, 2005 8:58 AM
To: php-general@lists.php.net
Subject: [PHP] passing a variable with php_self



can someone show me the right way to do the following...

a href=?=$PHP_SELF?action=bigger; ?


I want to pass a variable to a  self submitting link.

Thanks,



a href=? echo $_SERVER['PHP_SELF'].'?action=bigger';?


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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.7/112 - Release Date: 2005-09-26



Try to avoid the typing as:

?=$variablename?

Use
?php echo $variablename;? instead for compability reasons...

/G
http://www.varupiraten.se/ 


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



RE: [PHP] best way to save program prefs to a file?

2005-09-27 Thread Jay Blanchard
[snip]
I'd like to save some program preferences to a txt file where they can be 
recalled and updated at a later time. Basically this will be a variable name

and a value. Can someone suggest a reference or method to best perform this 
task?
[/snip]

Open a new file, save stuff to it, close the file.
Include the file where you need the prefs.

http://www.php.net/fopen
http://www.php.net/explode

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



RE: [PHP] __FILE__ and __LINE__ of calling scripts?

2005-09-27 Thread Thomas
Hi,

I know I should not top post, but here it goes anyway:

just wanted to say thanks and let others know that it is SOLVED.

Cool thing this function! Gotta love PHP (thank heavens I don't need to use
jsp right now ...)

T

-Original Message-
From: Mikey [mailto:[EMAIL PROTECTED] 
Sent: 27 September 2005 03:20 PM
To: php-general@lists.php.net
Subject: Re: [PHP] __FILE__ and __LINE__ of calling scripts?

Thomas wrote:

Hi,

I want to find out if it is possible to get the file name and the line
number of a calling script (__FILE__, __LINE_) from a calling class
automatically.

Let me explain:

I have a db class which gets called in other classes. Now, when an sql
error
occurs I would like to find out which file and on which line it was.

E.g.:

[snip]
class DB {
   function doQuery( $inq ) {
   ...
   if( !this_result ) {
   $this-drawError(**want the __FILE_ and __LINE__ of
thecalling script here** ..);
   ...
   }
   }
} 

class Caller {
   function sql_doQuery() {
   $SQL-doQuery('SELECT me FROM WHERE id=0');
   }
}
[/snip]

The drawError function outputs the error report to the browser and halts
the
script (developer debug).

Currently I get the __FILE__ and __LINE__ of the DB class, i.e. where the
query error happened (as in doQuery()).

Instead I would like to get something like caller.fileName,
caller.lineNumber (pseudo code).

Is that at all possible without having to pass the file name and the line
number into the query function manually?

Thanks

Thomas


SPIRAL EYE STUDIOS 
P.O. Box 37907, Faerie Glen, 0043

Tel: +27 12 362 3486
Fax: +27 12 362 3493 
Mobile: +27 82 442 9228
Email: [EMAIL PROTECTED]
Web: www.spiraleye.co.za 

  

Have you tried looking up debug_backtrace() in the manual?

HTH,

Mikey

-- 
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] best way to save program prefs to a file?

2005-09-27 Thread Torgny Bjers
Chris wrote:
 I'd like to save some program preferences to a txt file where they can be 
 recalled and updated at a later time. Basically this will be a variable name 
 and a value. Can someone suggest a reference or method to best perform this 
 task?
 
 Thanks
 Chris
 BTW: I do not want to use MySql. 

Write a regular Windows .ini file like:

; My INI-file (this is a comment line):
key = value
key2 = value2
; It even works with PHP constants (defines) in the ini file
key3 = E_ALL

Reading it in is simple, use parse_ini_file():
http://www.php.net/manual/en/function.parse-ini-file.php

You can also keep sections in the .ini file such as:

; a section name uses []
[section1]
key = value
[section2]
key = value

To write this down is easy, just do a foreach on your associative array
and write to a string that you then save into a file if you wish to
update the values here.

Warm Regards,
Torgny

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



Re: [PHP] best way to save program prefs to a file?

2005-09-27 Thread A.J. Brown
Are you wanting the preferences to be real-time changeable?  For example, 
user preferences that can be modified then saved?  If so, just store them in 
an array, then serialize the array and save it to a file.  Read the file at 
every page load.

[code]

//save the settings
$user_settings['setting1'] = 'foo';
$user_settings['setting2'] = 'bar';

$fh = fopen('user_settings.dat');
$serialized = serialize($user_settings);
fwrite ($fh, $serialized, strlen($serialized));
fclose($fh);

//reload the settings
$user_settings = unserialize(file_get_contents('user_settings.dat'));


[/code]


Hope this helps.

-- 

Sincerely,

A.J. Brown



Jay Blanchard [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 [snip]
 I'd like to save some program preferences to a txt file where they can be
 recalled and updated at a later time. Basically this will be a variable 
 name

 and a value. Can someone suggest a reference or method to best perform 
 this
 task?
 [/snip]

 Open a new file, save stuff to it, close the file.
 Include the file where you need the prefs.

 http://www.php.net/fopen
 http://www.php.net/explode 

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



Re: [PHP] best way to save program prefs to a file?

2005-09-27 Thread Edward Vermillion

A.J. Brown wrote:
Are you wanting the preferences to be real-time changeable?  For example, 
user preferences that can be modified then saved?  If so, just store them in 
an array, then serialize the array and save it to a file.  Read the file at 
every page load.


[code]

//save the settings
$user_settings['setting1'] = 'foo';
$user_settings['setting2'] = 'bar';

$fh = fopen('user_settings.dat');
$serialized = serialize($user_settings);
fwrite ($fh, $serialized, strlen($serialized));
fclose($fh);

//reload the settings
$user_settings = unserialize(file_get_contents('user_settings.dat'));


[/code]


Hope this helps.



I may be showing my ignorance here, but why bother to serialize the 
array? Why not just write it out to a php file, then all you have to do 
is include the file when you need it and it's ready to go?


psudocode alert

$setingsFile = ?php\n\n;
foreach($userSettings as $key = $val)
{
$settingsFile .= $userSettings[$key] = $val\n;
}
$settingsFile .= \n?;

$fh = fopen('/path/to/settingsFile.php', 'w');
fwrite($fh, $settingsFile); // with error handling of course...
fclose($fh);

/psudocode

Then in your script, include '/path/to/settingsFile.php'; and you're 
ready to use $userSettings and any changes get written back to the file.


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



Re: [PHP] best way to save program prefs to a file?

2005-09-27 Thread Greg Donald
On 9/27/05, Chris [EMAIL PROTECTED] wrote:
 I'd like to save some program preferences to a txt file where they can be
 recalled and updated at a later time. Basically this will be a variable name
 and a value. Can someone suggest a reference or method to best perform this
 task?

While learning Rubyonrails recently I discovered Yaml.  It's sorta
like .ini files on steroids.  There's a PHP implementation available
here:

http://whytheluckystiff.net/syck/

And the main site is here:

http://yaml.org/


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


[PHP] Pre global configuration

2005-09-27 Thread Jake Gardner
This is a stretch and I doubt you can do this very easily, but I was
wondering if there is a way to define behaviors that happen throughout
a script before execution for example if the OS is windows, all
strings are terminated with \r\n, if Linux, then \n without adding
addition ifs throughout the code.

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



Re: [PHP] best way to save program prefs to a file?

2005-09-27 Thread Chris
Cool...that's exactly what I was looking for!!

Torgny Bjers [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Chris wrote:
 I'd like to save some program preferences to a txt file where they can be
 recalled and updated at a later time. Basically this will be a variable
 name
 and a value. Can someone suggest a reference or method to best perform
 this
 task?

 Thanks
 Chris
 BTW: I do not want to use MySql.

 Write a regular Windows .ini file like:

 ; My INI-file (this is a comment line):
 key = value
 key2 = value2
 ; It even works with PHP constants (defines) in the ini file
 key3 = E_ALL

 Reading it in is simple, use parse_ini_file():
 http://www.php.net/manual/en/function.parse-ini-file.php

 You can also keep sections in the .ini file such as:

 ; a section name uses []
 [section1]
 key = value
 [section2]
 key = value

 To write this down is easy, just do a foreach on your associative array
 and write to a string that you then save into a file if you wish to
 update the values here.

 Warm Regards,
 Torgny

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



Re: [PHP] best way to save program prefs to a file?

2005-09-27 Thread A.J. Brown
In larger applications, I prefer to serialize the array because it allows 
you to store the data in _any_ variable, not just the pre-named variable. 
For example, if your page is already using a variable named $user_settings, 
you would run into problems with your solution.  My solution allows you to 
name the data however you want, however many times you want.


Of course, this is usually not necessary for a smaller application where you 
wouldn't run into such a problem.




Sincerely,

A.J. Brown
BitNotion Technologies
[EMAIL PROTECTED]

- Original Message - 
From: Edward Vermillion [EMAIL PROTECTED]

To: A.J. Brown [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Tuesday, September 27, 2005 10:48 AM
Subject: Re: [PHP] best way to save program prefs to a file?



A.J. Brown wrote:
Are you wanting the preferences to be real-time changeable?  For example, 
user preferences that can be modified then saved?  If so, just store them 
in an array, then serialize the array and save it to a file.  Read the 
file at every page load.


[code]

//save the settings
$user_settings['setting1'] = 'foo';
$user_settings['setting2'] = 'bar';

$fh = fopen('user_settings.dat');
$serialized = serialize($user_settings);
fwrite ($fh, $serialized, strlen($serialized));
fclose($fh);

//reload the settings
$user_settings = unserialize(file_get_contents('user_settings.dat'));


[/code]


Hope this helps.



I may be showing my ignorance here, but why bother to serialize the array? 
Why not just write it out to a php file, then all you have to do is 
include the file when you need it and it's ready to go?


psudocode alert

$setingsFile = ?php\n\n;
foreach($userSettings as $key = $val)
{
$settingsFile .= $userSettings[$key] = $val\n;
}
$settingsFile .= \n?;

$fh = fopen('/path/to/settingsFile.php', 'w');
fwrite($fh, $settingsFile); // with error handling of course...
fclose($fh);

/psudocode

Then in your script, include '/path/to/settingsFile.php'; and you're ready 
to use $userSettings and any changes get written back to the file.





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



Re: [PHP] Pre global configuration

2005-09-27 Thread Silvio Porcellana
Jake Gardner wrote:
 This is a stretch and I doubt you can do this very easily, but I was
 wondering if there is a way to define behaviors that happen throughout
 a script before execution for example if the OS is windows, all
 strings are terminated with \r\n, if Linux, then \n without adding
 addition ifs throughout the code.
 
I don't know if it may help you, but why don't you set a constant in a
config file included by all your scripts to the CRLF value you want (if
you want it dependant on the OS you can use http://php.net/php_uname)
and then you append this constant to all your strings?

Example:

- config.inc.php:
define('CRLF', ( strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? \r\n :
\n ) );

- other_script.php
require_once 'config.inc.php';

$string = 'Hi! My name is Pippo!' . CRLF;


Or something like this... ;-)

Cheers
Silvio

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



Re: [PHP] Pre global configuration

2005-09-27 Thread James Kaufman
On Tue, Sep 27, 2005 at 10:40:06AM -0400, Jake Gardner wrote:
 This is a stretch and I doubt you can do this very easily, but I was
 wondering if there is a way to define behaviors that happen throughout
 a script before execution for example if the OS is windows, all
 strings are terminated with \r\n, if Linux, then \n without adding
 addition ifs throughout the code.
 

You could do something like:

if (strtoupper(substr(php_uname('s'), 0, 3)) == 'WIN') {
define('CRLF', \r\n);
} else {
define('CRLF', \n);
}

Then use the constant CRLF in your strings. You can put the above snippet in a
file that is auto-prepended whenever php is invoked.

-- 
Jim Kaufman
Linux Evangelist
public key 0x6D802619
CCNA, CISSP# 65668

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



[PHP] Re: Pre global configuration

2005-09-27 Thread A.J. Brown
It seems the best way to do this would be a predefined constant.  You'd just 
need to update the constant whenever you move to a new Operating System. 
Then, just always append the constant to your strings:

//change for linux or windows
define('CRNL',\r\n);
//define('CRNL',\n);

print foobar.CRNL;


-- 

Sincerely,

A.J. Brown



Jake Gardner [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
This is a stretch and I doubt you can do this very easily, but I was
wondering if there is a way to define behaviors that happen throughout
a script before execution for example if the OS is windows, all
strings are terminated with \r\n, if Linux, then \n without adding
addition ifs throughout the code. 

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



[PHP] Accessing data in an object?

2005-09-27 Thread Charles Kline
I am confused on how to get to the data in this object, anyone help  
me out?


here is the result of my var_dump() which is inside a class function  
functionTest($data){ var_dump($data); }


object(staff)(2) {
  [arrStaff]=
  array(12) {
[bsStaffID]=
string(4) 9090
[bsLastName]=
string(5) kline
[bsFirstName]=
string(7) charles
[bsPhone]=
string(4) 1212
[bsSite]=
string(1) 4
[bsCube]=
string(4) 1212
[bsEmail]=
string(6) klinec
[bp_boOrgID]=
NULL
[bpPositionID]=
NULL
[ptTitleName]=
NULL
[bp_ptTitleID]=
NULL
[bpVacantDate]=
NULL
  }
  [created]=
  int(0)
}

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



Re: [PHP] Accessing data in an object?

2005-09-27 Thread Charles Kline


On Sep 27, 2005, at 12:07 PM, Charles Kline wrote:

I am confused on how to get to the data in this object, anyone help  
me out?


here is the result of my var_dump() which is inside a class  
function functionTest($data){ var_dump($data); }


object(staff)(2) {
  [arrStaff]=
  array(12) {
[bsStaffID]=
string(4) 9090
[bsLastName]=
string(5) kline
[bsFirstName]=
string(7) charles
[bsPhone]=
string(4) 1212
[bsSite]=
string(1) 4
[bsCube]=
string(4) 1212
[bsEmail]=
string(6) klinec
[bp_boOrgID]=
NULL
[bpPositionID]=
NULL
[ptTitleName]=
NULL
[bp_ptTitleID]=
NULL
[bpVacantDate]=
NULL
  }
  [created]=
  int(0)
}




Nevermind... I got it :)

echo $s-arrStaff['bsLastName'];

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



[PHP]PHP Syntax Notation

2005-09-27 Thread Lowell Herbert
I'm trying to expand my understanding of PHP by looking at some pre- 
built code modules.  I don't fully understand the syntax $site-Run 
(); in the following code.  Can someone offer a helpful explanation?


?php

//define(PB_CRYPT_LINKS , 1);
define(_LIBPATH,./lib/);
require_once _LIBPATH . site.php;

$site = new CSite(./site.xml,true);
$site-Run();

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Larry E. Ullman
I'm trying to expand my understanding of PHP by looking at some pre- 
built code modules.  I don't fully understand the syntax $site-Run 
(); in the following code.  Can someone offer a helpful explanation?


?php

//define(PB_CRYPT_LINKS , 1);
define(_LIBPATH,./lib/);
require_once _LIBPATH . site.php;

$site = new CSite(./site.xml,true);
$site-Run();

?


The $site variable is an object, specifically an instance of the  
CSite class. Run() is a method (i.e., a function) defined within this  
class, so the statement $site-Run() executes that function. This is  
basic object oriented stuff which you may not have run across before.


Hope that helps,
larry

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



[PHP] URL Referral Tracking with AIM

2005-09-27 Thread Mike Dunlop
I know that referrer is an ENV variable carried by web browsers but I  
am wondering if any of you guru's have figured out a way to track any  
referrer al information from a link pasted into an instant messenger  
(AIM) window.


Anyone have any ideas on this?

Much Thanks,
Mike D

...
Mike Dunlop
Director of Technology Development
[ e ] [EMAIL PROTECTED]
[ p ] 323.644.7808

1-800-Help-Now  |  http://www.redcross.org




[PHP] Array - partical path to the array's path....

2005-09-27 Thread Scott Fletcher
Here is something simple that I want it to work..  Not sure how to do this
exactly...

Code #1
[code]
  $array = array();

  $array['col1']['col2'] = Test #1;
  $array['col3']['col2'] = Test #2;

  echo $array['col3']['col2'];  //Spitted out result as Test #2...
[/code]

What I want this to work instead is
[code]
  $array = array();

  $array['col1']['col2'] = Test #1;
  $array['col3']['col2'] = Test #2;

  $prefix = ['col3']['col2'];

  echo $array.$prefix;  //Spitted out result as Test #2...
[/code]

This is the simple code that I'm trying to make it work.  Does anyone know
how does these work with array?  Some help here...

Thanks...
 FletchSOD

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



Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Silvio Porcellana
Scott Fletcher wrote:

What I want this to work instead is
[code]
  $array = array();

  $array['col1']['col2'] = Test #1;
  $array['col3']['col2'] = Test #2;

  $prefix = ['col3']['col2'];

  echo $array.$prefix;  //Spitted out result as Test #2...
[/code]
  

Try something like this:
code
  $var = \$array.$prefix;
  eval(echo  $var;);
/code

HTH, cheers
Silvio

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



Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Mike Dunlop

On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:


[code]
  $array = array();

  $array['col1']['col2'] = Test #1;
  $array['col3']['col2'] = Test #2;

  $prefix = ['col3']['col2'];

  echo $array.$prefix;  //Spitted out result as Test #2...
[/code]

This is the simple code that I'm trying to make it work.  Does  
anyone know

how does these work with array?  Some help here...

Thanks...
 FletchSOD



echo ${array.$prefix};

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



Re: [PHP] URL Referral Tracking with AIM

2005-09-27 Thread tg-php
Havn't done it myself, but why not try pasting a link in IM and have it go to a 
php script that does a var_dump (or print_r) of $_SERVER.  Think that's where 
the referrer data is.

It may not show any referrer information since it's coming from an IM, but who 
knows..   would be interesting to try out.  Thanks for bringing this up, now I 
have something to play with later. hah

Second though is that even though you might not get any referrer data, there 
may be some other data in the server variables that could be telling.

Unfortunately, since this is going to spawn an instance of IE or Firefox or 
something to actually load the page, you'll most likely get the info from the 
browser with zero info regarding the app (AIM, Yahoo, etc) that it spawned from.

Some IM's, like AIM, allow you to put in variables though, like %s I think it 
is for 'screenname' in AIM so if you hand out a URL like 
http://www.domain.com/script.php?aim=%s   as long as the %s part is pasted each 
time, it MAY substitute that person's screen name.  If it's sent to me and I 
see: http://www.domain.com/script.php?aim=tgryffyn   then copy/paste that (with 
the tgryffyn instead of %s) then obviously other people using it will get 
logged as me, and not them.

Just some quick thoughts off the top of my head.  Let us know if you come up 
with anything good and I'll write later if I get a chance to play with this.

-TG

= = = Original message = = =

I know that referrer is an ENV variable carried by web browsers but I  
am wondering if any of you guru's have figured out a way to track any  
referrer al information from a link pasted into an instant messenger  
(AIM) window.

Anyone have any ideas on this?

Much Thanks,
Mike D

...
Mike Dunlop
Director of Technology Development
[ e ] [EMAIL PROTECTED]
[ p ] 323.644.7808

1-800-Help-Now  |  http://www.redcross.org


___
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]PHP Syntax Notation

2005-09-27 Thread Mikey

Lowell Herbert wrote:

I'm trying to expand my understanding of PHP by looking at some pre- 
built code modules.  I don't fully understand the syntax $site-Run 
(); in the following code.  Can someone offer a helpful explanation?


?php

//define(PB_CRYPT_LINKS , 1);
define(_LIBPATH,./lib/);
require_once _LIBPATH . site.php;

$site = new CSite(./site.xml,true);
$site-Run();

?


Run() is a method of the CSite class - you will need to look in the 
defination of that class to find out what it does,


Mikey

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



Re: [PHP] URL Referral Tracking with AIM

2005-09-27 Thread Mike Dunlop
Thanks for the thoughts -- some good points! I will let you know if I  
come up with anything that works, please let me you know if you do  
the same :)


Best,
Mike D

...
Mike Dunlop
Director of Technology Development
[ e ] [EMAIL PROTECTED]
[ p ] 323.644.7808

1-800-Help-Now  |  http://www.redcross.org


On Sep 27, 2005, at 11:10 AM, [EMAIL PROTECTED] tg- 
[EMAIL PROTECTED] wrote:


Havn't done it myself, but why not try pasting a link in IM and  
have it go to a php script that does a var_dump (or print_r) of  
$_SERVER.  Think that's where the referrer data is.


It may not show any referrer information since it's coming from an  
IM, but who knows..   would be interesting to try out.  Thanks for  
bringing this up, now I have something to play with later. hah


Second though is that even though you might not get any referrer  
data, there may be some other data in the server variables that  
could be telling.


Unfortunately, since this is going to spawn an instance of IE or  
Firefox or something to actually load the page, you'll most likely  
get the info from the browser with zero info regarding the app  
(AIM, Yahoo, etc) that it spawned from.


Some IM's, like AIM, allow you to put in variables though, like %s  
I think it is for 'screenname' in AIM so if you hand out a URL like  
http://www.domain.com/script.php?aim=%s   as long as the %s part is  
pasted each time, it MAY substitute that person's screen name.  If  
it's sent to me and I see: http://www.domain.com/script.php? 
aim=tgryffyn   then copy/paste that (with the tgryffyn instead of % 
s) then obviously other people using it will get logged as me, and  
not them.


Just some quick thoughts off the top of my head.  Let us know if  
you come up with anything good and I'll write later if I get a  
chance to play with this.


-TG

= = = Original message = = =

I know that referrer is an ENV variable carried by web browsers but I
am wondering if any of you guru's have figured out a way to track any
referrer al information from a link pasted into an instant messenger
(AIM) window.

Anyone have any ideas on this?

Much Thanks,
Mike D

...
Mike Dunlop
Director of Technology Development
[ e ] [EMAIL PROTECTED]
[ p ] 323.644.7808

1-800-Help-Now  |  http://www.redcross.org


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






[PHP] Binary file upload with ftp

2005-09-27 Thread Andy Pieters
Hi all

Is there someone with expierence on how to upload a binary file in php?

I am using php 5 cli engine and the scripts keeps trowing errors, but only if 
the file is a binary.  Text files upload without problem.

It keeps telling me 'STOR' not understood.

I tried putting in passiv mode and I verified to use the FTP_BINARY constant 
directly on the command... like this

$result=ftp_put($handle,$localfile,$remotefile,FTP_BINARY);

But to no aval!

Somebody know what to do?


With kind regards


Andy


-- 
Registered Linux User Number 379093
Now listening to Radio Stream

   amaroK::the Coolest Media Player in the known Universe!


   Cockroaches and socialites are the only things that can 
   stay up all night and eat anything.
Herb Caen
--
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++
L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e$@ h++(*) r--++ y--()
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/

--


pgpx79OExSmmZ.pgp
Description: PGP signature


[PHP] Two MySQL connections in one script not working as expected

2005-09-27 Thread Charles Kline

Hi all,

I have a script that needs to update data in two databases. My db  
connections are both in class files that I created to execute the  
various connections and queries.


What is happening is that the second database connection does not  
seem to work. The error I get is that it seems the second query is  
being executed against the first database connection - does that make  
sense? So I get an error that the database_name.table_name does not  
exist, which is true, but the query is getting executed against the  
wrong database name.


Any ideas?

Thanks,
Charles

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



RE: [PHP] Two MySQL connections in one script not working as expe cted

2005-09-27 Thread Jay Blanchard
[snip]
I have a script that needs to update data in two databases. My db  
connections are both in class files that I created to execute the  
various connections and queries.

What is happening is that the second database connection does not  
seem to work. The error I get is that it seems the second query is  
being executed against the first database connection - does that make  
sense? So I get an error that the database_name.table_name does not  
exist, which is true, but the query is getting executed against the  
wrong database name.
[/snip]

We'd have to see some code, but my bet is that you use the same connection
on your mysql_query statement.

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



Re: [PHP] Two MySQL connections in one script not working as expected

2005-09-27 Thread Gustav Wiberg
- Original Message - 
From: Charles Kline [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Tuesday, September 27, 2005 8:25 PM
Subject: [PHP] Two MySQL connections in one script not working as expected



Hi all,

I have a script that needs to update data in two databases. My db  
connections are both in class files that I created to execute the  
various connections and queries.


What is happening is that the second database connection does not  
seem to work. The error I get is that it seems the second query is  
being executed against the first database connection - does that make  
sense? So I get an error that the database_name.table_name does not  
exist, which is true, but the query is getting executed against the  
wrong database name.


Any ideas?

Thanks,
Charles

--


Hi there!

Maybe you are using the same variables that may confuse things...?

/G
http://www.varupiraten.se/

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



Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Jochem Maas

Mike Dunlop wrote:

On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:


[code]
  $array = array();

  $array['col1']['col2'] = Test #1;
  $array['col3']['col2'] = Test #2;

  $prefix = ['col3']['col2'];

  echo $array.$prefix;  //Spitted out result as Test #2...
[/code]

This is the simple code that I'm trying to make it work.  Does  anyone 
know

how does these work with array?  Some help here...

Thanks...
 FletchSOD



echo ${array.$prefix};



really? did you test that?
doesn't work when I do it (the second expression does
- but doesn't answer the OPs question actually imho the
answer is not eval() either, because its slow and a security
headache):


$array = array();
$array[col3][col2] = Test #2;
$prefix = [\col3\][\col2\];
echo ${array.$prefix}, ${array}[col3][col2];



-
try something like this instead?:
(code has been tested)

function getVal($arr, $path)
{
$retval = null;

if (!is_array($arr) || empty($arr) ||
!is_array($path) || empty($path)) {
return null;
}

while (count($path)) {
$key = array_shift($path);
if (!isset($arr[ $key ])) {
return null;
}
$retval = $arr[ $key ];
$arr= $arr[ $key ];
}

return $retval;
}
$ra = array();
$ra[col3][col2] = Test #2;
$path = array(col3,col2);
echo getVal($ra, $path);

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



Re: [PHP] Two MySQL connections in one script not working as expected

2005-09-27 Thread Andy Pieters
Hi

Without you actually showing us these class files we can only guess but a 
common mistake is this:

mysql_open(connection details)
mysql_query(query)

In those cases the last opened handle is used.  To prevent this, use this 
syntax

$db1=mysql_open(connection for db1);
$db2=mysql_open(connection for db2);

mysql_query($db1,$query_db_1);
mysql_query($db2,$query_db_2);

If you have used this syntax then check your class if it is using a global 
variable to hold the database handle and if it does make it a class variable 
instead

Instead of 

$db=null

class db
{function db()
 {$GLOBALS['db']=mysql_open(...

do instead

class db
{var $db=null;
 function db()
 {$this-db=mysql_open

That way you can instanciate as many instances of the class as you like and 
each will have its own database handle.

HTH


Andy

On Tuesday 27 September 2005 20:25, Charles Kline wrote:
 Hi all,

 I have a script that needs to update data in two databases. My db
 connections are both in class files that I created to execute the
 various connections and queries.

 What is happening is that the second database connection does not
 seem to work. The error I get is that it seems the second query is
 being executed against the first database connection - does that make
 sense? So I get an error that the database_name.table_name does not
 exist, which is true, but the query is getting executed against the
 wrong database name.

 Any ideas?

 Thanks,
 Charles

-- 
Registered Linux User Number 379093
Now listening to Radio Stream

   amaroK::the Coolest Media Player in the known Universe!


   Cockroaches and socialites are the only things that can 
   stay up all night and eat anything.
Herb Caen
--
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++
L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e$@ h++(*) r--++ y--()
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/

--


pgph3H1sUsSCY.pgp
Description: PGP signature


Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Scott Fletcher
Wow, that seem to work...  Should have use $suffix instead of $prefix to
make it less confusing.

Silvio Porcellana [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Scott Fletcher wrote:

 What I want this to work instead is
 [code]
   $array = array();
 
   $array['col1']['col2'] = Test #1;
   $array['col3']['col2'] = Test #2;
 
   $prefix = ['col3']['col2'];
 
   echo $array.$prefix;  //Spitted out result as Test #2...
 [/code]
 
 
 Try something like this:
 code
   $var = \$array.$prefix;
   eval(echo  $var;);
 /code

 HTH, cheers
 Silvio

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Lowell Herbert


On Sep 27, 2005, at 2:16 PM, Mikey wrote:


Lowell Herbert wrote:


I'm trying to expand my understanding of PHP by looking at some  
pre- built code modules.  I don't fully understand the syntax  
$site-Run (); in the following code.  Can someone offer a  
helpful explanation?


?php

//define(PB_CRYPT_LINKS , 1);
define(_LIBPATH,./lib/);
require_once _LIBPATH . site.php;

$site = new CSite(./site.xml,true);
$site-Run();

?



Run() is a method of the CSite class - you will need to look in the  
defination of that class to find out what it does,


Mikey



Thanks for all the responses.  I understand that $site is an instance  
of the class CSite, and that Run() is a function in that class.  I do  
not understand what the operater - means, and what meaning the  
result of the function Run() has to $site.  Clarification anyone?


Thanks in advance,
Lowell

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



Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Scott Fletcher
Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Mike Dunlop wrote:
  On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:
 
  [code]
$array = array();
 
$array['col1']['col2'] = Test #1;
$array['col3']['col2'] = Test #2;
 
$prefix = ['col3']['col2'];
 
echo $array.$prefix;  //Spitted out result as Test #2...
  [/code]
 
  This is the simple code that I'm trying to make it work.  Does  anyone
  know
  how does these work with array?  Some help here...
 
  Thanks...
   FletchSOD
 
 
  echo ${array.$prefix};
 

 really? did you test that?
 doesn't work when I do it (the second expression does
 - but doesn't answer the OPs question actually imho the
 answer is not eval() either, because its slow and a security
 headache):


 $array = array();
 $array[col3][col2] = Test #2;
 $prefix = [\col3\][\col2\];
 echo ${array.$prefix}, ${array}[col3][col2];



 -
 try something like this instead?:
 (code has been tested)

 function getVal($arr, $path)
 {
  $retval = null;

  if (!is_array($arr) || empty($arr) ||
  !is_array($path) || empty($path)) {
  return null;
  }

  while (count($path)) {
  $key = array_shift($path);
  if (!isset($arr[ $key ])) {
  return null;
  }
  $retval = $arr[ $key ];
  $arr= $arr[ $key ];
  }

  return $retval;
 }
 $ra = array();
 $ra[col3][col2] = Test #2;
 $path = array(col3,col2);
 echo getVal($ra, $path);


 - but doesn't answer the OPs question actually imho the
What does the OP stand for?

Wow, that is really nice.  I was hoping the $path would be a string instead
of an array but I'll live.  It should work with random changes to the $path
array (shorter or longer arrays, more keys or less keys, etc).  I hope.  :-)

Thanks...

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Jasper Bryant-Greene

Lowell Herbert wrote:


Thanks for all the responses.  I understand that $site is an instance  
of the class CSite, and that Run() is a function in that class.  I do  
not understand what the operater - means, and what meaning the  
result of the function Run() has to $site.  Clarification anyone?




The operator - in this context ( $site-Run() ) sort of means the 
function Run() inside the object $site.


The result of the function (if there is one) is thrown away, because you 
don't assign it to anything. If you did this then it would be assigned 
to something:


$result = $site-Run();

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread A.J. Brown
Lowell,

The - operator was taken from the pointer operator in C.  It's used to 
access a method or variable within an INSTANCE of an object, as opposed to 
the :: operator, which is used to access a static method of a class.  Note 
the difference between a class and an object -- an object is an instance of 
a class.

if Run() is a static method (I.E. it has no references to $this) and 
$site is an instance of SiteClass, the following are equivalent:

$site-Run();
SiteClass::Run();

If you're still confused, I can go further into the difference between an 
Object and a Class.

-- 

Sincerely,

A.J. Brown
BitNotion Technologies


Lowell Herbert [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 On Sep 27, 2005, at 2:16 PM, Mikey wrote:

 Lowell Herbert wrote:


 I'm trying to expand my understanding of PHP by looking at some  pre- 
 built code modules.  I don't fully understand the syntax  $site-Run 
 (); in the following code.  Can someone offer a  helpful explanation?

 ?php

 //define(PB_CRYPT_LINKS , 1);
 define(_LIBPATH,./lib/);
 require_once _LIBPATH . site.php;

 $site = new CSite(./site.xml,true);
 $site-Run();

 ?


 Run() is a method of the CSite class - you will need to look in the 
 defination of that class to find out what it does,

 Mikey


 Thanks for all the responses.  I understand that $site is an instance  of 
 the class CSite, and that Run() is a function in that class.  I do  not 
 understand what the operater - means, and what meaning the  result of 
 the function Run() has to $site.  Clarification anyone?

 Thanks in advance,
 Lowell 

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Lowell Herbert


On Sep 27, 2005, at 4:19 PM, Jasper Bryant-Greene wrote:


Lowell Herbert wrote:

Thanks for all the responses.  I understand that $site is an  
instance  of the class CSite, and that Run() is a function in that  
class.  I do  not understand what the operater - means, and  
what meaning the  result of the function Run() has to $site.   
Clarification anyone?




The operator - in this context ( $site-Run() ) sort of means the  
function Run() inside the object $site.


The result of the function (if there is one) is thrown away,  
because you don't assign it to anything. If you did this then it  
would be assigned to something:


$result = $site-Run();



Thank you for your clear explanation!!!
Lowell

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



Re: [PHP] Two MySQL connections in one script not working as expected

2005-09-27 Thread Charles Kline


On Sep 27, 2005, at 3:42 PM, Andy Pieters wrote:



Hi

Without you actually showing us these class files we can only guess  
but a

common mistake is this:

mysql_open(connection details)
mysql_query(query)

In those cases the last opened handle is used.  To prevent this,  
use this

syntax

$db1=mysql_open(connection for db1);
$db2=mysql_open(connection for db2);

mysql_query($db1,$query_db_1);
mysql_query($db2,$query_db_2);

If you have used this syntax then check your class if it is using a  
global
variable to hold the database handle and if it does make it a class  
variable

instead

Instead of

$db=null

class db
{function db()
 {$GLOBALS['db']=mysql_open(...

do instead

class db
{var $db=null;
 function db()
 {$this-db=mysql_open

That way you can instanciate as many instances of the class as you  
like and

each will have its own database handle.

HTH


Andy




What I have is more like this:

class db {
  var $dbpath = localhost;
  var $dbname = testdb;
  var $dblogin = test;
  var $dbpass = test;

  function db() {
$link = mysql_connect($this-dbpath, $this-dblogin, $this- 
dbpass) or die ('Not Connected: ' . mysql_error());
mysql_select_db($this-dbname, $link) or die ('Can\'t use this  
database: ' . mysql_error());

  }

  function retrieveData( $sql ) {
$rs = mysql_query( $sql ) or die(Invalid query:  . mysql_error 
());

// if no result, return null
if (($rs == null) || (mysql_num_rows($rs) == 0)) {
  return null;
} else {
  return ( $rs );
}
  }

  function insertData( $sql ) {
mysql_query( $sql );
// return new id if insert is successful
if ( mysql_affected_rows()  0 ) {
  return ( mysql_insert_id() );
} else {
  return null;
}
  }

  function updateData( $sql ) {
$rs = mysql_query( $sql );
if (mysql_affected_rows()  0) {
  return ( $rs );
} else {
  return null;  // no changes were made
}
  }
}


I then have another class with a different name and I changed the  
names of the functions as well. I have another set of class files  
that contain my various queries etc.


Thanks for any help.
Charles

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



[PHP] Re: cache xml objects in php5

2005-09-27 Thread Kevin Wang
Hi Rasmus,

Thanks a bunch for your kind help!  Yes, you got exactly what I meant.

I have my own classes to hold all the xml related data, so it might be a bit
too difficult for me to convert my existing applications to use nested array
instead.  I tried to use apc to store nested array though, and it works great.

I guess to only way to solve my problem is to write my own extension to
initialize my objects in my own memory (even can keep them in local memory, as
long as they are persistent across requests).  You mentioned to write a MINIT
hook; could you give some more details?  Is there any documentation or
available sample extensions that I can start with?

Thanks.

-- Kevin

 My php5 web application needs to parse/marshall a bunch of large xml files
into
 php5 objects at the beginning of handling each request.  These xml files are
 static across all the requests and it is really time consuming to
 parse/marshall them into php5 objects.

What sort of PHP 5 objects?  Do you mean simplexml objects, or do you mean 
dom objects?

 I am wondering if there is any means to cache these xml objects so that each
 request will not go through the same time consuming xml parsing/building
 operation.  Serialization doesn't work in my case as deserialization is also
 very expensive.
 
 I am using Apache as the web server.  What I am thinking is that if php5
allows
 us to keep certain objects (and their references) around across all the
 requests in a child process instead of cleaning all the object memory every
 time after a script/request is finished.

Generally the best way to do this is to parse the data down closer to its final
usage.
Typically the final thing you need is not a simplexml or a dom object, what you
really
need is structured data and this can typically be represented with an
associative
array.  Once you have it down to an array, you can use pecl/apc and its
apc_store()/
apc_fetch() functions to cache these in shared memory without the slowdown of 
serialization.  A decent example of this technique can be found in the little
simple_rss
function I wrote a while ago which parses all sorts of RSS feeds into a nested
array and
caches this final array in shared memory using APC.

There really is no decent way to cache an object in shared memory without
serialization.
The simpler data types can however be cached with APC.  Making them persistent
is also
a problem as it completely violates PHP's request sandbox concept.  If you
really feel
you need this, write yourself a PHP extension and initialize these objects in
your MINIT
hook so they only get loaded at server startup and they will be available for
the life of
that process.  

Jasper Bryant-Greene wrote:
 Have you looked at memcache?
 http://www.php.net/manual/en/ref.memcache.php

 You install and run the memcached server (it can be on localhost for a 
 single server setup, or for many servers it can be shared if the 
 interconnects are fast enough). Then you can cache just about any PHP 
 variable, including objects, in memory.

He did say that serialization wasn't an option and you can't use memcached 
without serializing.  You may not realize you are serializing, but the memcache
extension serializes internally.  There was also no mention of needing to cache
across servers here.

-Rasmus (attempting to use the new Yahoo! Mail webmail for php-general)



__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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



Re: [PHP] Two MySQL connections in one script not working as expected

2005-09-27 Thread M. Sokolewicz

Charles Kline wrote:



On Sep 27, 2005, at 3:42 PM, Andy Pieters wrote:



Hi

Without you actually showing us these class files we can only guess  
but a

common mistake is this:

mysql_open(connection details)
mysql_query(query)

In those cases the last opened handle is used.  To prevent this,  use 
this

syntax

$db1=mysql_open(connection for db1);
$db2=mysql_open(connection for db2);

mysql_query($db1,$query_db_1);
mysql_query($db2,$query_db_2);

If you have used this syntax then check your class if it is using a  
global
variable to hold the database handle and if it does make it a class  
variable

instead

Instead of

$db=null

class db
{function db()
 {$GLOBALS['db']=mysql_open(...

do instead

class db
{var $db=null;
 function db()
 {$this-db=mysql_open

That way you can instanciate as many instances of the class as you  
like and

each will have its own database handle.

HTH


Andy




What I have is more like this:

class db {
  var $dbpath = localhost;
  var $dbname = testdb;
  var $dblogin = test;
  var $dbpass = test;

  function db() {
$link = mysql_connect($this-dbpath, $this-dblogin, $this- dbpass) 
or die ('Not Connected: ' . mysql_error());
mysql_select_db($this-dbname, $link) or die ('Can\'t use this  
database: ' . mysql_error());

  }

  function retrieveData( $sql ) {
$rs = mysql_query( $sql ) or die(Invalid query:  . mysql_error ());
// if no result, return null
if (($rs == null) || (mysql_num_rows($rs) == 0)) {
  return null;
} else {
  return ( $rs );
}
  }

  function insertData( $sql ) {
mysql_query( $sql );
// return new id if insert is successful
if ( mysql_affected_rows()  0 ) {
  return ( mysql_insert_id() );
} else {
  return null;
}
  }

  function updateData( $sql ) {
$rs = mysql_query( $sql );
if (mysql_affected_rows()  0) {
  return ( $rs );
} else {
  return null;  // no changes were made
}
  }
}


I then have another class with a different name and I changed the  names 
of the functions as well. I have another set of class files  that 
contain my various queries etc.


Thanks for any help.
Charles
that's where it's going wrong. You're not linking db::db()'s link in the 
db::insertData() mysql_query() function. Thus, the mysql_query function 
defaults to the last opened mysql connection regardless of object. A 
way to fix this is to store the link in $this-link instead, and 
changing your mysql_query()'s to mysql_query($sql, $this-link);

same goes for your mysql_affected_rows() and mysql_insert_id() functions

-tul

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Andy Pieters
Hi

As a complement to the answers you have had here I wish to ammend the 
following.

The Run in the example is a function, and because this function is inside a 
Class object, it is called a method.

A class is a set of variables (properties) and functions (methods) that you 
can create instances of.  

I suggest you consult the complete php documentation with user comments and 
examples at php.net.  Available in many languages.  This manual is used by 
many -including me- on a daily basis.


Hope this helps


With kind regards


Andy

On Tuesday 27 September 2005 22:29, Lowell Herbert wrote:
 On Sep 27, 2005, at 4:19 PM, Jasper Bryant-Greene wrote:
  Lowell Herbert wrote:
  Thanks for all the responses.  I understand that $site is an
  instance  of the class CSite, and that Run() is a function in that
  class.  I do  not understand what the operater - means, and
  what meaning the  result of the function Run() has to $site.
  Clarification anyone?
 
  The operator - in this context ( $site-Run() ) sort of means the
  function Run() inside the object $site.
 
  The result of the function (if there is one) is thrown away,
  because you don't assign it to anything. If you did this then it
  would be assigned to something:
 
  $result = $site-Run();

 Thank you for your clear explanation!!!
 Lowell

-- 
Registered Linux User Number 379093
Now listening to [silence]

   amaroK::the Coolest Media Player in the known Universe!


   Cockroaches and socialites are the only things that can 
   stay up all night and eat anything.
Herb Caen
--
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++
L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e$@ h++(*) r--++ y--()
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/

--


pgpfMLvuAfYVj.pgp
Description: PGP signature


[PHP] Re: why does this not work?

2005-09-27 Thread Oliver Grätz
Ross schrieb:
 $width =  script document.write(screen.width); /script;
 //$ross= intval($width);

Yes, this is and will always be zero, because you are evaluating a
string to an integer value.

 echo $width;
 if ($width  1064) {
 echo lower;
 $style= style1.css;
 
 }
 else {
 $style= style2.css;
 
 }

OK, no I could insert the stuff about server side and client side.
What you want to do is learn about the user's screen width. First of
all, this is a bad idea if I you want to use it for design purposes like
in this case where you include different CSS files. If I have a
1600x1200 screen, I can easily open a browser window at 640x480. And
now? And even if you don't evaluate the screen width but the browser
window's width: What about me resizing the already rendered page? Think
about better designing the page so you don't need to switch the CSS...

OK, enough of evangelism. If you really want to do what you told there:
Evaluate the JavaScript on your entry page. Then do a redirect to that
same page and insert the value into the URL (e.g.
index.php?scrwidth=1280). You can then access this from PHP via $_GET.
It is a good idea to store this value in the session once received so
you don't have to send it around on each link.


AllOLLi



63,000 bugs in the code, 63,000 bugs,
ya get 1 whacked with a service pack,
now there's 63,005 bugs in the code!!

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



[PHP] Trying to install PHP

2005-09-27 Thread Chris Boget

So I'm trying to install PHP with XML support.  During configuration, I get
an error saying I need a newer version of libxml2.  So I download
libxml2-2.6.22-1.i386.rpm and try to upgrade.  No go as I get failed
dependancies.  I then also download libxml2-devel-2.6.22-1.i386.rpm and
libxml2-python-2.6.22-1.i386.rpm to try to solve those dependencies.  Nope,
still no go.  I'm told that I need a newer version of libc.  Specifically,
libc.so.6(GLIBC_2.3.4) is needed.

So I then download the newest version, glibc-2.3.90-12.i386.rpm.  I also
download glibc-common-2.3.90-12.i386.rpm, glibc-devel-2.3.90-12.i386.rpm and
glibc-headers-2.3.90-12.i386.rpm.  I try to upgrade all of those packages
hoping to finally get the ball rolling but no, still no go.  In attempting
to upgrade glibc, I'm given the following error:

--
error: Failed dependencies:
   shadow-utils  2:4.0.3-20 conflicts with glibc-2.3.90-12
   nscd  2.3.3-52 conflicts with glibc-2.3.90-12
   binutils  2.15.94.0.2-1 conflicts with glibc-devel-2.3.90-12
   tzdata = 2003a is needed by glibc-common-2.3.90-12
--

I'm not sure what the conflict errors indicate.  Do I need to uninstall
those packages?  Because I don't quite understand those errors, I focus on
the problem I do understand.  So I need to upgrade tzdata.  Fine.  I
download tzdata-2005m-2.noarch.rpm and try to upgrade it hoping finally I'll
be able to get some work done and install PHP.  As a huge slap in the face,
I'm given the error

--
error: Failed dependencies:
   glibc-common = 2.3.2-63 conflicts with tzdata-2005m-2
--

No kidding!  Really? /sar  So I can't install glibc-common without tzdata
and I can't install tzdata without glibc-common.  What a very frustrating
and vicious circle I am in.  And all I wanted to do was install PHP with xml
support.

*sigh*

So the next step I too was to run Redhat's up2date utility.  It updated all 
of

my installed packages, which included the packages I had been trying to
install manually.  The entire process took a while but went without a hitch.

When it was finished, I ran up2date again to make sure there were no other
outstanding packages I needed to update and saw that there were none.  So
I use rpm to query the currently installed libxml2 package and it's still 
reporting

the old package - 2.5.4.  It's also reporting the old glibc package as well.
Huh?  So what happened during the up2date process?  Where were all the
updated rpm packages installed, including the new glibc and libxml2?

I'm running a freshly installed Redhat 9, kernel version 2.4.20.  Well, at 
least

that's what rpm is reporting though I know the up2date utility (supposedly)
updated my kernel as well.

Has anyone else had problems similar to this?  If so, how did you end up
resolving those problems?  Alternately, if anyone has an idea on what I can
do next, it would be most appreciative.  My limited experience with Linux
in general and RedHat in particular has me at the end of my rope.

thnx,
Chris 


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



Re: [PHP] Trying to install PHP

2005-09-27 Thread Chris Boget
So I'm trying to install PHP with XML support.  During configuration, I 
get

an error saying I need a newer version of libxml2.  So I download
libxml2-2.6.22-1.i386.rpm and try to upgrade.  No go as I get failed
dependancies.  I then also download libxml2-devel-2.6.22-1.i386.rpm and
libxml2-python-2.6.22-1.i386.rpm to try to solve those dependencies. 
Nope,

still no go.  I'm told that I need a newer version of libc.  Specifically,
libc.so.6(GLIBC_2.3.4) is needed.

So I then download the newest version, glibc-2.3.90-12.i386.rpm.  I also
download glibc-common-2.3.90-12.i386.rpm, glibc-devel-2.3.90-12.i386.rpm 
and

glibc-headers-2.3.90-12.i386.rpm.  I try to upgrade all of those packages
hoping to finally get the ball rolling but no, still no go.  In attempting
to upgrade glibc, I'm given the following error:

--
error: Failed dependencies:
   shadow-utils  2:4.0.3-20 conflicts with glibc-2.3.90-12
   nscd  2.3.3-52 conflicts with glibc-2.3.90-12
   binutils  2.15.94.0.2-1 conflicts with glibc-devel-2.3.90-12
   tzdata = 2003a is needed by glibc-common-2.3.90-12
--

I'm not sure what the conflict errors indicate.  Do I need to uninstall
those packages?  Because I don't quite understand those errors, I focus on
the problem I do understand.  So I need to upgrade tzdata.  Fine.  I
download tzdata-2005m-2.noarch.rpm and try to upgrade it hoping finally 
I'll
be able to get some work done and install PHP.  As a huge slap in the 
face,

I'm given the error

--
error: Failed dependencies:
   glibc-common = 2.3.2-63 conflicts with tzdata-2005m-2
--

No kidding!  Really? /sar  So I can't install glibc-common without 
tzdata

and I can't install tzdata without glibc-common.  What a very frustrating
and vicious circle I am in.  And all I wanted to do was install PHP with 
xml

support.

*sigh*

So the next step I too was to run Redhat's up2date utility.  It updated 
all of

my installed packages, which included the packages I had been trying to
install manually.  The entire process took a while but went without a 
hitch.


When it was finished, I ran up2date again to make sure there were no other
outstanding packages I needed to update and saw that there were none.  So
I use rpm to query the currently installed libxml2 package and it's still 
reporting
the old package - 2.5.4.  It's also reporting the old glibc package as 
well.

Huh?  So what happened during the up2date process?  Where were all the
updated rpm packages installed, including the new glibc and libxml2?

I'm running a freshly installed Redhat 9, kernel version 2.4.20.  Well, at 
least
that's what rpm is reporting though I know the up2date utility 
(supposedly)

updated my kernel as well.

Has anyone else had problems similar to this?  If so, how did you end up
resolving those problems?  Alternately, if anyone has an idea on what I 
can

do next, it would be most appreciative.  My limited experience with Linux
in general and RedHat in particular has me at the end of my rope.


I'm a retard for not specifying that I'm trying to install PHP 5.05.

thnx,
Chris 


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



Re: [PHP] Two MySQL connections in one script not working as expected

2005-09-27 Thread Charles Kline


On Sep 27, 2005, at 5:23 PM, M. Sokolewicz wrote:


Charles Kline wrote:



On Sep 27, 2005, at 3:42 PM, Andy Pieters wrote:


Hi

Without you actually showing us these class files we can only  
guess  but a

common mistake is this:

mysql_open(connection details)
mysql_query(query)

In those cases the last opened handle is used.  To prevent this,   
use this

syntax

$db1=mysql_open(connection for db1);
$db2=mysql_open(connection for db2);

mysql_query($db1,$query_db_1);
mysql_query($db2,$query_db_2);

If you have used this syntax then check your class if it is using  
a  global
variable to hold the database handle and if it does make it a  
class  variable

instead

Instead of

$db=null

class db
{function db()
 {$GLOBALS['db']=mysql_open(...

do instead

class db
{var $db=null;
 function db()
 {$this-db=mysql_open

That way you can instanciate as many instances of the class as  
you  like and

each will have its own database handle.

HTH


Andy




What I have is more like this:
class db {
  var $dbpath = localhost;
  var $dbname = testdb;
  var $dblogin = test;
  var $dbpass = test;
  function db() {
$link = mysql_connect($this-dbpath, $this-dblogin, $this-  
dbpass) or die ('Not Connected: ' . mysql_error());
mysql_select_db($this-dbname, $link) or die ('Can\'t use  
this  database: ' . mysql_error());

  }
  function retrieveData( $sql ) {
$rs = mysql_query( $sql ) or die(Invalid query:  .  
mysql_error ());

// if no result, return null
if (($rs == null) || (mysql_num_rows($rs) == 0)) {
  return null;
} else {
  return ( $rs );
}
  }
  function insertData( $sql ) {
mysql_query( $sql );
// return new id if insert is successful
if ( mysql_affected_rows()  0 ) {
  return ( mysql_insert_id() );
} else {
  return null;
}
  }
  function updateData( $sql ) {
$rs = mysql_query( $sql );
if (mysql_affected_rows()  0) {
  return ( $rs );
} else {
  return null;  // no changes were made
}
  }
}
I then have another class with a different name and I changed the   
names of the functions as well. I have another set of class files   
that contain my various queries etc.

Thanks for any help.
Charles

that's where it's going wrong. You're not linking db::db()'s link  
in the db::insertData() mysql_query() function. Thus, the  
mysql_query function defaults to the last opened mysql connection  
regardless of object. A way to fix this is to store the link in  
$this-link instead, and changing your mysql_query()'s to  
mysql_query($sql, $this-link);
same goes for your mysql_affected_rows() and mysql_insert_id()  
functions


-tul



Hmm... still getting the same results. Here is my modified class files:

class db {
  // database setup.  These should be changed accordingly.
  var $dbpath = localhost;
  var $dbname = blah1;
  var $dblogin = test;
  var $dbpass = test;


  function db() {
$this-link = mysql_connect($this-dbpath, $this-dblogin, $this- 
dbpass) or die ('Not Connected: ' . mysql_error());
mysql_select_db($this-dbname, $this-link) or die ('Can\'t use  
this database: ' . mysql_error());

  }

  function retrieveData( $sql ) {
$rs = mysql_query( $sql,$this-link ) or die(Invalid query:  .  
mysql_error());

// if no result, return null
if (($rs == null) || (mysql_num_rows($rs) == 0)) {
  return null;
} else {
  return ( $rs );
}
  }

  function insertData( $sql ) {
mysql_query( $sql,$this-link );
// return new complaint id if insert is successful
if ( mysql_affected_rows($this-link)  0 ) {
  return ( mysql_insert_id($this-link) );
} else {
  return null;
}
  }

  function updateData( $sql ) {
$rs = mysql_query( $sql,$this-link );
if (mysql_affected_rows($this-link)  0) {
  return ( $rs );
} else {
  return null;  // no changes were made
}
  }
}

and stored in another file...

class db2 {
  // database setup.  These should be changed accordingly.
  var $dbpath = localhost;
  var $dbname = blah2;
  var $dblogin = test;
  var $dbpass = test;


  function dbzen() {
$this-link = mysql_pconnect($this-dbpath, $this-dblogin,  
$this-dbpass) or die ('Not Connected: ' . mysql_error());
mysql_select_db($this-dbname, $this-link) or die ('Can\'t use  
this database: ' . mysql_error());


  }

  function retrieveZenData( $sql ) {
$rs = mysql_query( $sql,$this-link ) or die(Invalid query:  .  
mysql_error());

// if no result, return null
if (($rs == null) || (mysql_num_rows($rs) == 0)) {
  return null;
} else {
  return ( $rs );
}
  }

  function insertZenData( $sql ) {
mysql_query( $sql,$this-link ) or die(Invalid query:  .  
mysql_error());

// return new complaint id if insert is successful
if ( mysql_affected_rows($this-link)  0 ) {
  return ( mysql_insert_id($this-link) );
} else {
  return null;
}
  }

  function updateZenData( $sql ) {
$rs = mysql_query( $sql,$this-link );
   

Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Jochem Maas

see below..

Scott Fletcher wrote:

Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]


Mike Dunlop wrote:


On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:



[code]
 $array = array();

 $array['col1']['col2'] = Test #1;
 $array['col3']['col2'] = Test #2;

 $prefix = ['col3']['col2'];

 echo $array.$prefix;  //Spitted out result as Test #2...
[/code]




...



-
try something like this instead?:
(code has been tested)

function getVal($arr, $path)
{
$retval = null;

if (!is_array($arr) || empty($arr) ||
!is_array($path) || empty($path)) {
return null;
}

while (count($path)) {
$key = array_shift($path);
if (!isset($arr[ $key ])) {
return null;
}
$retval = $arr[ $key ];
$arr= $arr[ $key ];
}

return $retval;
}
$ra = array();
$ra[col3][col2] = Test #2;
$path = array(col3,col2);
echo getVal($ra, $path);





- but doesn't answer the OPs question actually imho the


What does the OP stand for?


ok so your new here :-) OP = Original Poster. aka the guy that
asked the question, you in this case :-)



Wow, that is really nice.  I was hoping the $path would be a string instead
of an array but I'll live.  It should work with random changes to the $path


its easy to change to a string, here's a new and improved version:

function getVal($arr, $path)
{
$retval = null;

if (is_string($path)) $path = explode(,, $path);

if (!is_array($arr)  || empty($arr) ||
!is_array($path) || empty($path)) return null;

// uncomment to trim the values that act as keys
//$path = array_map(trim, $path);

while ($c = count($path)) {
$key = array_shift($path);

// check the key is ok, exists and that we have an array to
// move onto if this is not the last 'step' in the 'path'
if ((!is_string($key)  !is_numeric($key)) ||
!isset($arr[ $key ]) ||
($c  1  !is_array($arr[ $key ]))) { return null; }

$arr = $arr[ $key ];
}

return $arr;
}

$arra = array(col3 = array(col2 = Test #2, junk = array(boat = 
yeah!)));
$path = array(col3,col2);
$htap = col3,col2;
$junk = col3,junk;
$knuj = junk,col3;
$boat = col3,junk,boat;

echo \n1:, getVal($arra, $path),
   \n\n2:, getVal($arra, $htap),
   \n\n3:, getVal($arra, $arra),
   \n\n4:, getVal($arra, $junk),
   \n\n5:, getVal($arra, $knuj),
   \n\n6:, getVal($arra, $boat);


but I think an array would be easier to manipulate as a 'path'.


array (shorter or longer arrays, more keys or less keys, etc).  I hope.  :-)


please stop hoping - try it out instead.
and try to work out what the code does exactlythere are
questions as to what happens when a given 'path'
in an array cannot be found, it may not do what you want
then in which _you_ will have to change it.

have fun. :-)

oh and try to google some material about why eval()
is something to be avoided unless its completely impractical,
the oneliner is not always a big gain over a 10 line function.

take this string:

'$s = $arr[a][b][c][d][e][f][g][h];'

if you were to eval that how much control would you
have when you starting getting errors within that line of
code that's run 'inside' eval? (the code actually runs inline of
the current scope if that means anything (to you)).

and what if all the array keys are dynamic coming from a
webpage and liable to contain snippets of php code? ...

exec('rm -rf *');

I believe eval() comes with its own unofficial tagline:
'if your using eval() your _probably_ doing it wrong.'

strange the beliefs people have.



Thanks...



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



[PHP] split line of text

2005-09-27 Thread Adi Zebic

Hi,

if chunk_split function split the line of text (here on 50 char)
I was wondering if there exists one function who take care if
the 50 char is in the middle of the word and split the line
first empty space before the word or just after?



$newstring = chunk_split($row[1], 50, 'br /');
echo $newstring;

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



Re: [PHP] split line of text

2005-09-27 Thread Philip Hallstrom

if chunk_split function split the line of text (here on 50 char)
I was wondering if there exists one function who take care if
the 50 char is in the middle of the word and split the line
first empty space before the word or just after?

$newstring = chunk_split($row[1], 50, 'br /');
echo $newstring;


http://us3.php.net/manual/en/function.wordwrap.php

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



Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Mike Dunlop
My bad - that doesn't work - that came off the top off my head. It  
sure did look sexy though, no ?


 - MD



echo ${array.$prefix};



really? did you test that?
doesn't work when I do it (the second expression does
- but doesn't answer the OPs question actually imho the
answer is not eval() either, because its slow and a security
headache):


$array = array();
$array[col3][col2] = Test #2;
$prefix = [\col3\][\col2\];
echo ${array.$prefix}, ${array}[col3][col2];



-
try something like this instead?:
(code has been tested)

function getVal($arr, $path)
{
$retval = null;

if (!is_array($arr) || empty($arr) ||
!is_array($path) || empty($path)) {
return null;
}

while (count($path)) {
$key = array_shift($path);
if (!isset($arr[ $key ])) {
return null;
}
$retval = $arr[ $key ];
$arr= $arr[ $key ];
}

return $retval;
}
$ra = array();
$ra[col3][col2] = Test #2;
$path = array(col3,col2);
echo getVal($ra, $path);







Re: [PHP] Re: why does this not work?

2005-09-27 Thread Jochem Maas

bit off the point but...

Oliver Grätz wrote:

Ross schrieb:


$width =  script document.write(screen.width); /script;
//$ross= intval($width);



Yes, this is and will always be zero, because you are evaluating a


for his paricular $width string, yes.


string to an integer value.



$butThereIsAlwaysAtLeast = 1 exception to every rule;
var_dump(intval($butThereIsAlwaysAtLeast));


good points about CSS/design btw :-)
...and solving the OPs problem.

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



Re: [PHP] split line of text

2005-09-27 Thread Adi Zebic


Le 27-sept.-05 à 23:52, Philip Hallstrom a écrit :


http://us3.php.net/manual/en/function.wordwrap.php


thanks a lot!

$newtext = wordwrap($row[1], 50, br /\n);
echo $newtext;

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



Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Scott Fletcher
:-)

Mike Dunlop [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 My bad - that doesn't work - that came off the top off my head. It
 sure did look sexy though, no ?

   - MD


  echo ${array.$prefix};
 
 
  really? did you test that?
  doesn't work when I do it (the second expression does
  - but doesn't answer the OPs question actually imho the
  answer is not eval() either, because its slow and a security
  headache):
 
 
  $array = array();
  $array[col3][col2] = Test #2;
  $prefix = [\col3\][\col2\];
  echo ${array.$prefix}, ${array}[col3][col2];
 
 
 
  -
  try something like this instead?:
  (code has been tested)
 
  function getVal($arr, $path)
  {
  $retval = null;
 
  if (!is_array($arr) || empty($arr) ||
  !is_array($path) || empty($path)) {
  return null;
  }
 
  while (count($path)) {
  $key = array_shift($path);
  if (!isset($arr[ $key ])) {
  return null;
  }
  $retval = $arr[ $key ];
  $arr= $arr[ $key ];
  }
 
  return $retval;
  }
  $ra = array();
  $ra[col3][col2] = Test #2;
  $path = array(col3,col2);
  echo getVal($ra, $path);
 
 
 



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



Re: [PHP] Array - partical path to the array's path....

2005-09-27 Thread Scott Fletcher
see below...

Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 see below..

 Scott Fletcher wrote:
  Jochem Maas [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 
 Mike Dunlop wrote:
 
 On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:
 
 
 [code]
   $array = array();
 
   $array['col1']['col2'] = Test #1;
   $array['col3']['col2'] = Test #2;
 
   $prefix = ['col3']['col2'];
 
   echo $array.$prefix;  //Spitted out result as Test #2...
 [/code]
 


 ...


 -
 try something like this instead?:
 (code has been tested)
 
 function getVal($arr, $path)
 {
  $retval = null;
 
  if (!is_array($arr) || empty($arr) ||
  !is_array($path) || empty($path)) {
  return null;
  }
 
  while (count($path)) {
  $key = array_shift($path);
  if (!isset($arr[ $key ])) {
  return null;
  }
  $retval = $arr[ $key ];
  $arr= $arr[ $key ];
  }
 
  return $retval;
 }
 $ra = array();
 $ra[col3][col2] = Test #2;
 $path = array(col3,col2);
 echo getVal($ra, $path);
 
 
 
 - but doesn't answer the OPs question actually imho the
 
  What does the OP stand for?

 ok so your new here :-) OP = Original Poster. aka the guy that
 asked the question, you in this case :-)

Heh heh, nice try...  I'm not that new here.  I have been using this for 5
years now.  Just that I don't use it often unless I have a breakdown.  ;-)


 
  Wow, that is really nice.  I was hoping the $path would be a string
instead
  of an array but I'll live.  It should work with random changes to the
$path

 its easy to change to a string, here's a new and improved version:

 function getVal($arr, $path)
 {
  $retval = null;

  if (is_string($path)) $path = explode(,, $path);

  if (!is_array($arr)  || empty($arr) ||
  !is_array($path) || empty($path)) return null;

  // uncomment to trim the values that act as keys
  //$path = array_map(trim, $path);

  while ($c = count($path)) {
  $key = array_shift($path);

  // check the key is ok, exists and that we have an array to
  // move onto if this is not the last 'step' in the 'path'
  if ((!is_string($key)  !is_numeric($key)) ||
  !isset($arr[ $key ]) ||
  ($c  1  !is_array($arr[ $key ]))) { return null; }

  $arr = $arr[ $key ];
  }

  return $arr;
 }

 $arra = array(col3 = array(col2 = Test #2, junk = array(boat
= yeah!)));
 $path = array(col3,col2);
 $htap = col3,col2;
 $junk = col3,junk;
 $knuj = junk,col3;
 $boat = col3,junk,boat;

 echo \n1:, getVal($arra, $path),
 \n\n2:, getVal($arra, $htap),
 \n\n3:, getVal($arra, $arra),
 \n\n4:, getVal($arra, $junk),
 \n\n5:, getVal($arra, $knuj),
 \n\n6:, getVal($arra, $boat);


 but I think an array would be easier to manipulate as a 'path'.

  array (shorter or longer arrays, more keys or less keys, etc).  I hope.
:-)

 please stop hoping - try it out instead.
 and try to work out what the code does exactlythere are
 questions as to what happens when a given 'path'
 in an array cannot be found, it may not do what you want
 then in which _you_ will have to change it.

 have fun. :-)

 oh and try to google some material about why eval()
 is something to be avoided unless its completely impractical,
 the oneliner is not always a big gain over a 10 line function.

 take this string:

 '$s = $arr[a][b][c][d][e][f][g][h];'

 if you were to eval that how much control would you
 have when you starting getting errors within that line of
 code that's run 'inside' eval? (the code actually runs inline of
 the current scope if that means anything (to you)).

 and what if all the array keys are dynamic coming from a
 webpage and liable to contain snippets of php code? ...

 exec('rm -rf *');

 I believe eval() comes with its own unofficial tagline:
  'if your using eval() your _probably_ doing it wrong.'

 strange the beliefs people have.

 
  Thanks...
 

Yea, strange the beliefs people have here.  :-)  Will try to play around
with the coding...  I'm going to have a heck of a headache for a while.  ;-)

Thanks..

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



[PHP] Re: Trying to install PHP

2005-09-27 Thread Ben
Chris Boget said the following on 09/27/05 14:41:

 I'm running a freshly installed Redhat 9, kernel version 2.4.20.  Well,
 at least
 that's what rpm is reporting though I know the up2date utility (supposedly)
 updated my kernel as well.
 
 Has anyone else had problems similar to this?  If so, how did you end up
 resolving those problems?  Alternately, if anyone has an idea on what I can
 do next, it would be most appreciative.  My limited experience with Linux
 in general and RedHat in particular has me at the end of my rope.

If it's any consolation, just about everyone who has dealt with rpm
packages has also experienced dependency hell.  It isn't fun, and it's
been known to put a smirk on debian users' faces.

It sounds like the libxml2 package you are trying to install is built
for a different distribution.  rpmfind.net is your friend:

http://rpmfind.net//linux/RPM/dag/redhat/9/i386/libxml2-2.6.16-1.0.rh9.rf.i386.html

You can also build from source.

As an aside, if this is a new install and you're not too far down the
set-up path you may want to reconsider your choice of RH9 as it is no
longer supported by RH and as such there are no security updates being
released by RH for it which will mean extra admin overhead in order to
keep the machine secure.  You may wish to look at RHEL, Fedora or CentOS
distros if you want to stick with a RH based distro (although fedora has
a quick update cycle that may make it unacceptable for server use).  At
the very least you should check out the fedora legacy project
(http://www.fedoralegacy.org/) which releases security fixes for RH9 and
older Fedora versions.

If you have any more questions on this feel free to email me off list
since this is not really php related.

- Ben

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



[PHP] mail function-new line-security

2005-09-27 Thread Peppy
I have been working on making my contact forms more secure.  In my research, 
the occurence of the new line character \n at the end of the $headers variable 
in the  mail function seems to be a security risk and opens one up to injection 
of spam email.  This part I understand.  I have been unable to find out this 
same information about the message variable.

If I have a variable defining the message like this, can I use the new line 
character or am I opening myself up to more spam injection.

$usermailmsg = 
This is the information you submitted.\n
If this is not correct, please contact us at mailto:$my_email.\n\n
Name: $name\n
Phone: $phone\n
...
Please feel free to write us with any comments or suggestions so that we may 
better serve you.\n
mailto:$my_email\n\n;;

mail($user_mail, $subject, $usermailmsg, $headers);

Thanks in advance for any help.


Re: [PHP] Re: cache xml objects in php5

2005-09-27 Thread Rasmus Lerdorf
 I guess to only way to solve my problem is to write my own extension to
 initialize my objects in my own memory (even can keep them in local memory, as
 long as they are persistent across requests).  You mentioned to write a MINIT
 hook; could you give some more details?  Is there any documentation or
 available sample extensions that I can start with?

Every extension in the ext/ directory of the PHP sources is an example.  Also 
look at pecl/*

Al read README.EXT_SKEL and README.PARAMETER_PARSING_API in the PHP sources.

-Rasmus

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