[PHP] Re: private, public, protected in 4.3.11

2006-01-11 Thread David Robley
Peter Lauri wrote:

> Hi,
> 
> Example code that I try to run in version 4.3.11:
> 
> Class Page {
> private $myID;
> function Page() {
> $this->myID=1;
> }
> 
> function getID() {
> return $this->myID;
> }
> 
> }
> 
> But I get error message:
> 
> Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or
> `T_VAR' or `'}'' in C:\Documents and Settings\Peter Lauri\My Documents\DWS
> Asia\webserver\ework\classes\page.class.php on line 8
> 
> If I change to
> var $myID;
> it works.
> 
> What is wrong?

I think you will find that the Visibility feature you are trying to use was
introduced with PHP 5


Cheers
-- 
David Robley

I'm sure it's in the manual somewhere...

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



[PHP] private, public, protected in 4.3.11

2006-01-11 Thread Peter Lauri
Hi,

 

Example code that I try to run in version 4.3.11:

 

Class Page {

private $myID;

 

function Page() {

$this->myID=1;

}

 

function getID() {

return $this->myID;

}

 

}

 

But I get error message:

 

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or
`T_VAR' or `'}'' in C:\Documents and Settings\Peter Lauri\My Documents\DWS
Asia\webserver\ework\classes\page.class.php on line 8

 

If I change to

var $myID;

it works.

 

What is wrong?

 

/Peter

 

 

 



[PHP] javascript in php page to use window.open()

2006-01-11 Thread Olga Urban
Hi everyone,  
 
I am trying to open a new window after a successful function call (I
don't want to use \n";
echo "
window.open(\"add.html\",\"resizable=no,width=400,height=200\");";
echo "\n\n";
}
else
echo "Error adding a record.";
 
 
 
Thanks.
 
Olga


[PHP] Apache2 PHP Downloadin Code

2006-01-11 Thread Ray Hauge
Hello everyone,

I'm having some problems with one of our servers.  Recently Plesk overwrote 
our configuration file, and I'm trying to get the thing back online.  To make 
a long story short, I've got PHP working with http, but now that I've got the 
https virtual host set up, php doesn't work with it.  Instead apache just 
sends a file download request to the client, so I can download the entire 
source code, instead of viewing the results from PHP.

Has anyone run into an issue like this?  It's just so odd that the HTTP 
virtual host works just fine, but the HTTPS virtual host does not.

I've got all the appropriate:

LoadModule php4_module modules/libphp4.so
AddHandler php-script php
AddType application/x-httpd-php .php .php4 .php3 .phtml .inc
DirectoryIndex index.php index.php3

in the php.conf file.  I don't think I have to specify to turn the PHP engine 
on in the HTTPS virtual host, do I?

Thanks for any help,

Ray Hauge

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



[PHP] Re: array of checkbox values

2006-01-11 Thread Al

Sjef Janssen wrote:

Hallo,
I have a form with a number of checkboxes grouped together. The value of
these boxes is stored in an array: $used[]. Now I found that the value of
checked boxes (value = 'Y') are stored in the array while non checked boxes
are not stored at all. This makes the array incomplete as I want to have all
checkbox values in the array.
For example: for 4 checkboxes the values are
checkbox 1: array index  = 0 value = "Y"
checkbox 2: array index = 1 value = "Y"
checkbox 3: value = "N" : it does not occur in the array
checkbox 4: array index = 2 value = "Y"

Is there a way to, as it were, complete the array and have all values
stored, even the "N" values? So that array index 2 has a value of "N", and
array index 3 is "Y".

Thxs

Sjef


Seems like I recall solving this problem.  It's been a long time, so you'll 
need to try it.

For each checkbox set these two


You'll get $_POST[foo] as "no" or "yes"

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



[PHP] Re: problem with large arrays in php 4.3.2

2006-01-11 Thread James Benson


Their should be no problem with what your trying to do, try the 
following function, should act pretty much like array_diff();





if(!function_exists('array_diff')) {
function array_diff($array1, $array2)
{
$difference = array();
foreach($array1 as $key => $value)
{
if(is_numeric($key)) {
if(!in_array($value, $array2)) {
$difference[] = $value;
}
} else {
if(!array_key_exists($key, $array2)) {
$difference[] = $key;
}
}
}
return $difference;
}
}




// small test
$array1 = array_fill(0, 2, 'banana');
$array2 = array();
print_r(array_diff($array1, $array2));




It also depends how much data the arrays contain

James



Jesse Guardiani wrote:

Hello,

I have an old version of php (4.3.2) that is acting rather strangely. I'm
searching two large arrays (approx 22,000 records in each) using
array_diff_key() from the PEAR PHP_Compat library:

$result = $args[0];
foreach ($args[0] as $key1 => $value1) {
for ($i = 1; $i !== $array_count; $i++) {
foreach ($args[$i] as $key2 => $value2) {
if ((string) $key1 === (string) $key2) {
unset($result[$key2]);
break 2;
}
}
}
}

And I'm getting aweful performance. I know it's a ton of records (22,000 *
22,000), but it shouldn't take 16 minutes on a P4 Xeon 2.4ghz!

Has anyone seen this before? Is this a bug? Or are my math skills lacking and
this is perfectly normal performance for the size of the data set?

Thanks!



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



[PHP] Re: test variable value?

2006-01-11 Thread David Robley
William Stokes wrote:

> Hello
> 
> What is the best way to determine if a variable has no value?
> 
> if ($var= '')
> 
> or
> 
> if ($var= 'null')
> 
> 
> Can 'null' be used here?

Look at isset() and empty()

Cheers
-- 
David Robley

You cannot achieve the impossible without attempting the absurd.

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



[PHP] Re: test variable value?

2006-01-11 Thread James Benson

If your talking values in submitted form data I would use:


if(isset($var) && trim($var) == '') {
   echo "Please give a value";
}




James




William Stokes wrote:

Hello

What is the best way to determine if a variable has no value?

if ($var= '')

or

if ($var= 'null')


Can 'null' be used here?

Thanks
-Willa 


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



[PHP] Re: Sending mail with php-

2006-01-11 Thread James Benson

alter the sendmail configuration file: /etc/mail/local-host-names

If that dont work you need to setup DNS for your machine.





James Benson wrote:
You need a domain name pointing to your IP address for a start, then you 
either need to configure php.ini to use the correct email or you should 
pass the additional param to sendmail, as shown below.



Taken from  php.net:

The additional_parameters parameter can be used to pass an additional 
parameter to the program configured to use when sending mail using the 
sendmail_path  configuration setting. For example, this can be used to 
set the envelope sender address when using sendmail with the -f sendmail 
option.


The user that the webserver runs as should be added as a trusted 
user to the sendmail configuration to prevent a 'X-Warning' header from 
being added to the message when the envelope sender (-f) is set using 
this method. For sendmail users, this file is /etc/mail/trusted-users.




 The additional_parameters parameter can be used to pass an additional 
parameter to the program configured to use when sending mail using the 
sendmail_path.





James


Dotan Cohen wrote:


On my home Fedora Core 4 box I run Apache 2.0. Sometimes when sending
mail with php no mail is delivered, and I find this in the logs:

<<< 550-Verification failed for <[EMAIL PROTECTED]>
<<< 550-unrouteable mail domain "localhost.localdomain"
<<< 550 Sender verify failed

So I changed the only email address in httpd.conf to:
ServerAdmin [EMAIL PROTECTED]

But I still get the error! I did restart apache and even went so far 
as to

reboot the machine. If I cannot modify the parameter within apache,
then where should I modify it? Within php? Within sendmail?

Thank you.

Dotan Cohen
http://technology-sleuth.com/question/what_are_the_advantages_of_lcd_monitors.html 


(-)


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



[PHP] Re: array of checkbox values

2006-01-11 Thread James Benson

Do something like:

$checkboxes = array('food','drink','smoking');

// display the checkboxes
foreach($checkboxes as $checkbox) {
echo "$checkbox: ";
}



Then when processing the form input check if each of the $checkboxes 
array values are present, if not, you can set to something else such as 
N, like so.




$sent_data = array();
foreach($checkboxes as $checkbox) {
  if(isset($_REQUEST[$checkbox])) {
$sent_data[$checkbox] = 'Y';
  } else {
$sent_data[$checkbox] = 'N';
  }
}





James



Sjef Janssen wrote:

Hallo,
I have a form with a number of checkboxes grouped together. The value of
these boxes is stored in an array: $used[]. Now I found that the value of
checked boxes (value = 'Y') are stored in the array while non checked boxes
are not stored at all. This makes the array incomplete as I want to have all
checkbox values in the array.
For example: for 4 checkboxes the values are
checkbox 1: array index  = 0 value = "Y"
checkbox 2: array index = 1 value = "Y"
checkbox 3: value = "N" : it does not occur in the array
checkbox 4: array index = 2 value = "Y"

Is there a way to, as it were, complete the array and have all values
stored, even the "N" values? So that array index 2 has a value of "N", and
array index 3 is "Y".

Thxs

Sjef


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



Re: [PHP] Re: array of checkbox values

2006-01-11 Thread Philip Hallstrom

Would it be enough to set a key for each checkbox, for example explicitly
say:
checkbox[1]
checkbox[2]
checkbox[3]
then a non checked box will have an empty string as a value, whereas the
checked ones will have a value of 'Y'.


Nope.  That's the problem.  If a checkbox is unchecked the browser doesn't 
need to send it all when it submits the server...


an example: 
http://www.pjkh.com/~philip/test/check.php




Sjef

"David Dorward" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]

