Re: [PHP] Update db with $_POST

2005-03-16 Thread Danny Brow
On Wed, 2005-03-16 at 16:50 +1000, Ligaya Turmelle wrote:
 assuming you are using PEAR DB -
 
 $result = $db-query(UPDATE items SET (item_name, item_desc, 
 item_price, extraprice) VALUES (?,?,?,?) WHERE item_id = 3, 
 array($_POST['title'], $_POST['description'], $_POST['price'],
   $_POST['extraprice']));
 if (PEAR::isError($result))
 { 
   echo Error: There was an error with the query.  Message returned: ;
   die($result-getMessage().'  '.$db-getUserInfo().' '));
 }


Thanks I got it worked out though, I'm going to try this also to see
what happens, I'm trying to learn the best I can and when things break
and you fix em you learn a lot more.  Thanks again.

PS this is what I did:

$db-query('UPDATE items SET item_name=?, item_desc=?, item_price=?,
extraprice=? WHERE item_id = 3',
array($_POST['title'], $_POST['description'],
$_POST['price'], $_POST['extraprice']));

I've already posted this to the list, but it may not be there yet.

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



[PHP] Re: Log out button

2005-03-16 Thread M. Sokolewicz
William Stokes wrote:
Hello,
Again this might be more of a HTML quetion. If so sorry about that.
Anyway I was just trying to make a log out button to a page. It should end a 
session or/and close browser window. (Closing browser ends the session as 
well I think?
no
)
All variable values are deleted when browser is closed. Right?
no
Can anyone help?
Thanks
-Will 
Make a button. In the submitted form, get the session-id, destroy the 
data, and remove the cookie. The output some JS to close the window.
see http://www.php.net/session_destroy for more info

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


[PHP] Object Destruction in PHP5

2005-03-16 Thread Arjun Jain
Hi everyone,
When is the object destroyed which is created in a PHP5 script?
Suppose i say:
?php
$m = new MyClass;
$m-fun1('abcd');
$m-fun2();
?
Then why is the destructor not called when my script ends? Can it be
called explicitly? If yes, how?
Thanking you in advance,
Regards
aj
--
-
Arjun Jain, 7th Sem CSE, RVCE
http://arjun.notlong.com
Visit http://groups.yahoo.com/group/rvcelug/ 
http://groups.yahoo.com/group/rvcelug/
-

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


[PHP] Re: is_a() against instanceof

2005-03-16 Thread Jason Barnett
Christian Stadler wrote:
 Eli schrieb:

- ($cls instanceof ClassName)  *requires* from ClassName to be declared,
and generates a fatal error when ClassName is not declared.

 How about
 if (class_exists('ClassName') AND $cls instanceof ClassName)
 {
...
 }

 Regards,
   Christian Stadler

Nice suggestion!  But I wonder... would it perhaps be better to use the
 operator instead of the AND operator?  That way in case you are
trying to do an assignment PHP won't bother to check instanceof if the
class_exists() fails.

if (class_exists($class)  $cls instanceof $class)
{

}


--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] Reading posted form variables

2005-03-16 Thread Jochem Maas
Simon Allison wrote:
Hey,

 

Obviously this has something to do with the quotation marks in the a href
statement, however I am new to php and my attempts using addslashes and
stripslashes have failed. I would be most grateful if anyone could help me. 

addslashes() and stripslashes() won't help completely (although you may 
still need to
escape quotes - depending on the way you call the following funcs...)
- take a look at htmlentities() and htmlspecialchars(), basically you need to 
encode
you 'msg' so that any HTML contained in the message is not rendered by the 
browser.
 

Cheers,
Simon
 


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


[PHP] Re: Ad software

2005-03-16 Thread pete M
check www.hotscripts.com
Ryan A wrote:
Hey,
I am looking for a software that just lists adverts...
eg:
Like ebay but without the bidding
Requirements are simple, so simple that i am sure something like this exists
and i dont have to write it myself:
0.They must register first then...
1.offer the person to put in his ad details, a few other details like his
telephone number, asking price etc
2.(optional) add a photo
3. They can delete their ad if they want to later
4.normal visitors can search or browse by category or latest additions etc
I can give you an example in the form of a swedish site:
http://www.blocket.se
I have found something very close in ASP but i dont trust MS products and
would rather it be in PHP as i can tinker with it (i dont know ASP and my
server does not support it)
As you can see, it wouldnt take too long to build but i have little time so
i would rather finish my lingering old projects than start on something
new from scratchits for a pet site where people can sell (or
barter/exchange) aquarium fish, fish food, aquariums, filters, stands etc
Checking google and hot scripts just sends me to ad management software like
banner rotators and bidding systems etc.
Any help appreciated and thanks in advance.
-Ryan

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


Re: [PHP] Auto logout

2005-03-16 Thread trlists
For the basic logout, it's very easy.

Store a session variable which is the last active time.  Initialize 
it to the current time when the user logs in.

Each time a page loads, start the session and check current time 
against the last active time.  If the difference is over the limit, 
display a message and/or go back to the login screen.  If it is not, 
reset the last active time to the current time.

This way you have a timer which is reset on every page load.  If no 
page is loaded for some given amount of time, the timer expires and 
you force a new login.

To update the logged in status in the database after a time-based 
logout, you need a way to know when the user has *not* done something, 
and that by definition is not going to come from the user themselves.  
So you have to use a cron job which resets the database flag, there's 
no way around it.  You could store the last active time described 
above in the database in addition to or instead of in the session data 
to facilitate this.

--
Tom

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



RE: [PHP] Question about shortening a string

2005-03-16 Thread Kim Madsen

-Original Message-
From: Steve Slater [mailto:[EMAIL PROTECTED] 
Sent: Saturday, March 12, 2005 5:29 PM

$name_array = explode( ,$name);
$short_name = $name_array[0]  . end($name_array);

 And a dozen other ways to do it I'm sure. I just finished a
 project with a mess of pattern matching so have regex on the brain. :-)

Hehe, I know the feeling

Ereg solution:

eregi(^([a-z] ).* ?([a-z])$, $name, $regs);
print the name in short is $regs[1] $regs[2];

But when dealing with names I think Your approach is better since there´s all 
kinds of chararcters from language to language, in Denmark ÆæØøÅå, in sweden 
äÄöÖ and so on. Of course I could do something like:
ereg(^(.+ ).* ?(.+)$, $name, $regs); // untested

-- 
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen 
Systemudvikler
Naverland 31

DK-2600 Glostrup
www.comx.dk 
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]

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



[PHP] Strange PHP5 message

2005-03-16 Thread aka MacGuru
Hi,
I have PHP 5.03 running on SuSE 9.2. Some code working fine in PHP 4.3x 
now throws a message:

Notice: serialize() [function.serialize]: __sleep should return an 
array only containing the names of instance-variables to serialize. in 
ANVphpApp.php on line 840

Anyone knows what is the problem?
Thanks in advance for any suggestion(s).
*
*   Best Regards   ---   Andrei Verovski
*
*   Personal Home Page
*   http://snow.prohosting.com/guru4mac/
*   Mac, Linux, DTP, Development, IT WEB Site
*


RE: [PHP] php 4 php 5

2005-03-16 Thread Kim Madsen

-Original Message-
From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 15, 2005 4:05 AM

  That's why I'd like to stick with apache2 + php5 default and
  apache2+php4 just for a single site hosted (the one that uses imp).

 See my previous message describing the ProxyPass approach.  It is by far 
 the easiest way to solve this cleanly.

I´ve only been on the list for a couple of weeks, so sorry if it´s already been 
answered but couldn´t one use 2 AddTypes?

LoadModule php4_module libexec/libphp4.so
AddType application/x-httpd-php .php4

LoadModule php5_module libexec/libphp5.so
AddType application/x-httpd-php5 .php .php5

AddModule mod_php4.c
AddModule mod_php5.c

I believe that´s how we did it while testing 3 vs 4 at one of my previous jobs 
(the ISP World Online/Tiscali), worked for hosted customers aswell.