Sjef Janssen wrote:


I have a form with a number of checkboxes grouped together. The value of
these boxes is stored in an array: $used[]. Now I found that the value of
checked boxes (value = 'Y') are stored in the array while non checked
boxes are not stored at all. This makes the array incomplete as I want to
have all checkbox values in the array.


That's how HTML forms work. The general solution is to set the value of
the
checkbox to describe what the checkbox is (for example, the row id of the
database record that the checkbox is associated with). Then you can loop
through and see which values were submitted.

--
David Dorward      
Home is where the ~/.bashrc is


--
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] Sending mail with php-

2006-01-11 Thread Dotan Cohen
On 1/11/06, Duffy, Scott E <[EMAIL PROTECTED]> wrote:
>
> This is what I use to send email via php. I have sent hundreds at once.
>
>
> $fromname="Cohen, Dotan";
> $fromaddress="[EMAIL PROTECTED]";
> $subject ="Subject";
> $message="message body";
> $from=" [EMAIL PROTECTED]";
>$headers  = "MIME-Version: 1.0\n";
>$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
>$headers .= "X-Priority: 3\n";
>$headers .= "X-MSMail-Priority: Normal\n";
>$headers .= "X-Mailer: php\n";
>$headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";
>//return mail($toaddress, $subject, $message, $headers);
> $toAddress='[EMAIL PROTECTED]';
> mail($toAddress,$subject,$message,$headers);
>
> good luck
>
>
> Scott Duffy
>
> -Original Message-
> From: Dotan Cohen [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 11, 2006 2:49 PM
> To: Sameer N Ingole
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Sending mail with php-
>
> On 1/10/06, Sameer N Ingole <[EMAIL PROTECTED]> wrote:
> > Dear Dotan,
> > Dotan Cohen wrote:
> >
> > >On my home Fedora Core 4 box I run Apache 2.0. Sometimes when sending
> > >mail with php no mail is delivered, and I find this in the logs:
> > >
> > ><<< 550-Verification failed for <[EMAIL PROTECTED]>
> > ><<< 550-unrouteable mail domain "localhost.localdomain"
> > ><<< 550 Sender verify failed
> > >
> > You are getting this error because [EMAIL PROTECTED] cannot
> > be reached from Internet and whoever you are sending mail to may have
> > something called sender check. This verifies if the sender of this
> mail
> > is reachable. This avoids spammers to send mails using unreachable
> > addresses. Also he may be checking spf-record for your From: domain on
> > mail envelop.
> >
> > >
> > >So I changed the only email address in httpd.conf to:
> > >ServerAdmin [EMAIL PROTECTED]
> > >
> > What error you are getting after you change address in apache and try
> > sending mail after restarting apache?
> >
> > >
> > >But I still get the error! I did restart apache and even went so far
> as to
> > >reboot the machine. If I cannot modify the parameter within apache,
> > >then where should I modify it? Within php? Within sendmail?
> > >
> >
>
> Excact same error. Actually, this was working fine until recently. I
> use the script (homemade) to send out the http://lyricslist.com
> monthly newsletter every month- and only this month am I having
> problems. No changes made to apache, php, or sendmail except the
> regular updates. Could an update have broken this?
>
> Dotan Cohen
> http://technology-sleuth.com/short_answer/what_is_hdtv.html
> 876
>

Thanks. The parts refering to the sender I _do_ have. The messages are
(for those who signed up for html) part html and part text. Here are
my headers:

--snip--
$from = "Dotan Cohen <[EMAIL PROTECTED]>";
$subject = "LyricsList Newsletter - January 2006";
--snip--
$headers  = "From: $from\n";
$headers .= "Reply-To: $from\n";
$headers .= "Date: ".date("r")."\n";
$headers .= "X-Mailer: Dotan Cohen's Homebrew PHP Mailer
(http://dotancohen.com)\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type:
multipart/mixed;\n\tboundary=\"=".rand(1000,)."\"\n";
--snip--
mail ($subscriber[0], $subject, $message, $headers);
--snip--

$subscriber[0] is the users email address (1 is text/html preferance,
2 is IP,...). When I send it to my Yahoo address for testing, it goes
through. Everywhere else (gmail.com, hotmail.com, dotancohen.com), it
fails with the error that I previously described. Relevant parts of
the headers that I take from mail.yahoo.com look like this:

X-Originating-IP:[192.117.111.61]
Return-Path:<[EMAIL PROTECTED]>
Authentication-Results: mta144.mail.mud.yahoo.com from=dotancohen.com;
domainkeys=neutral (no sig)
Received:   from 192.117.111.61 (EHLO localhost.localdomain)
(192.117.111.61) by mta144.mail.mud.yahoo.com with SMTP; Wed, 11 Jan
2006 12:40:14 -0800
Received:   from localhost.localdomain (localhost.localdomain
[127.0.0.1]) by localhost.localdomain (8.13.4/8.13.4) with ESMTP id
k0BKiiYo004610 for <[EMAIL PROTECTED]>; Wed, 11 Jan 2006 22:44:44
+0200
Received:   (from [EMAIL PROTECTED]) by localhost.localdomain
(8.13.4/8.13.4/Submit) id k0BKihHI004609; Wed, 11 Jan 2006 22:44:43
+0200

From:   "Dotan Cohen" <[EMAIL PROTECTED]>  Add to Address
BookAdd to Address Book
Reply-to:   Dotan Cohen <[EMAIL PROTECTED]>

192.117.111.61 is my home IP address (constant). Somewhere, the From
information is being written over by the default apache values. Where
can I change that? The email address in httpd.conf has already been
changed to my address.

Dotan Cohen
http://technology-sleuth.com/technical_answer/what_is_hdtv.html
823


[PHP] Re: array of checkbox values

2006-01-11 Thread Sjef
Would it be enough to set a key for each checkbox, for example explicitly 
say:
checkbox[1]
checkbox[2]
checkbox[3]
then a non checked box will have an empty string as a value, whereas the 
checked ones will have a value of 'Y'.

Sjef

"David Dorward" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]
> Sjef Janssen wrote:
>
>> I have a form with a number of checkboxes grouped together. The value of
>> these boxes is stored in an array: $used[]. Now I found that the value of
>> checked boxes (value = 'Y') are stored in the array while non checked
>> boxes are not stored at all. This makes the array incomplete as I want to
>> have all checkbox values in the array.
>
> That's how HTML forms work. The general solution is to set the value of 
> the
> checkbox to describe what the checkbox is (for example, the row id of the
> database record that the checkbox is associated with). Then you can loop
> through and see which values were submitted.
>
> -- 
> David Dorward      
> Home is where the ~/.bashrc is 

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



RE: [PHP] Sending mail with php-

2006-01-11 Thread Duffy, Scott E

This is what I use to send email via php. I have sent hundreds at once.


$fromname="Cohen, Dotan";
$fromaddress="[EMAIL PROTECTED]";
$subject ="Subject";
$message="message body";
$from=" [EMAIL PROTECTED]";
   $headers  = "MIME-Version: 1.0\n";
   $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
   $headers .= "X-Priority: 3\n";
   $headers .= "X-MSMail-Priority: Normal\n";
   $headers .= "X-Mailer: php\n";
   $headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";
   //return mail($toaddress, $subject, $message, $headers);
$toAddress='[EMAIL PROTECTED]';
mail($toAddress,$subject,$message,$headers);

good luck


Scott Duffy

-Original Message-
From: Dotan Cohen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 11, 2006 2:49 PM
To: Sameer N Ingole
Cc: php-general@lists.php.net
Subject: Re: [PHP] Sending mail with php-

On 1/10/06, Sameer N Ingole <[EMAIL PROTECTED]> wrote:
> Dear Dotan,
> Dotan Cohen wrote:
>
> >On my home Fedora Core 4 box I run Apache 2.0. Sometimes when sending
> >mail with php no mail is delivered, and I find this in the logs:
> >
> ><<< 550-Verification failed for <[EMAIL PROTECTED]>
> ><<< 550-unrouteable mail domain "localhost.localdomain"
> ><<< 550 Sender verify failed
> >
> You are getting this error because [EMAIL PROTECTED] cannot
> be reached from Internet and whoever you are sending mail to may have
> something called sender check. This verifies if the sender of this
mail
> is reachable. This avoids spammers to send mails using unreachable
> addresses. Also he may be checking spf-record for your From: domain on
> mail envelop.
>
> >
> >So I changed the only email address in httpd.conf to:
> >ServerAdmin [EMAIL PROTECTED]
> >
> What error you are getting after you change address in apache and try
> sending mail after restarting apache?
>
> >
> >But I still get the error! I did restart apache and even went so far
as to
> >reboot the machine. If I cannot modify the parameter within apache,
> >then where should I modify it? Within php? Within sendmail?
> >
>

Excact same error. Actually, this was working fine until recently. I
use the script (homemade) to send out the http://lyricslist.com
monthly newsletter every month- and only this month am I having
problems. No changes made to apache, php, or sendmail except the
regular updates. Could an update have broken this?

Dotan Cohen
http://technology-sleuth.com/short_answer/what_is_hdtv.html
876

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



Re: [PHP] test variable value?

2006-01-11 Thread Gerry Danen
On 1/11/06, M. Sokolewicz <[EMAIL PROTECTED]> wrote:
>
> remember though that
> if(!$x) {
>echo 'nothing here';
> }
>
> will also output 'nothing here' when provided with the string '0'!


That's because (!$x) means ($x == false) and '0' is false...

Gerry


[PHP] Re: array of checkbox values

2006-01-11 Thread David Dorward
Sjef Janssen wrote:

> I have a form with a number of checkboxes grouped together. The value of
> these boxes is stored in an array: $used[]. Now I found that the value of
> checked boxes (value = 'Y') are stored in the array while non checked
> boxes are not stored at all. This makes the array incomplete as I want to
> have all checkbox values in the array.

That's how HTML forms work. The general solution is to set the value of the
checkbox to describe what the checkbox is (for example, the row id of the
database record that the checkbox is associated with). Then you can loop
through and see which values were submitted.

-- 
David Dorward      
 Home is where the ~/.bashrc is

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



Re: [PHP] test variable value?

2006-01-11 Thread M. Sokolewicz

Gerry Danen wrote:

On 1/11/06, M. Sokolewicz <[EMAIL PROTECTED]> wrote:


remember though that
if(!$x) {
  echo 'nothing here';
}

will also output 'nothing here' when provided with the string '0'!




That's because (!$x) means ($x == false) and '0' is false...

Gerry

I know that, and you know that, as do others who have encountered 
problems with this before; just wanted to make a small warning so the OP 
wouldn't get hit by this


- tul

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



Re: [PHP] Sending mail with php-

2006-01-11 Thread Dotan Cohen
On 1/11/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
> actually I don't mind it - especially as I'm not on the apache or
> fedora lists ;-)
>
> and with regard to sending out emails I find using a connection with
> an SMTP server (local or not) is alot less hassle with regard to bounces
> and stuff (like the problem you were/are having) than using sendmail - not
> necessarily because an smtp service is better but because it means that 
> usually
> someone has already done the nitty-gritty mail server config stuff that sees 
> to
> it that mail gets reliably delivered!
>
> and phpmailer - thats also be known to help me from myself (when it comes to
> make a pig's ear of using the mail() function) - 3 cheers for Richard Heyes
> (you just know a class rocks when you can actually name the author by heart! 
> :-).
>

Isn't sendmail a local SMPT server?

Dotan Cohen
http://technology-sleuth.com/technical_answer/what_is_hdtv.html
092


RE: [PHP] Reading large files via PHP?

2006-01-11 Thread Philip Hallstrom

I'm reading in a 66MB file into php so I can parse it and load it into a
database.  However, it is taking a long time for php to read the file.
So long that the script times out.  I know about the
ini_set("max_execution_time", 120) or whatever length I want to set the
time out for the script, but my question is as follows.

Is it possible to read in a file and at the same time echo out a status
of how far along the file has been read?

The code I have right now is below.  Just wondering if what I'm trying
to do is possible and how to do it.

// set script timeout
ini_set("max_execution_time", 120);

// import file name
$log_file_name = "access_log.1";
echo "Reading access log!";
if (!$ac_arr = file("./$log_file_name")) {
echo "Couldn't load access log!";
die;
}

Thanks!


Even if you get around the execution time the above code is going to use
up 66megs of memory to store that file in $ac_arr.

You'd be much better off doing something like:

$fd = fopen("./$log_file_name", "r");

while ( !feof($fd) ) {
$buf = fread($fd, 32768);
// process buffer here
}
fclose($fd);

That will let you do your progress thing as well as not eat up so much
memory.  Play around with values of 32768 to see if smaller or larger
makes any different on your system.

Good luck!


Ahhh.. Okay that's very cool and I did not know that.  I knew that it 
was chewing up a lot of memory reading it all at once.


I guess the only thing I have to worry about now is if I do a read like 
that will it truncate a whole line instead of getting the whole line? 
The reason why I ask is that if possible I would rather have it read 
line by line for X lines and then process that buffer then go and grab 
more lines until end of file.  Is that possible?


Sure.  If it's a text file you could do something like this:

$i = 0;
$buf = "";
while ( !feof($fd) ) {
$buf .= fgets($fd);
if ( $i++ % 10 == 0 ) {
// process buf here
$buf = "";
}
}

Or you could turn buf into an array with $buf[] = fgets($fd) if that's 
easier...


All kinds of options :)

-philip

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



Re: [PHP] Sending mail with php-

2006-01-11 Thread Dotan Cohen
On 1/10/06, Sameer N Ingole <[EMAIL PROTECTED]> wrote:
> Dear Dotan,
> Dotan Cohen wrote:
>
> >On my home Fedora Core 4 box I run Apache 2.0. Sometimes when sending
> >mail with php no mail is delivered, and I find this in the logs:
> >
> ><<< 550-Verification failed for <[EMAIL PROTECTED]>
> ><<< 550-unrouteable mail domain "localhost.localdomain"
> ><<< 550 Sender verify failed
> >
> You are getting this error because [EMAIL PROTECTED] cannot
> be reached from Internet and whoever you are sending mail to may have
> something called sender check. This verifies if the sender of this mail
> is reachable. This avoids spammers to send mails using unreachable
> addresses. Also he may be checking spf-record for your From: domain on
> mail envelop.
>
> >
> >So I changed the only email address in httpd.conf to:
> >ServerAdmin [EMAIL PROTECTED]
> >
> What error you are getting after you change address in apache and try
> sending mail after restarting apache?
>
> >
> >But I still get the error! I did restart apache and even went so far as to
> >reboot the machine. If I cannot modify the parameter within apache,
> >then where should I modify it? Within php? Within sendmail?
> >
>