-- 
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen 
Systemudvikler
Naverland 31

DK-2600 Glostrup
www.comx.dk 
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]

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



[PHP] How to access any function of a any class?

2005-03-16 Thread pf
Hello.
Please consider this:

class A {

   function A($Cont){
  $this-Container= $Cont;
   }

   function A_1(){
  $this-Container-objB-B_1(somehing);
   }
}
class B {

   function B($Cont){
  $this-Container= $Cont;
   }

   function B_1(){
  //anything
   }
}

class Container{

function Container(){
   $this-objA=new A($this);
   $this-objB=new B($this);
}
}

$MyOBJ=new Container();


The problem is that sometimes member functions and variables can be
reached this way, but sometimes not (mainly variables or file pointers)
depending WHEN you create the object and when (for example) you create a
file pointer inside some class.

What I want to do is to be able to use any function of any class from any
function of any class.

Any ideas are welcome.

Thanks a lot in advance!

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



[PHP] date() function help

2005-03-16 Thread John Eggen
I am writing an application to allow users to enter weekly data and am
storing the data based on the year and the ISO week number.  The data
will be reported on a monthly basis and therefore I need a way to find
the ISO week number for the first full week of the month
(Monday-Sunday) and the ISO week number for the last week (starting on
the last Sunday of the month).  Does anyone have a suggestion?

Thanks!
-- 
John Eggen [EMAIL PROTECTED]

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



[PHP] Log out button

2005-03-16 Thread William Stokes
Hello,
Again this might be more of a HTML quetion. If so sorry about that.

Anyway I was just trying to make a log out button to a page. It should end a 
session or/and close browser window. (Closing browser ends the session as 
well I think?)

All variable values are deleted when browser is closed. Right?

Can anyone help?

Thanks
-Will 

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



[PHP] MIME Types

2005-03-16 Thread Mikey
Sunny mornings to you all!
 
Does anyone on this NG know off of the top of their heads what the correct
MIME type is for a CSV file?
 
The closest I have found on my google is the application/msexcel type, but
this spawns Excel when viewing the file, and I do not want this behaviour.
 
TIA,
 
Mikey

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



[PHP] RE: MIME Types [fixed]

2005-03-16 Thread Mikey
 The closest I have found on my google is the 
 application/msexcel type, but this spawns Excel when 
 viewing the file, and I do not want this behaviour.

Not sure what is happening with the list this morning, but it is eerily
quiet!

Anyway, a little bit of tinkering and I found that the answer was stupidly
simple.  The correct header to send is text/plain - doh!

Regards,

Mikey

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



[PHP] XPath Query Exressions and Quote Characters

2005-03-16 Thread C Drozdowski
I've got a problem with quote characters and building XPath query 
expressions (PHP 5.0.3). What do I need to do to get them to work? I've 
tried various encoding functions but cannot figure it out.

Given this expression, if $id contains one or more double quotes, an 
error is thrown.

$query = '//book/chapter' . '[EMAIL PROTECTED]:id=' . $id . ']';
Given this expression, if $id contains one or more single quotes, an 
error is thrown.

$query = //book/[EMAIL PROTECTED]:id='$id'];
I need to be able to build an exression that contains either double or 
single quotes in the search regarding of how I programatically build 
the expression.

Any insight would be appreciated.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] MIME Types

2005-03-16 Thread Chris Ramsay
On Wed, 16 Mar 2005 11:01:29 -, Mikey [EMAIL PROTECTED] wrote:
 Sunny mornings to you all!
 
 Does anyone on this NG know off of the top of their heads what the correct
 MIME type is for a CSV file?

What I've always used is:
Content-type: application/octet-stream

 
 The closest I have found on my google is the application/msexcel type, but
 this spawns Excel when viewing the file, and I do not want this behaviour.

This may be down to the end user's system - may not be much you can do about it.

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

chris

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



[PHP] Re: Log out button

2005-03-16 Thread Jason Barnett
M. Sokolewicz wrote:
 William Stokes wrote:

 Hello,
 Again this might be more of a HTML quetion. If so sorry about that.

 Anyway I was just trying to make a log out button to a page. It should
 end a session or/and close browser window. (Closing browser ends the
 session as well I think?

 no

Well... depends on whether you are using the so-called session cookie.
 I.e. if your cookies have a lifetime of 0, then they *should* be
destroyed when the browser is closed.

http://php.net/manual/en/ref.session.php#ini.session.cookie-lifetime

...
 Make a button. In the submitted form, get the session-id, destroy the
 data, and remove the cookie. The output some JS to close the window.
 see http://www.php.net/session_destroy for more info

Agreed!  Heck, you even close the browser with some JS... how well does
that work?  (I'm curious whether pop-up blockers / mozilla / etc. would
stop JS from doing that)

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] Object Destruction in PHP5

2005-03-16 Thread Jochem Maas
Arjun Jain wrote:
Hi everyone,
When is the object destroyed which is created in a PHP5 script?
Suppose i say:
?php
$m = new MyClass;
$m-fun1('abcd');
$m-fun2();
unset($m); // this fires $m-__destruct() if it exists.
?
Then why is the destructor not called when my script ends? Can it be
it is called - but it won't output anything because by the time its called
there is nothing for php to output to (think of a shutdown procedure)
need to know more, search the list - it was covered in more depth within the
last 7 days.
called explicitly? If yes, how?
Thanking you in advance,
Regards
aj
--
-
Arjun Jain, 7th Sem CSE, RVCE
http://arjun.notlong.com
Visit http://groups.yahoo.com/group/rvcelug/ 
http://groups.yahoo.com/group/rvcelug/
-

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


[PHP] Ensure only one instance of a script is running

2005-03-16 Thread Shaun
Hi,

I have a script that inserts data from files uploaded to our server. I need 
to make sure that only one instance of this script runs at anyone time, can 
anyone tell me how I can do this?

Many thanks 

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



RE: [PHP] Ensure only one instance of a script is running

2005-03-16 Thread Jay Blanchard
[snip]
I have a script that inserts data from files uploaded to our server. I
need 
to make sure that only one instance of this script runs at anyone time,
can 
anyone tell me how I can do this?
[/snip]

Don't run another instance. ba-dump ching!

Ok, here is a quick and dirty way to do it, have the script check for
the existence of a file containing a date and timestamp, if one does not
exist the script creates one. If it does exist, the script exits. Once
the script is nearing completion have it destroy the file (unlink).

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



Re: [PHP] OT - C programming

2005-03-16 Thread Brian
To understand the *'s just google for c pointer tutorial, you're
likely to find alot of helpful material.


On Tue, 15 Mar 2005 11:37:26 -0500, Jason Barnett
[EMAIL PROTECTED] wrote:
 Rasmus Lerdorf wrote:
  Jason Barnett wrote:
 
  Jay Blanchard wrote:
 ...
  In the end you are probably much better off learning a bit of C or C++
  and writing your own PHP extensions than hoping that someone will make a
  compiler that will magically speed everything up.  PHP was designed
  specifically with this in mind.  The idea is to keep things that don't
 ...
  better performance than any PHP Compiler ever will.  And it really
  isn't that hard to write a PHP extension.
 
  -Rasmus
 
 I actually looked into building my own extension before.  I saw some of
 the docs from the talks.php.net site and most of it made sense to me.
 So I agree that the PHP - extensions interface is simple enough for a
 poor slob like myself to understand.
 
 Can you (or anyone else for that matter) give me a book recommendation
 that explains C coding to someone with intermediate PHP skills?
 
 I already have George Schlossnagle's book and it's great (it taught me a
 lot of what I know about the source), but it assumes a level of
 proficiency in C that I just don't have.
 
 I know that you have to allocate memory for variables, you have strict
 types (although I'm vaguely familiar with a zval), but some things like
 all of those **'s I see in the source code just don't make sense to me.
   Recommendations, anyone?
 
 --
 Teach a man to fish...
 
 NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
 STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
 STFM | http://php.net/manual/en/index.php
 STFW | http://www.google.com/search?q=php
 LAZY |
 http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins
 
 


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



[PHP] Re: Strange PHP5 message

2005-03-16 Thread Jason Barnett
Andrei Verovski wrote:
...
 Notice: serialize() [function.serialize]: __sleep should return an array
 only containing the names of instance-variables to serialize. in
 ANVphpApp.php on line 840


 Anyone knows what is the problem?

Exactly what the notice says ;) basically __sleep is used so that you
can prevent certain properties (file pointers, db connections, objects,
etc.) from being serialized.