Excact same error. Actually, this was working fine until recently. I
use the script (homemade) to send out the http://lyricslist.com
monthly newsletter every month- and only this month am I having
problems. No changes made to apache, php, or sendmail except the
regular updates. Could an update have broken this?

Dotan Cohen
http://technology-sleuth.com/short_answer/what_is_hdtv.html
876


[PHP] Re: Image size?

2006-01-11 Thread zerof


what would the chance be that the OP actually knows Portuguese and could 
read that? 

---
I don't know what is the chance, but the example in this page doesn't 
requires to know portuguese.

Sorry if you don't speak portuguese. Sorry for my poor english.

zerof

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



RE: [PHP] array of checkbox values

2006-01-11 Thread Jim Moseby
> Hallo,
> I have a form with a number of checkboxes grouped together. 
> The value of
> these boxes is stored in an array: $used[]. Now I found that 
> the value of
> checked boxes (value = 'Y') are stored in the array while non 
> checked boxes
> are not stored at all. This makes the array incomplete as I 
> want to have all
> checkbox values in the array.
> For example: for 4 checkboxes the values are
> checkbox 1: array index  = 0 value = "Y"
> checkbox 2: array index = 1 value = "Y"
> checkbox 3: value = "N" : it does not occur in the array
> checkbox 4: array index = 2 value = "Y"
> 
> Is there a way to, as it were, complete the array and have all values
> stored, even the "N" values? So that array index 2 has a 
> value of "N", and
> array index 3 is "Y".