?php

session_start();
error_reporting(E_ALL);

class Dummy {
  public$s1  = 'I am a test string';
  protected $s2  = 'I am the protected string';
  private   $_s3 = 'I am the private string';
  var   $a1  = array('testing', 1, 2, 3);
  static$i1  = 0;

  function __sleep() {
$i = self::$i1++;
echo Oops, I forgot everything!  $i\n;
return array();
  }
}

class hasMemory extends Dummy {

  private $_fp = NULL;

  function __construct() {
$this-_fp = fopen('/path/to/some/file', 'r');
  }

  function __sleep() {
$props_to_save = array('s1', 's2', 'a1');
echo I know about the following properties:\n;
print_r($props_to_save);
return $props_to_save;
  }
}

$_SESSION['obj1']= new Dummy();
$_SESSION['obj2']= new hasMemory();
$_SESSION['string']  = '123abcdefg!';
$_SESSION['integer'] = 1;
$_SESSION['float']   = .1234;
$_SESSION['double']  = .1234567890123456;
$_SESSION['bool']= TRUE;

foreach ($_SESSION as $key = $value) {
  echo $key: ;
  var_dump(serialize($value));
}

?

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] warning question about mysql sessions concurrency

2005-03-16 Thread Marek Kilimajer
Josh Whiting wrote:
I've been trying to switch to MySQL-based session storage instead of the 
native PHP session storage.  In doing so, I've run into a lot of code on 
the web that exhibits a serious flaw regarding concurrent requests from 
the same client. All the code I've seen has glossed over the need to 
lock the session for the duration of the request, e.g. not allow 
concurrent requests to use it until it has finished.  PHP's native 
session handler correctly does this, but lots of MySQL-driven session 
code does not.

Example timeline:
1. client sends a request
2. session data is loaded from the db 
3. same client sends a request before the first one is finished (e.g. 
frames, tabbed browsing, slow server response times, etc)
4. session data is again loaded from the db
5. the first request changes some values in $_SESSION
6. the second request changes some values in $_SESSION
7. the first request writes the data to the db and exits
8. the second request writes it's data (over that written by the first 
request) and exits

PHP's native handler solves this problem by forcing concurrent requests
to wait for each other. The same thing needs to happen in a
database-driven session handler.
SO, does anyone have some code that uses MySQL to replace PHP's native
session storage that also correctly handles this concurrency problem? 
Ideally I'd like to see just a set of functions that can be used with 
sessions_set_save_handler() to transparently shift PHP's sessions to a 
database, but I'm not going to use the stuff I've found on the web or 
even in books (appendix D of O'Reilly's Web Database Applications with 
PHP  MySQL publishes code with this problem).

Folks using database sessions who do not deal with this scenario be
warned! I'm surprised so much bad code is going around for this task...
MySQL's InnoDB supports row-level locking. So row the right row in 
session_start and release it in session_close function.

In MyISAM you can use application-level locking: GET_LOCK() and 
RELEASE_LOCK() in session_start and session_close, respectively. 
Parameter would be session id with some prefix.

The problem is when you need to create session id - you must lock the 
whole table to find unused session id and insert it into table.

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


RE: [PHP] Ensure only one instance of a script is running

2005-03-16 Thread Robert Cummings
On Wed, 2005-03-16 at 11:12, Jay Blanchard wrote:
 [snip]
 I have a script that inserts data from files uploaded to our server. I
 need 
 to make sure that only one instance of this script runs at anyone time,
 can 
 anyone tell me how I can do this?
 [/snip]
 
 Don't run another instance. ba-dump ching!
 
 Ok, here is a quick and dirty way to do it, have the script check for
 the existence of a file containing a date and timestamp, if one does not
 exist the script creates one. If it does exist, the script exits. Once
 the script is nearing completion have it destroy the file (unlink).

Here's a simple script which uses directories for locking which is
superior to the above example that doesn't cater to race conditions. It
uses directory creation since directory creation is supposedly atomic on
a non NFS filesystem.

?
function lockCreate( $name )
{
$myPath = ereg_replace( '/[^/]+$', '/', __FILE__ );
$lockPath = $myPath.$name.'.lock';
$status = @mkdir( $lockPath );

return $status;
}

function lockDestroy( $name )
{
$myPath = ereg_replace( '/[^/]+$', '/', __FILE__ );
$lockPath = $myPath.$name.'.lock';

$status = @rmdir( $lockPath );

return $status;
}

if( !lockCreate( $lockName ) )
{
//
// Script already running.
//
exit();
}

//
// Do stuff here then afterwards remove the lock.
//

lockDestroy( $lockName );
?

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

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



[PHP] Re: XPath Query Exressions and Quote Characters

2005-03-16 Thread Jason Barnett
C Drozdowski wrote:
...
 $query = '//book/chapter' . '[EMAIL PROTECTED]:id=' . $id . ']';

First of all check the XPath documentation:

http://www.w3.org/TR/xpath
http://www.w3.org/TR/xpath#path-abbrev

AFAIK your expression above is the way to build this query.  Give us a
link to the XML doc if you want us to take a look at that specific doc.
 Also make sure you referenced the correct DTD.  And (just to be sure)
try to validate you document against the DTD.


 Given this expression, if $id contains one or more single quotes, an
 error is thrown.

 $query = //book/[EMAIL PROTECTED]:id='$id'];

 I need to be able to build an exression that contains either double or
 single quotes in the search regarding of how I programatically build the
 expression.


A couple of things that may be in play here...

- First of all I recall there was a specific bug with xml:id, although I
can't recall off the top of my head what it was...
- Secondly the XPath querying interface in PHP will only return simple
data at this point.  In fact, I think it will only return strings.

http://www.w3.org/TR/xpath#attribute-nodes

But if your ID is simple data (integer / string), I can't imagine it
would be a problem for XPath to return it.

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


[PHP] Encrypted 2.5+M files do upload, but don't create a record when stored as LongBlobs (PHP/Apache/MySQL)

2005-03-16 Thread Steven Altsman
Files under 2.5 megs will go into the database just fine, any thing over
that will return the page without errors, but will not be injected into the
database.  Not even a record is created.

Edited PHP.INI to allow up to 40M of data to be uploaded.  Set the script
timeout to be 9000 seconds.  Set the script operational memory to 80M.  I
did a print_r of $_FILES and the results show that there is a file in the
tmp directory, but I'm not sure after that if there is a problem with mcrypt
or MySQL.  I did read something about a limitation of MySQL and max packet
size between server and client, but only 4.1 or less is mentioned with that.
I also switched from the fopen/fread combo and did file_get_contents
instead, as it was recommended to be more efficient.

http://us4.php.net/fopen
http://us4.php.net/fread
http://us4.php.net/file_get_contents
http://us3.php.net/mcrypt
http://us3.php.net/features.file-upload
http://us3.php.net/print_r

http://www.ispirer.com/doc/sqlways38/Output/SQLWays-1-195.html
http://www.totalchoicehosting.com/forums/lofiversion/index.php/t10276.html
http://www.chipmunk-scripts.com/board/index.php?forumID=27ID=1674
http://scripts.franciscocharrua.com/database-file-upload-download.php
http://www.hotscripts.com/Detailed/33694.html

http://www.google.com

If there is any other links to M's that I haven't R'ed, please let me know.
Otherwise I'm clueless.  Google gives me a metric tonne of information, but
it is mostly people asking the same question I am with recommendations on
editing the PHP.INI.  Obviously this is a useful script that many people
have written in their own way for their own needs, and I'm sure they've run
into the same problem I'm encountering now.