You could pre-initialize the array with all 'N' values, then update the
array with the 'Y's from the checkboxes.

JM

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



RE: [PHP] Reading large files via PHP?

2006-01-11 Thread Jay Paulson \(CE CEN\)
>> I'm reading in a 66MB file into php so I can parse it and load it into a 
>> database.  However, it is taking a long time for php to read the file. 
>> So long that the script times out.  I know about the 
>> ini_set("max_execution_time", 120) or whatever length I want to set the 
>> time out for the script, but my question is as follows.
>>
>> Is it possible to read in a file and at the same time echo out a status 
>> of how far along the file has been read?
>>
>> The code I have right now is below.  Just wondering if what I'm trying 
>> to do is possible and how to do it.
>>
>> // set script timeout
>> ini_set("max_execution_time", 120);
>>
>> // import file name
>> $log_file_name = "access_log.1";
>> echo "Reading access log!";
>> if (!$ac_arr = file("./$log_file_name")) {
>>  echo "Couldn't load access log!";
>>  die;
>> }
>>
>> Thanks!
>
> Even if you get around the execution time the above code is going to use 
> up 66megs of memory to store that file in $ac_arr.
>
> You'd be much better off doing something like:
>
> $fd = fopen("./$log_file_name", "r");
>
> while ( !feof($fd) ) {
>   $buf = fread($fd, 32768);
>   // process buffer here
> }
> fclose($fd);
>
> That will let you do your progress thing as well as not eat up so much 
> memory.  Play around with values of 32768 to see if smaller or larger 
> makes any different on your system.
> 
> Good luck!

Ahhh.. Okay that's very cool and I did not know that.  I knew that it was 
chewing up a lot of memory reading it all at once.  

I guess the only thing I have to worry about now is if I do a read like that 
will it truncate a whole line instead of getting the whole line?  The reason 
why I ask is that if possible I would rather have it read line by line for X 
lines and then process that buffer then go and grab more lines until end of 
file.  Is that possible?


[PHP] array of checkbox values

2006-01-11 Thread Sjef Janssen
Hallo,
I have a form with a number of checkboxes grouped together. The value of
these boxes is stored in an array: $used[]. Now I found that the value of
checked boxes (value = 'Y') are stored in the array while non checked boxes
are not stored at all. This makes the array incomplete as I want to have all
checkbox values in the array.
For example: for 4 checkboxes the values are
checkbox 1: array index  = 0 value = "Y"
checkbox 2: array index = 1 value = "Y"
checkbox 3: value = "N" : it does not occur in the array
checkbox 4: array index = 2 value = "Y"

Is there a way to, as it were, complete the array and have all values
stored, even the "N" values? So that array index 2 has a value of "N", and
array index 3 is "Y".

Thxs

Sjef

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



Re: [PHP] Reading large files via PHP?

2006-01-11 Thread Philip Hallstrom
I'm reading in a 66MB file into php so I can parse it and load it into a 
database.  However, it is taking a long time for php to read the file. 
So long that the script times out.  I know about the 
ini_set("max_execution_time", 120) or whatever length I want to set the 
time out for the script, but my question is as follows.


Is it possible to read in a file and at the same time echo out a status 
of how far along the file has been read?


The code I have right now is below.  Just wondering if what I'm trying 
to do is possible and how to do it.


// set script timeout
ini_set("max_execution_time", 120);

// import file name
$log_file_name = "access_log.1";
echo "Reading access log!";
if (!$ac_arr = file("./$log_file_name")) {
echo "Couldn't load access log!";
die;
}

Thanks!


Even if you get around the execution time the above code is going to use 
up 66megs of memory to store that file in $ac_arr.


You'd be much better off doing something like:

$fd = fopen("./$log_file_name", "r");

while ( !feof($fd) ) {
$buf = fread($fd, 32768);
// process buffer here
}
fclose($fd);

That will let you do your progress thing as well as not eat up so much 
memory.  Play around with values of 32768 to see if smaller or larger 
makes any different on your system.


Good luck!

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



[PHP] Re: Sending mail with php-

2006-01-11 Thread James Benson
You need a domain name pointing to your IP address for a start, then you 
either need to configure php.ini to use the correct email or you should 
pass the additional param to sendmail, as shown below.



Taken from  php.net:

The additional_parameters parameter can be used to pass an additional 
parameter to the program configured to use when sending mail using the 
sendmail_path  configuration setting. For example, this can be used to 
set the envelope sender address when using sendmail with the -f sendmail 
option.


The user that the webserver runs as should be added as a trusted 
user to the sendmail configuration to prevent a 'X-Warning' header from 
being added to the message when the envelope sender (-f) is set using 
this method. For sendmail users, this file is /etc/mail/trusted-users.




 The additional_parameters parameter can be used to pass an additional 
parameter to the program configured to use when sending mail using the 
sendmail_path.





James


Dotan Cohen wrote:

On my home Fedora Core 4 box I run Apache 2.0. Sometimes when sending
mail with php no mail is delivered, and I find this in the logs:

<<< 550-Verification failed for <[EMAIL PROTECTED]>
<<< 550-unrouteable mail domain "localhost.localdomain"
<<< 550 Sender verify failed

So I changed the only email address in httpd.conf to:
ServerAdmin [EMAIL PROTECTED]

But I still get the error! I did restart apache and even went so far as to
reboot the machine. If I cannot modify the parameter within apache,
then where should I modify it? Within php? Within sendmail?

Thank you.

Dotan Cohen
http://technology-sleuth.com/question/what_are_the_advantages_of_lcd_monitors.html
(-)


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



[PHP] Reading large files via PHP?

2006-01-11 Thread Jay Paulson \(CE CEN\)
I'm reading in a 66MB file into php so I can parse it and load it into a 
database.  However, it is taking a long time for php to read the file.  So long 
that the script times out.  I know about the ini_set("max_execution_time", 120) 
or whatever length I want to set the time out for the script, but my question 
is as follows.

Is it possible to read in a file and at the same time echo out a status of how 
far along the file has been read?

The code I have right now is below.  Just wondering if what I'm trying to do is 
possible and how to do it.

// set script timeout
ini_set("max_execution_time", 120);

// import file name
$log_file_name = "access_log.1";
echo "Reading access log!";
if (!$ac_arr = file("./$log_file_name")) {
echo "Couldn't load access log!";
die;
}

Thanks!


RE: [PHP] php .htaccess

2006-01-11 Thread Weber Sites LTD
You may want to check this list of Authentication related code examples :
http://www.weberdev.com/search.php3?searchtype=category&category=Authenticat
ion&secondary=&IsSub=1

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP code examples : http://www.weberdev.com 
PHP Web Logs : http://www.weberblog.com/ 
PHP & MySQL Forums : http://www.weberforums.com/ 
Learn PHP Playing Trivia http://www.webertrivia.com 
Web Development Index http://www.weberindex.com 
Web Templates http://www.webertemplates.com
Search for PHP Code from your browser http://toolbar.weberdev.com 

 

-Original Message-
From: enediel gonzalez [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 11, 2006 4:50 PM
To: php-general@lists.php.net
Subject: [PHP] php .htaccess

Hello

I've a site with a .htaccess defined, the users have to enter the login and
password to get in, Is it possible on php to ask the apache server wich user
is using the current session?

I'd like to give the users the oportunity to change their password but
without ask again who are you.

Thanks in advance for any answer.
Regards
Enediel

Linux user 300141
Debian GNU/Linux

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

2006-01-11 Thread ron

test

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



Re: [PHP] Capturing the current URL when mod_rewrite is used

2006-01-11 Thread Brian Dunning
I think I answered my own question. The following works even when  
mod_rewrite has changed the URL:


'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

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



Re: [PHP] Capturing the current URL when mod_rewrite is used

2006-01-11 Thread Richard Lynch
On Wed, January 11, 2006 11:33 am, Brian Dunning wrote:
> How do I capture the current displayed URL when it has been changed
> by mod_rewrite?
>
> Example:
> original (ugly) URL is http://domain.com?id=12345
> displayed (friendly) URL is http://domain.com/California
>
> When I use 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] that
> only gives me the original URL. How do I get the current URL?

Try using  in a page with a re-written URL and see
if it outputs the re-written URL.

If that fails, odds are looking pretty bad...

Personally, I have found that not messing with mod_rewrite and using
$_SERVER['PATH_INFO'] with .htaccess instead is far more flexible and
maintainable.

Not to mention portable to servers where you don't (won't) have access
to httpd.conf to enable mod_rewrite.

There is a performance penalty for .htaccess being on, and if you need
to wring out every last microwatt of power from your box, and know for
sure you'll never have to port to a shared environment, then
mod_rewrite is probably the way to go.  But for MOST users, it's not.

Back on-topic:  If the data you want isn't available, it seems to me
like the kind of thing Apache really ought to be providing for PHP to
give you...  Maybe it would be fun for you to dive into Apache source
and submit a patch. :-)

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

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



Re: [PHP] Re: Image size?

2006-01-11 Thread Warren Vail

Try; http://www.php.net/manual/en/function.getimagesize.php

Warren

At 09:16 AM 1/11/2006, M. Sokolewicz wrote:

zerof wrote:

William Stokes escreveu:


Hello,

Can I get pixel sizes from a uploaded web applicable image with PHP? I 
mean width and height as pixels. If  so How?


Thanks
-Will

--
http://www.educar.pro.br/abc/mathgd/index.php?xyz=30

zerof


what would the chance be that the OP actually knows Portuguese and could 
read that? rather small if you ask me... Just to help those that don't 
have a clue what the link links to, it links to a page describing the 
getimagesize function (in portuguese). It might have been more helpful to 
post a simple link to the PHP manual, or even just name the function to 
use. But that's just my opinion on this matter.
We all appreciate the fact that you try to share your knowledge, and help 
the OP.


- tul

--
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] Capturing the current URL when mod_rewrite is used

2006-01-11 Thread Brian Dunning
How do I capture the current displayed URL when it has been changed  
by mod_rewrite?


Example:
original (ugly) URL is http://domain.com?id=12345
displayed (friendly) URL is http://domain.com/California

When I use 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] that  
only gives me the original URL. How do I get the current URL?


Thanks.

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



[PHP] Re: Image size?

2006-01-11 Thread M. Sokolewicz

zerof wrote:

William Stokes escreveu:


Hello,

Can I get pixel sizes from a uploaded web applicable image with PHP? I 
mean width and height as pixels. If  so How?


Thanks
-Will 


--
http://www.educar.pro.br/abc/mathgd/index.php?xyz=30

zerof


what would the chance be that the OP actually knows Portuguese and could 
read that? rather small if you ask me... Just to help those that don't 
have a clue what the link links to, it links to a page describing the 
getimagesize function (in portuguese). It might have been more helpful 
to post a simple link to the PHP manual, or even just name the function 
to use. But that's just my opinion on this matter.
We all appreciate the fact that you try to share your knowledge, and 
help the OP.


- tul

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



Re: [PHP] Sending mail with php-

2006-01-11 Thread Richard Heyes
and phpmailer - thats also be known to help me from myself (when it 
comes to

make a pig's ear of using the mail() function) - 3 cheers for Richard Heyes
(you just know a class rocks when you can actually name the author by 
heart! :-).


Actually it's HTMLMimeMail - phpmailer is someone elses. :-)

http://www.phpguru.org/mime.mail.html

--
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] Sending mail with php-

2006-01-11 Thread Jochem Maas

Dotan Cohen wrote:

On 1/10/06, Sameer N Ingole <[EMAIL PROTECTED]> wrote:


Dear Dotan,

You know cross-posting is bad..?



...

actually I don't mind it - especially as I'm not on the apache or
fedora lists ;-)

and with regard to sending out emails I find using a connection with
an SMTP server (local or not) is alot less hassle with regard to bounces
and stuff (like the problem you were/are having) than using sendmail - not
necessarily because an smtp service is better but because it means that usually
someone has already done the nitty-gritty mail server config stuff that sees to
it that mail gets reliably delivered!