Using MySQL 5.0.2, PHP 5, newest mcrypt, mhash, Apache 2, FC 3, it is on
port 443 with a valid SSL cert, and if you need to know any other version or
variable info I will gladly provide it.


-=-=-=-=-=-=- /docs/phpinfo.php -=-=-=-=-=-

allow_call_time_pass_reference On On 
allow_url_fopen On On 
always_populate_raw_post_data Off Off 
arg_separator.input   
arg_separator.output   
asp_tags Off Off 
auto_append_file no value no value 
auto_globals_jit On On 
auto_prepend_file no value no value 
browscap no value no value 
default_charset no value no value 
default_mimetype text/html text/html 
define_syslog_variables Off Off 
disable_classes no value no value 
disable_functions no value no value 
display_errors On On 
display_startup_errors Off Off 
doc_root no value no value 
docref_ext no value no value 
docref_root no value no value 
enable_dl On On 
error_append_string no value no value 
error_log no value no value 
error_prepend_string no value no value 
error_reporting 2039 2039 
expose_php On On 
extension_dir ./ ./ 
file_uploads On On 
8 - 8 - 8
html_errors On On 
ignore_repeated_errors Off Off 
ignore_repeated_source Off Off 
ignore_user_abort Off Off 
implicit_flush Off Off 
include_path .:/usr/local/php//lib/php .:/usr/local/php//lib/php 
log_errors On On 
log_errors_max_len 1024 1024 
magic_quotes_gpc On On 
magic_quotes_runtime Off Off 
magic_quotes_sybase Off Off 
mail.force_extra_parameters no value no value 
max_execution_time 9000 9000 
max_input_time 9000 9000 
open_basedir no value no value 
output_buffering no value no value 
output_handler no value no value 
post_max_size 40M 40M 
precision 12 12 
register_argc_argv On On 
register_globals Off Off 
register_long_arrays On On 
report_memleaks On On 
report_zend_debug On On 
safe_mode Off Off 
safe_mode_exec_dir no value no value 
safe_mode_gid Off Off 
safe_mode_include_dir no value no value 
8 - 8 - 8
serialize_precision 100 100 
short_open_tag On On 
SMTP localhost localhost 
smtp_port 25 25 
sql.safe_mode Off Off 
track_errors Off Off 
unserialize_callback_func no value no value 
upload_max_filesize 40M 40M 
upload_tmp_dir no value no value 
user_dir no value no value 
variables_order EGPCS EGPCS

-=-=-=-=-=-=-=- My Script -=-=-=-=-=-=-=-=-

foreach($_FILES['binFile']['name'] as $k = $v)

{
// Variable-ize all of the attributes of the file object
$binFile[$k] = $_FILES['binFile'][$k];
$binFile_name[$k] = $_FILES['binFile']['name'][$k];
$binFile_size[$k] = $_FILES['binFile']['size'][$k];
$binFile_type[$k] = $_FILES['binFile']['type'][$k];
$binFile_tmp[$k] = $_FILES['binFile']['tmp_name'][$k];
// Get sender information
$author = $_SESSION['tehNam'];
$recipient = strtolower($_POST['email']);
// Tracking information on the file
$date_submitted[$k] = date('Y-m-d H:i:s');
$txtDescription[$k] = $_POST['txtDescription'][$k];
$binFile_unique[$k] =
md5($author.$txtDescription[$k].$binFile_name[$k]);
}

foreach($_FILES['binFile']['name'] as $k = $v)
{
// Generate hash for user-logn
$access_name = md5(strtolower($_POST['email']));

  

Re: [PHP] How to access any function of a any class?

2005-03-16 Thread pf
 [EMAIL PROTECTED] wrote:
 Hello.
 Please consider this:

 class A {

function A($Cont){

 you obviously didn't RTFM about php5's new features, migration issues
 etc.

 why do I say that? well it because you are using a ''
 each time you assign an object. thats not how its done in
 php5 - hint: php5 has real objects, an object is always a
 reference, you can assign an object to a hunderd vars and they will
 all point to the same object - if you need to copy
 an object use 'clone'.

Cool feature, but I've not tried php5 yet, I'm been lazy the last couple
of months. So the example is for php4 I thought it was obvious because of
the constructor name.


   $this-Container= $Cont;
}

function A_1(){
   $this-Container-objB-B_1(somehing);
}
 }
 class B {

function B($Cont){
   $this-Container= $Cont;
}

function B_1(){
   //anything
}
 }

 class Container{

 function Container(){
$this-objA=new A($this);

^--- I'm surprised that this even parses.

$this-objB=new B($this);
 }
 }

 $MyOBJ=new Container();


 The problem is that sometimes member functions and variables can be
 reached this way, but sometimes not (mainly variables or file pointers)
 depending WHEN you create the object and when (for example) you create a
 file pointer inside some class.

 What I want to do is to be able to use any function of any class from
 any
 function of any class.

 try the function pattern - basically you just use functions and then you
 don't
 have to worry about class scope etc; the ability for everyone of your
 functions to
 call everyone of your functions is built into php.

thanks for the advice, but I like to program using classes, besides the
class scope helps with names conflicts.


 i.e. it _sounds_ like a bad idea. the idea behind objects is making things
 more
 managable not creating hyper-spaghetti.


you're right, but if you dont want to keep extending classes or you have a
project where classes heavily interact with each other, you will end up 
accesing other objects function/vars many of wich where created after you
asigned the container reference to the calling object.

Thanks a lot for your answer.


 Any ideas are welcome.

 Thanks a lot in advance!




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



Re: [PHP] OT - C programming

2005-03-16 Thread Philip Olson

For a nice introduction to extension writing, read this
article:

  Part I: Introduction to PHP and Zend
  http://zend.com/php/internals/extension-writing1.php

As well as the various README files found within the php
source files:

  http://cvs.php.net/php-src/

And let's not forget about PECL_Gen. Although it requires
PHP 5 to run, it also allows one to quickly create
extensions that work in both PHP 4/5. There is also ext_skel
but it's slowly being replaced by PECL_Gen:

  http://pecl.php.net/package/PECL_Gen

And of course the Zend API docs:

  http://php.net/manual/en/zend.php

The Zend article above will be a five part series, which is 
pretty cool :)

Regards,
Philip