and phpmailer - thats also be known to help me from myself (when it comes to
make a pig's ear of using the mail() function) - 3 cheers for Richard Heyes
(you just know a class rocks when you can actually name the author by heart! 
:-).



Yes, I know that cross-posting is unencouraged behaviour. However, I
really thought that apache-users was the place to ask. When I received
no reply from the apache mailing list, I did not know whether to ask
here or at my distro's (Fedora) list. As the problem is in a php
script, however, it involves php AND apache AND sendmail, all of which
were installed by default on my distro- and are expected to work. I
was not sure if the fault is with me (my misconfiguration) or with the
distro (distros default configuration).

So I appologize, and here I learned yet another lesson- when I _do_
cheat- I get caught!

Dotan Cohen
http://technology-sleuth.com/short_answer/what_is_hdtv.html
(&^


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



Re: [PHP] test variable value?

2006-01-11 Thread M. Sokolewicz

remember though that
if(!$x) {
  echo 'nothing here';
}

will also output 'nothing here' when provided with the string '0'!

- tul

Rodolfo Andrade wrote:

I do use if(!$var) for simple application. Only _IF_ I need to know if the
$var is defined but empty or so I would use especific functions.

- Original Message - 
From: Stut

To: Rodolfo Andrade
Cc: William Stokes ; php-general@lists.php.net
Sent: Wednesday, January 11, 2006 11:49 AM
Subject: Re: [PHP] test variable value?


Rodolfo Andrade wrote:



How about...

if (!$x){
  echo "x is empty";
}





Because $x could be an empty string, 0, false, null or undefined. If
that's what you need to check for then knock yourself out.

-Stuart


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



Re: [PHP] php .htaccess

2006-01-11 Thread Robin Vickery
On 1/11/06, enediel gonzalez <[EMAIL PROTECTED]> wrote:
> Hello
>
> I've a site with a .htaccess defined, the users have to enter the login and
> password to get in,
> Is it possible on php to ask the apache server wich user is using the
> current session?

$_SERVER['REMOTE_USER']

  -robin


Re: [PHP] test variable value?

2006-01-11 Thread Rodolfo Andrade
I do use if(!$var) for simple application. Only _IF_ I need to know if the
$var is defined but empty or so I would use especific functions.

- Original Message - 
From: Stut
To: Rodolfo Andrade
Cc: William Stokes ; php-general@lists.php.net
Sent: Wednesday, January 11, 2006 11:49 AM
Subject: Re: [PHP] test variable value?


Rodolfo Andrade wrote:

>How about...
>
>if (!$x){
>echo "x is empty";
>}
>
>

Because $x could be an empty string, 0, false, null or undefined. If
that's what you need to check for then knock yourself out.

-Stuart

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



[PHP] Re: Image size?

2006-01-11 Thread zerof

William Stokes escreveu:

Hello,

Can I get pixel sizes from a uploaded web applicable image with PHP? I mean 
width and height as pixels. If  so How?


Thanks
-Will 

--
http://www.educar.pro.br/abc/mathgd/index.php?xyz=30

zerof

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



[PHP] php .htaccess

2006-01-11 Thread enediel gonzalez

Hello

I've a site with a .htaccess defined, the users have to enter the login and 
password to get in,
Is it possible on php to ask the apache server wich user is using the 
current session?


I'd like to give the users the oportunity to change their password but 
without ask again who are you.


Thanks in advance for any answer.
Regards
Enediel

Linux user 300141
Debian GNU/Linux

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



Re: [PHP] Image size?

2006-01-11 Thread William Stokes
Cheers!
:)


""Albert"" <[EMAIL PROTECTED]> kirjoitti 
viestissä:[EMAIL PROTECTED]
> William Stokes wrote:
>> Can I get pixel sizes from a uploaded web applicable image with PHP? I
>> mean width and height as pixels. If  so How?
>
> http://www.php.net/manual/en/function.getimagesize.php
>
> HTH
>
> Albert
>
> -- 
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.371 / Virus Database: 267.14.17/226 - Release Date: 
> 2006/01/10
> 

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



Re: [PHP] test variable value?

2006-01-11 Thread Stut

Rodolfo Andrade wrote:


How about...

if (!$x){
   echo "x is empty";
}
 



Because $x could be an empty string, 0, false, null or undefined. If 
that's what you need to check for then knock yourself out.


-Stuart

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



RE: [PHP] Image size?

2006-01-11 Thread Albert
William Stokes wrote:
> Can I get pixel sizes from a uploaded web applicable image with PHP? I
> mean width and height as pixels. If  so How?

http://www.php.net/manual/en/function.getimagesize.php

HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.17/226 - Release Date: 2006/01/10
 

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



Re: [PHP] Image size?

2006-01-11 Thread David Grant
Will,

William Stokes wrote:
> Can I get pixel sizes from a uploaded web applicable image with PHP? I mean 
> width and height as pixels. If  so How?

http://www.php.net/getimagesize

David
-- 
David Grant
http://www.grant.org.uk/

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



RE: [PHP] Image size?

2006-01-11 Thread Dan Parry
I would say this is what you need

http://uk2.php.net/manual/en/function.getimagesize.php

Dan

-Original Message-
From: William Stokes [mailto:[EMAIL PROTECTED] 
Sent: 11 January 2006 12:22
To: php-general@lists.php.net
Subject: [PHP] Image size?

Hello,

Can I get pixel sizes from a uploaded web applicable image with PHP? I mean 
width and height as pixels. If  so How?

Thanks
-Will 

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

__ NOD32 1.1356 (20060108) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com

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



[PHP] Image size?

2006-01-11 Thread William Stokes
Hello,

Can I get pixel sizes from a uploaded web applicable image with PHP? I mean 
width and height as pixels. If  so How?

Thanks
-Will 

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



[PHP] Re: Check how much/which variables there are in an class

2006-01-11 Thread Mathijs

Stefan Reimers wrote:

Try

array get_class_vars ( string class_name)

This will return an array with at least the public variables.


Mathijs wrote:

Is there a way to check how much/which variables there are in an class?

Thx in advanced.


It works, but only for the public indeed.
Is there also a way to get the private/protected variables?

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



Re: [PHP] Speed

2006-01-11 Thread Rodolfo Andrade
I think calculating directly in MySQL will be faster, since less data will
be "travelling" from MySQL to PHP.

Just my 2¢.

Regards,
Rodolfo Andrade

- Original Message - 
From: Weber Sites LTD
To: 'Peter Lauri' ; php-general@lists.php.net
Sent: Wednesday, January 11, 2006 6:07 AM
Subject: RE: [PHP] Speed


Why not check it?

Try to query for the AVG() and get the result or query for the data
and do a loop in PHP to calculate the AVG. Check the time each
Takes.

My Money is that getting the value from SQL will be faster.

Sincerely

berber

Visit the Weber Sites Today,
To see where PHP might take you tomorrow.
PHP code examples : http://www.weberdev.com
PHP Web Logs : http://www.weberblog.com/
PHP & MySQL Forums : http://www.weberforums.com/
Learn PHP Playing Trivia http://www.webertrivia.com
Web Development Index http://www.weberindex.com
Web Templates http://www.webertemplates.com
Search for PHP Code from your browser http://toolbar.weberdev.com


-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 11, 2006 9:14 AM
To: php-general@lists.php.net
Subject: [PHP] Speed

Best group member,



Assume that I save data about an object and it has 10.000 observations of
the object stored in a MySQL database. I want calculate the average value of
a column, is it faster done by using PHP on the result array or using the
MySQL function to do that?



/Peter

-- 
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] test variable value?

2006-01-11 Thread Rodolfo Andrade
How about...

if (!$x){
echo "x is empty";
}

Regards,
Rodolfo Andradee


- Original Message - 
From: Stut 
To: William Stokes 
Cc: php-general@lists.php.net 
Sent: Wednesday, January 11, 2006 8:08 AM
Subject: Re: [PHP] test variable value?


William Stokes wrote:

>Hello
>
>What is the best way to determine if a variable has no value?
>
>if ($var== '')
>
>or
>
>if ($var== 'null')
>
>
>Can 'null' be used here?
>  
>
Depends what you mean by no value. I suggest you read 
http://php.net/is_null, http://php.net/empty and http://php.net/isset.

-Stut

-- 
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: Check how much/which variables there are in an class

2006-01-11 Thread Stefan Reimers

Try

array get_class_vars ( string class_name)

This will return an array with at least the public variables.


Mathijs wrote:

Is there a way to check how much/which variables there are in an class?

Thx in advanced.


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



Re: [PHP] test variable value?

2006-01-11 Thread Stut

William Stokes wrote:


Hello

What is the best way to determine if a variable has no value?

if ($var== '')

or

if ($var== 'null')


Can 'null' be used here?
 

Depends what you mean by no value. I suggest you read 
http://php.net/is_null, http://php.net/empty and http://php.net/isset.


-Stut

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



Re: [PHP] test variable value?

2006-01-11 Thread Jochem Maas

William Stokes wrote:

Hello

What is the best way to determine if a variable has no value?

if ($var== '')

or

if ($var== 'null')


Can 'null' be used here?


yeah buts its a string which doesn't do what you want.



if (empty($var)) { echo 'yes'; }

or:

if (is_null($var)) { echo 'yes'; }




Thanks
-Willa



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



[PHP] test variable value?

2006-01-11 Thread William Stokes
Hello

What is the best way to determine if a variable has no value?

if ($var== '')

or

if ($var== 'null')


Can 'null' be used here?

Thanks
-Willa

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



[PHP] test variable value?

2006-01-11 Thread William Stokes
Hello

What is the best way to determine if a variable has no value?

if ($var= '')

or

if ($var= 'null')


Can 'null' be used here?

Thanks
-Willa 

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



Re: [PHP] Case-Insensitive include on linux.

2006-01-11 Thread Mathijs

George Pitcher wrote:

Mathijs wrote:


Is there a way to have include() be case-insensitive?


If you are know that all your file and directory names are lower case, but
users may input mixed case responses that will be used to determine the
include, you can set the case of the user input to lower case with
strtolower(). Or strtoupper() - the choice is yours.

If you have been a bit careless in naming your directories or filenames,
then I'd do some site maintenance and get that sorted first.

George


Owkay, its clear :).
I just wondered if it was possible, would save some other trouble :).

Thx for the help.

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



[PHP] Check how much/which variables there are in an class

2006-01-11 Thread Mathijs

Is there a way to check how much/which variables there are in an class?

Thx in advanced.

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



RE: [PHP] Case-Insensitive include on linux.

2006-01-11 Thread George Pitcher
Mathijs wrote:

> Is there a way to have include() be case-insensitive?

If you are know that all your file and directory names are lower case, but
users may input mixed case responses that will be used to determine the
include, you can set the case of the user input to lower case with
strtolower(). Or strtoupper() - the choice is yours.

If you have been a bit careless in naming your directories or filenames,
then I'd do some site maintenance and get that sorted first.

George

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



RE: [PHP] Speed

2006-01-11 Thread Weber Sites LTD
Why not check it?

Try to query for the AVG() and get the result or query for the data
and do a loop in PHP to calculate the AVG. Check the time each 
Takes.

My Money is that getting the value from SQL will be faster.

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP code examples : http://www.weberdev.com 
PHP Web Logs : http://www.weberblog.com/ 
PHP & MySQL Forums : http://www.weberforums.com/ 
Learn PHP Playing Trivia http://www.webertrivia.com 
Web Development Index http://www.weberindex.com 
Web Templates http://www.webertemplates.com
Search for PHP Code from your browser http://toolbar.weberdev.com 


-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 11, 2006 9:14 AM
To: php-general@lists.php.net
Subject: [PHP] Speed

Best group member,

 

Assume that I save data about an object and it has 10.000 observations of
the object stored in a MySQL database. I want calculate the average value of
a column, is it faster done by using PHP on the result array or using the
MySQL function to do that?

 

/Peter

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



Re: [PHP] Speed

2006-01-11 Thread Philip Hallstrom

Assume that I save data about an object and it has 10.000 observations of
the object stored in a MySQL database. I want calculate the average value of
a column, is it faster done by using PHP on the result array or using the
MySQL function to do that?


MySQL.

You don't have to transfer all 10,000 records to PHP for one thing.

-philip

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



Re: [PHP] Case-Insensitive include on linux.

2006-01-11 Thread Marco Kaiser
Hi,

this is very stupid because you can have files in a directory named:

PleaSeINCLUDeMe.php
pleaseincludeme.php

and if you do a case insensitive include which one should be included?
The include stuff works insensitive under windows great because the
filesystem does not permit 2 file with the same name in a directory.
The example above is not possible.

-- Marco

2006/1/11, Albert <[EMAIL PROTECTED]>:
>
> Mathijs wrote:
> > Is there a way to have include() be case-insensitive?
> Linux file systems are case sensitive. The include() and require()
> functions
> try to open the file specified. If you enter the wrong case the file
> system
> will return that the file does not exist.
>
> Albert
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.371 / Virus Database: 267.14.17/226 - Release Date:
> 2006/01/10
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Marco Kaiser