On Tue, 15 Mar 2005, Brian wrote:

 To understand the *'s just google for c pointer tutorial, you're
 likely to find alot of helpful material.
 
 
 On Tue, 15 Mar 2005 11:37:26 -0500, Jason Barnett
 [EMAIL PROTECTED] wrote:
  Rasmus Lerdorf wrote:
   Jason Barnett wrote:
  
   Jay Blanchard wrote:
  ...
   In the end you are probably much better off learning a bit of C or C++
   and writing your own PHP extensions than hoping that someone will make a
   compiler that will magically speed everything up.  PHP was designed
   specifically with this in mind.  The idea is to keep things that don't
  ...
   better performance than any PHP Compiler ever will.  And it really
   isn't that hard to write a PHP extension.
  
   -Rasmus
  
  I actually looked into building my own extension before.  I saw some of
  the docs from the talks.php.net site and most of it made sense to me.
  So I agree that the PHP - extensions interface is simple enough for a
  poor slob like myself to understand.
  
  Can you (or anyone else for that matter) give me a book recommendation
  that explains C coding to someone with intermediate PHP skills?
  
  I already have George Schlossnagle's book and it's great (it taught me a
  lot of what I know about the source), but it assumes a level of
  proficiency in C that I just don't have.
  
  I know that you have to allocate memory for variables, you have strict
  types (although I'm vaguely familiar with a zval), but some things like
  all of those **'s I see in the source code just don't make sense to me.
Recommendations, anyone?
  
  --
  Teach a man to fish...
  
  NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
  STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
  STFM | http://php.net/manual/en/index.php
  STFW | http://www.google.com/search?q=php
  LAZY |
  http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins
  
  
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



[PHP] Re: Ensure only one instance of a script is running

2005-03-16 Thread Raj Shekhar
Jay Blanchard [EMAIL PROTECTED] writes:

 [snip]
 I have a script that inserts data from files uploaded to our server. I
 need 
 to make sure that only one instance of this script runs at anyone time,
 can 
 anyone tell me how I can do this?
 [/snip]
 
 Don't run another instance. ba-dump ching!
 
 Ok, here is a quick and dirty way to do it, have the script check for
 the existence of a file containing a date and timestamp, if one does not
 exist the script creates one. If it does exist, the script exits. Once
 the script is nearing completion have it destroy the file (unlink).


Unluckily, this will not prevent a race condition.  The only file
operations that are guaranteed to be atomic are mkdir() and
symlink(). Try to create the directory and see if it fails.  Also
remember to rmdir() the lock directory before exiting

-- 
Raj Shekhar  Y!   : Operations Engineer
MySQL DBA, programmer and  slacker   Y!IM : lunatech3007
home : http://rajshekhar.net blog : http://rajshekhar.net/blog/

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



RE: [PHP] Re: Ensure only one instance of a script is running

2005-03-16 Thread Mikey
[snip]
 Unluckily, this will not prevent a race condition.  The only 
 file operations that are guaranteed to be atomic are mkdir() 
 and symlink(). Try to create the directory and see if it 
 fails.  Also remember to rmdir() the lock directory before exiting

How about grabbing the output from `ps -ax` and looping thourhgthe results
to see if your script is being run?

HTH,

Mikey

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



[PHP] [SOLVED] Re: [PHP] OT - C programming

2005-03-16 Thread Jason Barnett
Philip Olson wrote:
 For a nice introduction to extension writing, read this
 article:

   Part I: Introduction to PHP and Zend
   http://zend.com/php/internals/extension-writing1.php

Bookmarked for future reference.  Looking forward to the next several
parts in this series...


 As well as the various README files found within the php
 source files:

   http://cvs.php.net/php-src/

I've browsed the source several times, but I had not looked at these
files before.  I recall reading one README?  Clearly I need to do more
digging there... thanks again!


 And let's not forget about PECL_Gen. Although it requires
 PHP 5 to run, it also allows one to quickly create
 extensions that work in both PHP 4/5. There is also ext_skel
 but it's slowly being replaced by PECL_Gen:

   http://pecl.php.net/package/PECL_Gen

That's good to know.  I've been developing in 5 for a while so that's no
issue.  I was aware of ext_skel and that was usually the reference that
I had heard before.  gets_out_note_padYet another tool that I need to
check out/gets_out_not_pad


 And of course the Zend API docs:

   http://php.net/manual/en/zend.php

Seen that a time or two before, but I went ahead and bookmarked it as well.


 The Zend article above will be a five part series, which is
 pretty cool :)

 Regards,
 Philip

 On Tue, 15 Mar 2005, Brian wrote:


To understand the *'s just google for c pointer tutorial, you're
likely to find alot of helpful material.

For others in the same boat as me, I am currently reading the tutorial
from the following link:

http://pw1.netcom.com/~tjensen/ptr/pointers.htm

So far so good... if you are like me and don't understand all of those
*ptr's all over the place.  I also received an email from someone
(off-list) that suggested I read the book C Programming Language (2nd
Edition).  You can get it over at Amazon:

http://www.amazon.com/exec/obidos/tg/detail/-/0131103628/qid=000153/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/104-6998313-1583146?v=glances=booksn=507846

Thanks for all of your suggestions!


signature.asc
Description: OpenPGP digital signature


[PHP] Re: Ensure only one instance of a script is running

2005-03-16 Thread Raj Shekhar
Mikey [EMAIL PROTECTED] writes:

 
 How about grabbing the output from `ps -ax` and looping thourhgthe results
 to see if your script is being run?

Again the problem is of atomicity.  This is a multi step process 

- do a ps -aux
- do a grep on the output
- start script processing

What if second script between step 1 and 2 ?  That is why we need
something that is guaranteed to complete in 1 step. 

-- 
Raj Shekhar  Y!   : Operations Engineer
MySQL DBA, programmer and  slacker   Y!IM : lunatech3007
home : http://rajshekhar.net blog : http://rajshekhar.net/blog/

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



[PHP] session.use_trans_sid Question

2005-03-16 Thread Al
What are the pros and cons of session.use_trans_sid ON and OFF
Just moved our site from one which had the php.ini, session.use_trans_sid=OFF to 
one with it ON

Sure looks ugly having the PHPSESSID showing up for visitors.
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] opt-in mail list best practice

2005-03-16 Thread Todd Trent
I’ve created an email script that retrieves email addresses from a mysql
database. Currently I’m grabbing the email addresses and putting them in the
mail header’s Cc: or Bcc: section in comma delimited format. I do have
sendmail on the current server so I’m using the mail function to send the
email.

This works fine for a few test emails. What I would like to know is what is
considered best practice considering the following things:

- This could be hosted on shared hosting server.
- Opt-in list could be less than 100 or in the 1000’s.
- May need a way to track sending success.

I’ve been googling all day and have found mailing classes, libraries, and
scripts none of which seem to be documented very well or let me build my own
template for html mail. I understand there are going to be memory/shared
usage limits to my current method. Should I be looping through possibly 1000
’s of email addresses calling the mail function each time? Can someone
please enlighten me a little as to what is considered best practice here or
a least point me toward more definitive information on the subject?

Thanks,


Todd Trent

Hogfish Design
 2550 26th Street West
   Bradenton, FL 34205

 Tel: 941-749-0144
 www.hogfishdesign.com

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



[PHP] Re: PHP Classes

2005-03-16 Thread Jason Barnett
You know... we talked about this several times before.  Please search
the archives for the PHP list's answers.

Hint: STFA tutorial class object

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


[PHP] Re: Embed PHP

2005-03-16 Thread Jason Barnett
Patric Stout wrote:
 Currently I am trying to get embed PHP to work. A nice C-application
 that can handle PHP-scripts. I hope this is the right place to ask
 question about it...

This is a fine place to start.  Note: I personally don't really know the
answer to this question, but perhaps I can point you in the right direction.

More likely: let this question sit in php-general for a few days, but if
no one can help then try over at php-internals.

...
 zend_register_functions(NULL, add_func_array, CG(function_table),
 MODULE_PERSISTENT);

...
 I tried almost everything, and I am running out of ideas.. is this a
 bug, or is it not allowed to add functions on the fly to the same
 hash-table, or...

I know for a fact that it is *possible* to add functions on the fly.
You will probably find an answer that works (or refactor this function
itself) by searching PHP's source for create_function()

http://php.net/manual/en/function.create-function.php

...
 Oh, one more note: I am running 64-bit linux, maybe that has something
 to do with it..

It's possible.  64-bit hasn't been hammered as much as 32-bit.

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] file/array manipulation[RESOLVED]

2005-03-16 Thread Mignon Hunter
Got it - never mind

instead of 
$new_array = array($line_split[0] = $line_split[1] );

  it's

$new_array = array($line_split[0] , $line_split[1] );

But I'm still not sure how it works so well...



Ok I got this to work but I'm not sure how -- and am having trouble 
re-producing the data:

My script I have so far is:

$lines = file('test2.csv');
foreach ($lines as $line) {
$line_split = explode(,, $line);
if(!(empty($line_split[0]) ) ){
//echo I'm not empty;
$new_array = array(
$line_split[0] = $line_split[1]
); 
}   
print(pre);
print_r($new_array);
print(/pre);
//echo trtd . $new_array[0] . /tdtd . $new_array[1] 
. /td/tr;// this doesnt work  
}

Here's what the printed format spits out (abbreviated):

Array
(
[R] = ABC company
)
Array
(
[R] = ABC company
)
Array
(
[R] = ABC company
)
Array
(
[R] = ABC company
)
Array
(
[O] = XYZ company
)
Array
(
[O] = XYZ company
)
Array
(
[O] = XYZ company
)
Array
(
[O] = XYZ company
)

So - I'm getting the write letters assigned to write companys which is great. 
But my echo line:

echo trtd . $new_array[0] . /tdtd . $new_array[1] . /td/tr;// 
this doesnt work

Do I have several arrays or a multidim array?

Thanks for any guidance

 Richard Lynch [EMAIL PROTECTED] 03/15/05 10:39AM 

 Hello

 I'm trying to manipulate a text(.csv) file using php. I've read the file
 and can print each line,
  but I need to write where column A is missing

 ColumnAColumnB

 RABC company
   ABC company
   ABC company
   ABC company
 OXYZ company
XYZ company
XYZ company
XYZ company

 What I need to do is write a while loop (I think) to interate through the
 lines and populate ColumnA
 while ColumnB equals $var (ABC company, XYZ company), so that I end up
 with:

 ColumnAColumnB

 RABC company
 RABC company
 RABC company
 RABC company
 OXYZ company
 OXYZ company
 OXYZ company
 OXYZ company

 Is this possible. What I've got so far to print out the file:

 $lines = file('test2.csv');


$category = '';

 // Loop through our array, and show line and numbers too.
 foreach ($lines as $line_num = $line) {
   echo Line #b{$line_num}/b :  . $line . br /\n;

//Assuming it's the FIRST character of each line that has space or category:
//Check first character:
if ($line[0] != ' '  $line[0] != \t){
  $category = $line[0];
}

echo $category\t, trim(substr($line, 1)), br /\n;

 }


 Thanks in advance

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




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

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



[PHP] PHP Classes

2005-03-16 Thread Phil Neeb
Greets,
I've gone through the PHP Manual a few times now, reading about classes, 
but really, what's written there doesn't make a whole lot of sense to 
me.  I know a lot, if not the vast majority, of PHP programmers use 
classes, so I was wondering if some of you could explain them to me. 
What are the benefits of using classes? What's the format of a class? 
I'd like to know things like that and anything else you folks would like 
to teach me. Thanks

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


Re: [PHP] file/array manipulation

2005-03-16 Thread Mignon Hunter
Ok I got this to work but I'm not sure how -- and am having trouble 
re-producing the data:

My script I have so far is:

$lines = file('test2.csv');
foreach ($lines as $line) {
$line_split = explode(,, $line);
if(!(empty($line_split[0]) ) ){
//echo I'm not empty;
$new_array = array(
$line_split[0] = $line_split[1]
); 
}   
print(pre);
print_r($new_array);
print(/pre);
//echo trtd . $new_array[0] . /tdtd . $new_array[1] 
. /td/tr;// this doesnt work  
}

Here's what the printed format spits out (abbreviated):

Array
(
[R] = ABC company
)
Array
(
[R] = ABC company
)
Array
(
[R] = ABC company
)
Array
(
[R] = ABC company
)
Array
(
[O] = XYZ company
)
Array
(
[O] = XYZ company
)
Array
(
[O] = XYZ company
)
Array
(
[O] = XYZ company
)

So - I'm getting the write letters assigned to write companys which is great. 
But my echo line:

echo trtd . $new_array[0] . /tdtd . $new_array[1] . /td/tr;// 
this doesnt work

Do I have several arrays or a multidim array?

Thanks for any guidance

 Richard Lynch [EMAIL PROTECTED] 03/15/05 10:39AM 

 Hello

 I'm trying to manipulate a text(.csv) file using php. I've read the file
 and can print each line,
  but I need to write where column A is missing

 ColumnAColumnB

 RABC company
   ABC company
   ABC company
   ABC company
 OXYZ company
XYZ company
XYZ company
XYZ company

 What I need to do is write a while loop (I think) to interate through the
 lines and populate ColumnA
 while ColumnB equals $var (ABC company, XYZ company), so that I end up
 with:

 ColumnAColumnB

 RABC company
 RABC company
 RABC company
 RABC company
 OXYZ company
 OXYZ company
 OXYZ company
 OXYZ company

 Is this possible. What I've got so far to print out the file:

 $lines = file('test2.csv');


$category = '';

 // Loop through our array, and show line and numbers too.
 foreach ($lines as $line_num = $line) {
   echo Line #b{$line_num}/b :  . $line . br /\n;

//Assuming it's the FIRST character of each line that has space or category:
//Check first character:
if ($line[0] != ' '  $line[0] != \t){
  $category = $line[0];
}

echo $category\t, trim(substr($line, 1)), br /\n;

 }


 Thanks in advance

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




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

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



[PHP] Re: XPath Query Exressions and Quote Characters

2005-03-16 Thread C Drozdowski
It's just a coincidence that I used xml:id as part of my query 
expression. If I use following code method to build my expression:

$query = '//book/chapter[section=' . $section . ']';
or say
$query = '//book/[EMAIL PROTECTED]' . $title . ']';
I get an Invalid Predicate... error when either the $section or 
$title variable contains a double quote.

However, here's an example:
XML:
?xml version=1.0 encoding=UTF-8?
table
   row
   mod_idhome/mod_id
   mod_access1/mod_access
   mod_nameHome/mod_name
   /row
/table
XPath Expression:
$query = '//table/row[mod_name=' . $name . ']';
Variable Assignment:
$name = utf_encode('Home');
Using the expression throws the Invalid Predicate Error.

On 2005-03-16 12:06:24 -0500, [EMAIL PROTECTED] (Jason Barnett) said:
C Drozdowski wrote:
...
$query = '//book/chapter' . '[EMAIL PROTECTED]:id=' . $id . ']';
First of all check the XPath documentation:
http://www.w3.org/TR/xpath
http://www.w3.org/TR/xpath#path-abbrev
AFAIK your expression above is the way to build this query.  Give us a
link to the XML doc if you want us to take a look at that specific doc.
 Also make sure you referenced the correct DTD.  And (just to be sure)
try to validate you document against the DTD.
Given this expression, if $id contains one or more single quotes, an
error is thrown.
$query = //book/[EMAIL PROTECTED]:id='$id'];
I need to be able to build an exression that contains either double or
single quotes in the search regarding of how I programatically build the
expression.
A couple of things that may be in play here...
- First of all I recall there was a specific bug with xml:id, although I
can't recall off the top of my head what it was...
- Secondly the XPath querying interface in PHP will only return simple
data at this point.  In fact, I think it will only return strings.
http://www.w3.org/TR/xpath#attribute-nodes
But if your ID is simple data (integer / string), I can't imagine it
would be a problem for XPath to return it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: session.use_trans_sid Question

2005-03-16 Thread Jason Barnett
Al wrote:
 What are the pros and cons of session.use_trans_sid ON and OFF

 Just moved our site from one which had the php.ini,
 session.use_trans_sid=OFF to one with it ON

 Sure looks ugly having the PHPSESSID showing up for visitors.

 Thanks

PRO:
- makes life easier when session cookie isn't an option

CON:
- disables implicit flush for output buffering
- increased risk of session fixation

Others?

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


[PHP] Embed PHP

2005-03-16 Thread Patric Stout
Currently I am trying to get embed PHP to work. A nice C-application 
that can handle PHP-scripts. I hope this is the right place to ask 
question about it...

First of all, there is very poor documentation about this subject on the 
web. Even the Zend-docs are outdated. This doesn't make it easier. But 
anyway, I have a real problem, which I can't fix... I hope one of you 
know what to do about it:

most of the code works, it loads a script, runs it, and it stops when I 
want it to. Now I want to register functions on the fly. This is the 
part where it goes wrong.

I run a:
zend_register_functions(NULL, add_func_array, CG(function_table), 
MODULE_PERSISTENT);

two times, some cycles after the zend_execute_file is called (more 
exact: it is done on user-request), every time with an other 
function-name. Now I can call both functions from PHP, that works. But 
now when I close my application, it crashes. Glibc gives me an error 
that a pointer is tried to free'd twice. Here the GDB output:

#0  0x002a95e009b9 in raise () from /lib/tls/libc.so.6
#1  0x002a95e01fff in abort () from /lib/tls/libc.so.6
#2  0x002a95e3be7b in mallopt () from /lib/tls/libc.so.6
#3  0x002a95e39a22 in free () from /lib/tls/libc.so.6
#4  0x002a9760d1c0 in _efree () from /usr/lib/libphp5.so
#5  0x002a97619e36 in destroy_op_array () from /usr/lib/libphp5.so
#6  0x002a97619beb in destroy_zend_function () from /usr/lib/libphp5.so
#7  0x002a97619bf9 in zend_function_dtor () from /usr/lib/libphp5.so
#8  0x002a97627c2f in zend_hash_destroy () from /usr/lib/libphp5.so
#9  0x002a97620be3 in zend_shutdown () from /usr/lib/libphp5.s
I tried almost everything, and I am running out of ideas.. is this a 
bug, or is it not allowed to add functions on the fly to the same 
hash-table, or...

Of course I tried many many scenarios to isolate the problem. It works 
all pretty and nice, as long as I register all the functions BEFORE 
running zend_execute_file. I want to add functions after that time. 
Nowhere in the source I can see such restriction, and I see no reason 
why it should not work.. I hope you guys can help me.

Oh, one more note: I am running 64-bit linux, maybe that has something 
to do with it..

Tnx for your time,
Patric Stout
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] php 4 php 5

2005-03-16 Thread Rasmus Lerdorf
Kim Madsen wrote:
-Original Message-
From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 15, 2005 4:05 AM


That's why I'd like to stick with apache2 + php5 default and
apache2+php4 just for a single site hosted (the one that uses imp).

See my previous message describing the ProxyPass approach.  It is by far 
the easiest way to solve this cleanly.

I´ve only been on the list for a couple of weeks, so sorry if it´s already been 
answered but couldn´t one use 2 AddTypes?
LoadModule php4_module libexec/libphp4.so
AddType application/x-httpd-php .php4
LoadModule php5_module libexec/libphp5.so
AddType application/x-httpd-php5 .php .php5
AddModule mod_php4.c
AddModule mod_php5.c
I believe that´s how we did it while testing 3 vs 4 at one of my previous jobs (the ISP World Online/Tiscali), worked for hosted customers aswell.
Nope, this won't work.  libphp4.so and libphp5.so will have a lot of 
symbol clashes.  You could attempt compiling versioned libraries here, 
but we really haven't tested that.

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


RE: [PHP] opt-in mail list best practice

2005-03-16 Thread Chris W. Parker
Todd Trent mailto:[EMAIL PROTECTED]
on Wednesday, March 16, 2005 12:46 PM said:

 - Opt-in list could be less than 100 or in the 1000's.

[snip]

 I've been googling all day and have found mailing classes, libraries,
 and scripts none of which seem to be documented very well or let me
 build my own template for html mail. I understand there are going to
 be memory/shared usage limits to my current method. Should I be
 looping through possibly 1000 's of email addresses calling the mail
 function each time? Can someone please enlighten me a little

This question came up just recently (few days ago) and someone suggested
(among other things) to process the list in batches. So instead of
individually looping through 1000's of emails or putting 1000's of email
address in the Cc: or Bcc: fields, put them in batches of 200 or so and
go from there.



HTH,
Chris.

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



Re: [PHP] warning question about mysql sessions concurrency

2005-03-16 Thread Josh Whiting
On Wed, Mar 16, 2005 at 06:59:43PM +0100, Marek Kilimajer wrote:
 SO, does anyone have some code that uses MySQL to replace PHP's native
 session storage that also correctly handles this concurrency problem? 
 Ideally I'd like to see just a set of functions that can be used with 
 sessions_set_save_handler() to transparently shift PHP's sessions to a 
 database, but I'm not going to use the stuff I've found on the web or 
 even in books (appendix D of O'Reilly's Web Database Applications with 
 PHP  MySQL publishes code with this problem).

 
 MySQL's InnoDB supports row-level locking. So row the right row in 
 session_start and release it in session_close function.

But mysql does not support nested transactions.  Locking the row means
that your entire script has to happen inside a single transaction. 
Since my application logic requires transactions as well, it would mean
using two separate connections to MySQL, one for the session transaction
and one for business transactions, and that means twice the connection
overhead.

 In MyISAM you can use application-level locking: GET_LOCK() and 
 RELEASE_LOCK() in session_start and session_close, respectively. 
 Parameter would be session id with some prefix.

AH!  GET_LOCK() - that would do the trick!  I didn't realize MySQL
supported locking mechanisms independent of transactions/tables etc.

 The problem is when you need to create session id - you must lock the 
 whole table to find unused session id and insert it into table.

Hmm... couldn't I just do an 'insert ignore' with the session id every
time to kick off the process? Then MySQL would handle checking for an
existing row and create an empty one if it didn't exist. A very stripped
down example:

To open a session:
1. insert ignore into sessions (id,content) values ($sess_id,'')
2. select get_lock('my_prefix_.$sess_id, 15)
3. if NULL returned then abort, otherwise lock is aquired OK
4. select * from sessions where id=$sess_id

Do stuff ...

To close it:
1. update sessions set content='...'
2. select release_lock(my_prefix_.$sess_id)

I don't have all the details covered yet but I think that is just 
what I needed.  Thanks!!

/Josh W

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



Re: [PHP] incrementing a number from a text file

2005-03-16 Thread Kurt Yoder
On Mar 15, 2005, at 11:24 AM, Richard Lynch wrote:
BAD (probably):
Select blablabla FROM t1,t2,t3
WHERE customers LIKE '%$s%'
OR name LIKE '%$s%'
OR domain LIKE '%$s%'
OR email LIKE '%$s%'
OR log LIKE '%$s%'
AND t1.id = t2.t1_id
AND t1.id = t3.t1_id
GOOD (usually):
Select blablabla FROM t1,t2,t3
WHERE (customers LIKE '%$s%'
OR name LIKE '%$s%'
OR domain LIKE '%$s%'
OR email LIKE '%$s%'
OR log LIKE '%$s%')
AND t1.id = t2.t1_id
AND t1.id = t3.t1_id
Note parentheses added around OR expressions.
I see. Thanks for the info.

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


Re: [PHP] opt-in mail list best practice

2005-03-16 Thread Jeff Schmidt
Todd Trent wrote:
 This works fine for a few test emails. What I would like to know is 
what is
 considered best practice considering the following things:

 - This could be hosted on shared hosting server.
 - Opt-in list could be less than 100 or in the 1000s.
 - May need a way to track sending success.


Hello Todd,
  This is solely my suggestion on the matter, and I don't think I could 
classify this as 'best practice', as it is just my opinion (although it 
might be). I suggest that you setup a mailing list that is managed by a 
mailing list package, like GNU Mailman, or some other mailing list 
manager. A good mailing list manager is designed to track issues like 
mail being successfully sent, user unsubscribe, etc. Let the mailing 
list manager software do what it is good at, and have your script simply 
email your messages to the mailing list, which then takes care of 
distribution.

   If setting up a mailing list server is not possible on your shared 
host (very likely in a shared hosting setup), it is possible you might 
be able to setup a list with a third-party mailing-list hosting site. 
I've not researched this personally, but I'm sure probably multiple such 
services exist.

It should be possible, I think, in such a situation, to automate 
subscribing users to the list, from your scripts, when they create an 
account on your website (as well as initially adding all the users 
currently in the database, but you'd probably use a run-once script that 
did that in a batch).

   Anyhow, that is just my thoughts on the matter. Packages like 
Mailman are very good at managing mailing lists, so I would just use 
something like that to take care of that problem.

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


[PHP] PHP source code formatter for OS X

2005-03-16 Thread DuSTiN KRySaK
Does anyone know of a PHP source code formatter to clean up sloppy code 
that runs on OS X?

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


[PHP] Re: recommending a PHP book?

2005-03-16 Thread freaky . irish
Try this:
http://www.free-itebooks.com/php-mysql-free-itebooks/
and maybe you'll find ebook you're looking for

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



[PHP] Seleting records

2005-03-16 Thread Simon Allison
Hello,

 

My news table has a year field as such

 

Year



2000

2000

2001

2001

2003

2005

2005

 

I was wondering if you could select from this table so you only get one of
each year, so the output would be

 

2000

2001

2003

2005

 

Is this possible, I was trying to think of an algorithm that would work, but
I have had no luck yet?

 

Thanks,

Simon



[PHP] Re: Seleting records

2005-03-16 Thread David Robley
Simon Allison wrote:

 Hello,
 
  
 
 My news table has a year field as such
 
  
 
 Year
 
 
 
 2000
 
 2000
 
 2001
 
 2001
 
 2003
 
 2005
 
 2005
 
  
 
 I was wondering if you could select from this table so you only get one of
 each year, so the output would be
 
  
 
 2000
 
 2001
 
 2003
 
 2005
 
  
 
 Is this possible, I was trying to think of an algorithm that would work,
 but I have had no luck yet?

Use mysql DISTINCT

SELECT DISTINCT(year-field) FROM table

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



[PHP] obscure error message - PHP Notice: (null)(): Permission denied (errflg=2) in Unknown on line 0

2005-03-16 Thread Zinovi Boyadjiev
Hello,

I am getting this strange error while developing imap mail to mysql 
inporting script :

PHP Notice:  (null)(): Permission denied (errflg=2) in Unknown on line 0

I am getting it at the end of the script execution without affecting any 
actual script functionality.

I am using PHP 4.3.10 CLI interface on Windows

Does someone experienced the same problem ? Do you have any solution or hint 
where to look for ?

Regards,

Zinovi

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



[PHP] FreeBSD php upgrade oddity - can't load dynamic libraries

2005-03-16 Thread Al Arzaga
I'm running FreeBSD 5.2.1, and last night I cvsupped to the latest
ports.
This afternoon, I proceeded to upgrade PHP from 5.0.1 to 5.0.3.
But I kept getting these errors when restarting apache that it could not
find various shared libraries in /usr/local/lib/php/20041030
I see that I'm supposed to have such a directory, but what I do have is
a /usr/local/lib/php/20040412 instead.  (Pointing to that directory in
php.ini clearly is not the answer.)
Similar errors appear when running from the command line:
[kungpao:~]$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/ctype.so' - Cannot open 
quot;/usr/local/lib/php/20041030/ctype.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/simplexml.so' - Cannot open 
quot;/usr/local/lib/php/20041030/simplexml.soquot; in Unknown on line 
0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/dom.so' - Cannot open 
quot;/usr/local/lib/php/20041030/dom.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/gd.so' - Cannot open 
quot;/usr/local/lib/php/20041030/gd.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/iconv.so' - Cannot open 
quot;/usr/local/lib/php/20041030/iconv.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/ldap.so' - Cannot open 
quot;/usr/local/lib/php/20041030/ldap.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/mysql.so' - Cannot open 
quot;/usr/local/lib/php/20041030/mysql.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/odbc.so' - Cannot open 
quot;/usr/local/lib/php/20041030/odbc.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/oracle.so' - Cannot open 
quot;/usr/local/lib/php/20041030/oracle.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/pcre.so' - Cannot open 
quot;/usr/local/lib/php/20041030/pcre.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/pdf.so' - Cannot open 
quot;/usr/local/lib/php/20041030/pdf.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/posix.so' - Cannot open 
quot;/usr/local/lib/php/20041030/posix.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/session.so' - Cannot open 
quot;/usr/local/lib/php/20041030/session.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/sqlite.so' - Cannot open 
quot;/usr/local/lib/php/20041030/sqlite.soquot; in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/tokenizer.so' - Cannot open 
quot;/usr/local/lib/php/20041030/tokenizer.soquot; in Unknown on line 
0
PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/20041030/xml.so' - Cannot open 
quot;/usr/local/lib/php/20041030/xml.soquot; in Unknown on line 0
PHP 5.0.3 (cli) (built: Mar 16 2005 20:27:24)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
[kungpao:~]$

I've tried re-installing just the base install without any php 
configurations but to no avail.

Can anyone provide some insight on how I may solve this?
-Al

BEGIN:VCARD
VERSION:3.0
N:Arzaga;Alden;;;
FN:Alden Arzaga
ORG:Gelber Group\, LLC;
EMAIL;type=INTERNET;type=WORK:[EMAIL PROTECTED]
TEL;type=WORK:+1-312-692-2812
item1.ADR;type=WORK:;;141 West Jackson\nSuite 2100A;Chicago;IL;60604;United States
item1.X-ABADR:us
URL:www.arzaga.net
PHOTO;BASE64:
  /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
  AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEB
  AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCACAAIADASIA
  AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
  AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
  ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
  p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
  AwEBAQEBAQEBAQECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
  BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK
  U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3
  uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+NK2t
  n3Z28qEKDeQgVdxALIy7iQq52iRjxtUEkjSihb7xVuIzuIT5WwjBuXAYgKC3MmXYtkcKaiiUsGwA
  

[PHP] showing the decimal places

2005-03-16 Thread ross
when I define a number as

$number = 2.00

then echo it the number shows as 2. How can I get the two zeros to show?

This is not in any of my books but a fairly easy solution I'll bet!

R. 

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



[PHP] Session time out

2005-03-16 Thread Jacques
What is the life time of a PHP session object (variable)?  Which conditional 
test can I perform to check if the session object has timed out?

Jacques 

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



RE: [PHP] Session time out

2005-03-16 Thread yangshiqi
In your php.ini, session.gc_maxlifetime=1440;

 
Best regards,
Yang Shiqi
 
 
 

-Original Message-
From: Jacques [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 17, 2005 1:48 PM
To: php-general@lists.php.net
Subject: [PHP] Session time out

What is the life time of a PHP session object (variable)?  Which conditional

test can I perform to check if the session object has timed out?

Jacques 

-- 
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] showing the decimal places

2005-03-16 Thread Rob Agar
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 when I define a number as
 
 $number = 2.00
 
 then echo it the number shows as 2. How can I get the two 
 zeros to show?
 
 This is not in any of my books but a fairly easy solution I'll bet!

the function you want is called sprintf (s for string, f for format)
summat like this:

echo sprintf('%0.2f', $number);

hth,
Rob Agar

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



[PHP] [Fwd: db to xml using php]

2005-03-16 Thread K Karthik

---BeginMessage---
can anyone help me to write from db to xml using php.
if there is any site please do refer me.
thanks,
karthik

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

[PHP] db to xml using php

2005-03-16 Thread K Karthik
can anyone help me to write from db to xml using php.
if there is any site please do refer me.
thanks,
karthik
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] showing the decimal places

2005-03-16 Thread Kim Madsen
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 17, 2005 1:21 AM

 when I define a number as

 $number = 2.00

 then echo it the number shows as 2. How can I get the two zeros to
show?

Are You _sure_ the var is declared as a float? Have a look at gettype()
http://dk2.php.net/manual/en/function.gettype.php

$number += 2.00;

Should convert the var to a float according to:
http://dk2.php.net/manual/en/language.types.type-juggling.php#language.t
ypes.typecasting



-- 
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen 
Systemudvikler
Naverland 31

DK-2600 Glostrup
www.comx.dk 
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]

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



RE: [PHP] PHP Classes

2005-03-16 Thread Kim Madsen
-Original Message-
From: Phil Neeb [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 16, 2005 8:58 PM

 I've gone through the PHP Manual a few times now, reading about classes, 
 but really, what's written there doesn't make a whole lot of sense to 
 me.  I know a lot, if not the vast majority, of PHP programmers use 
 classes, so I was wondering if some of you could explain them to me. 
 What are the benefits of using classes? What's the format of a class? 
 I'd like to know things like that and anything else you folks would like 
 to teach me. Thanks

This is a PHP maillist, You´re asking about a programming concept. Google for 
oop+tutorial for info. 

In short a class is a bunch of functions, which manipulates the same area of 
data, for instance a SQL class which contains a select, insert, update and a 
delete function.

-- 
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen 
Systemudvikler/Systemdeveloper
Naverland 31

DK-2600 Glostrup
www.comx.dk 
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]

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