Re: [PHP] page works on public web site, but not on my computer

2009-08-26 Thread Lester Caine
mike bode wrote:
 I have posted the question in another thread a bit down, but only buried
 within the thread, so please excuse me when I ask again.
 
 I want to use some PHP code from a web site
 (http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm), and I am
 following their instruction how to implement it.

Mike it is probably worth pointing out that PHP5.3 has a LOT of changes
that will be flagged with warnings when running PHP5.2 or earlier code.
Since it will be some time (if ever) before the existing code samples
are updated, then switching display_errors off in php.ini will be the
only way of hiding them. This does not help of cause if you ARE trying
to do additional development and these additional error messages get in
the way :(

Certainly some major projects are simply not yet compatible with PHP5.3

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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



Re: [PHP] DOMNode children iteration (was Re: array() returns something weird)

2009-08-26 Thread Szczepan Hołyszewski
Martin Scotta wrote:

 Fatal error: Call to a member function getAttribute() on a non-object in
 testme.php on line *121*

Yes, this is _how_ the unmodified script errors out. It is not shown in the 
output I attached in my previous message because display_errors is Off in my 
php.ini, and the line that sets it to On in my script is commented out.

 I'm using a Apache/2.2.3 (Win32) PHP/5.2.6

I am not using Apache at all. The same error can be seen when I run the script 
directly through php on the command line.

 Is the script correctly? I have removed the  in the loop

I know that iterating a DOMNode's children using firstChild and nextSibling by 
reference causes trouble, thank you. The problem is that it causes trouble 
with objects unrelated to the loop itself, e.g. to variables defined _after_ 
the loop has terminated.

 and the script returns the attached file.

Do you mean it returns what is in the output file _I_ have attached, or did 
_you_ try to attach something? If that is the case, then your attachment 
didn't get through.

 It looks like a bogus bug?

I am certain it _is_ a genuine bug. For example, in PHP when you write:

$foo = array();
echo gettype($foo);

the output should not be NULL, but in my example script (unmodified, with 
iteration by reference) things like this start happening at some point.

Regards,
Szczepan Hołyszewski

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



Re: [PHP] Re: Directory Listing

2009-08-26 Thread Ashley Sheridan
On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote:
 I've been playing about more and now I have the following code:
 
 ?
 error_reporting(E_ALL);
 ini_set('display_errors', true);
 
 function getDirectory($path = '.', $ignore = '') {
 $dirTree = array ();
 $dirTreeTemp = array ();
 $fileDate = array ();
 $ignore[] = '.';
 $ignore[] = '..';
 $dh = @opendir($path);
 while (false !== ($file = readdir($dh))) {
 if (!in_array($file, $ignore)) {
 if (!is_dir($path/$file)) {
 $dirTree[$path][] = $file;
 $fileDate[$file][] = date (d/m/Y,
 filemtime($path/$file));
 } else {
 $dirTreeTemp = getDirectory($path/$file, $ignore);
 if (is_array($dirTreeTemp))$dirTree =
 array_merge($dirTree, $dirTreeTemp, $fileDate);
 }
 }
 }
 closedir($dh);
 return $dirTree;
 }
 
 $ignore = array('.htaccess', 'Thumbs.db', 'index.php');
 $dirTree = getDirectory('.', $ignore);
 getdirectory('.');
 
 echo Gatwick Tender Documents\n;
 
 foreach( $dirTree as $key = $folder ){
echo \n; //Don't need folders as they're shown with the files
foreach( $folder as $file){
echo str_replace(./, , $key) . \t . $file . \t\n; //Pad
 out with a tab for easy import into excel
 
}
 }
 print_r($dirTree); //Just using this for debugging
 ?
 
 
 The output is fine for the paths and filenames but I still can't get
 the dates showing. It's getting the correct date for some but not all.
 I did something else earlier and found that all the dates were
 01/01/1970 but at least there was a date for every file but can't
 remember how I go there!
 
 
 Here is a sample output result:
 
 Gatwick Tender Documents
 
 . 9216_100_REV_V1.0_bound.dwg 
 
 Tender Docs   BAA Works Terms v1.1 (22.05.08).pdf 
 Tender Docs   Contents of Volumes 1 and 2.pdf 
 Tender Docs   Cover Letter and Instructions.doc   
 Tender Docs   Form of Tender.doc  
 
 Tender Docs/Health and Safety Questionnaire   NT Baggage Tender
 Questionaire rev2.xls
 
 BAA Works Terms v1.1 (22.05.08).pdf   29/07/2009  
 
 Contents of Volumes 1 and 2.pdf   29/07/2009  
 
 Cover Letter and Instructions.doc 29/07/2009  
 
 Form of Tender.doc29/07/2009  
 
 Tender Docs/NTB BH Lighting   3J-B-1 PIR.xls  
 Tender Docs/NTB BH Lighting   3J-B-2B PIR.xls 
 Tender Docs/NTB BH Lighting   3J-B-2R PIR.xls 
 Tender Docs/NTB BH Lighting   3J-B-3R PIR.xls 
 Tender Docs/NTB BH Lighting   3J-D PIR.xls
 Tender Docs/NTB BH Lighting   4G-G PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-1B PIR.xls 
 Tender Docs/NTB BH Lighting   4J-B-1R PIR.xls 
 Tender Docs/NTB BH Lighting   4J-B-2B PIR.xls 
 Tender Docs/NTB BH Lighting   4J-B-2R PIR.xls 
 Tender Docs/NTB BH Lighting   4J-B-4 PIR.xls  
 Tender Docs/NTB BH Lighting   5G-G PIR.xls
 
 
 Can anyone shed any light on it?
 I'm about to admit defeat!
 
 Thanks in advance and I'm not being lazy - I really am trying!!! :(
 
 Tom
 

The only time I've ever noticed this problem was on a 32bit system where
the files were above 2GB each. When the files are that size, none of the
information functions seem to work correctly, including the filesize,
date, etc.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



[PHP] PHP5+APACHE 2.2 + Windows 2003 production server

2009-08-26 Thread Andrioli Darvin
Hi all

PHP manual state We do not recommend using a threaded MPM in production
with Apache 2. Use the prefork MPM instead, or use Apache 1. For information
on why, read the related FAQ entry on using Apache2 with a threaded MPM (
http://www.php.net/manual/en/install.windows.apache2.php )
From apache.org the compiled exe you can download it seems compiled against
threaded MPM. Even the all-in-one packages like WAMPSERVER
(http://www.wampserver.com/en/) or XAMPP Light install PHP as Apache module
on threaded MPM Apache
So I'm wondering, is the manual outdated, or should I consider other
configuration to install on my production servers?

Thank you 
Darvin


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



Re: [PHP] Re: Directory Listing

2009-08-26 Thread Tom Chubb
2009/8/26 Ashley Sheridan a...@ashleysheridan.co.uk:
 On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote:
 I've been playing about more and now I have the following code:

 ?
 error_reporting(E_ALL);
 ini_set('display_errors', true);

 function getDirectory($path = '.', $ignore = '') {
     $dirTree = array ();
     $dirTreeTemp = array ();
     $fileDate = array ();
     $ignore[] = '.';
     $ignore[] = '..';
     $dh = @opendir($path);
     while (false !== ($file = readdir($dh))) {
         if (!in_array($file, $ignore)) {
             if (!is_dir($path/$file)) {
                 $dirTree[$path][] = $file;
                 $fileDate[$file][] = date (d/m/Y,
 filemtime($path/$file));
             } else {
                 $dirTreeTemp = getDirectory($path/$file, $ignore);
                 if (is_array($dirTreeTemp))$dirTree =
 array_merge($dirTree, $dirTreeTemp, $fileDate);
             }
         }
     }
     closedir($dh);
     return $dirTree;
 }

 $ignore = array('.htaccess', 'Thumbs.db', 'index.php');
 $dirTree = getDirectory('.', $ignore);
 getdirectory('.');

 echo Gatwick Tender Documents\n;

 foreach( $dirTree as $key = $folder ){
    echo \n; //Don't need folders as they're shown with the files
    foreach( $folder as $file){
        echo str_replace(./, , $key) . \t . $file . \t\n; //Pad
 out with a tab for easy import into excel

    }
 }
 print_r($dirTree); //Just using this for debugging
 ?


 The output is fine for the paths and filenames but I still can't get
 the dates showing. It's getting the correct date for some but not all.
 I did something else earlier and found that all the dates were
 01/01/1970 but at least there was a date for every file but can't
 remember how I go there!


 Here is a sample output result:

 Gatwick Tender Documents

 .     9216_100_REV_V1.0_bound.dwg

 Tender Docs   BAA Works Terms v1.1 (22.05.08).pdf
 Tender Docs   Contents of Volumes 1 and 2.pdf
 Tender Docs   Cover Letter and Instructions.doc
 Tender Docs   Form of Tender.doc

 Tender Docs/Health and Safety Questionnaire   NT Baggage Tender
 Questionaire rev2.xls

 BAA Works Terms v1.1 (22.05.08).pdf   29/07/2009

 Contents of Volumes 1 and 2.pdf       29/07/2009

 Cover Letter and Instructions.doc     29/07/2009

 Form of Tender.doc    29/07/2009

 Tender Docs/NTB BH Lighting   3J-B-1 PIR.xls
 Tender Docs/NTB BH Lighting   3J-B-2B PIR.xls
 Tender Docs/NTB BH Lighting   3J-B-2R PIR.xls
 Tender Docs/NTB BH Lighting   3J-B-3R PIR.xls
 Tender Docs/NTB BH Lighting   3J-D PIR.xls
 Tender Docs/NTB BH Lighting   4G-G PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-1B PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-1R PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-2B PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-2R PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-4 PIR.xls
 Tender Docs/NTB BH Lighting   5G-G PIR.xls


 Can anyone shed any light on it?
 I'm about to admit defeat!

 Thanks in advance and I'm not being lazy - I really am trying!!! :(

 Tom


 The only time I've ever noticed this problem was on a 32bit system where
 the files were above 2GB each. When the files are that size, none of the
 information functions seem to work correctly, including the filesize,
 date, etc.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk





Cheers Ash,
I read that too, but I was getting the error for over 90% of the files
which I know are generally only a few MB.
I've started from scratch again and come up with something that is
easier to deal with but still having one last problem!

?php
error_reporting(E_ALL);
ini_set('display_errors', true);
function directoryToArray($directory, $recursive) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file !=index.php  $file != .  $file != 
..) {
if (is_dir($directory. / . $file)) {
//For Directories
if($recursive) {
$array_items = 
array_merge($array_items,
directoryToArray($directory. / . $file, $recursive));
}
$fullfile = $directory . / . $file;
$array_items[] = 
preg_replace(/\/\//si, /, $fullfile);
} else {
//For Files
$fullfile = $directory . / . $file;
$array_items[] = 
preg_replace(/\/\//si, /, $fullfile);
}
}
}
closedir($handle);
}
return $array_items;
}

$files = directoryToArray(./Tender, true);


//Output to browser
foreach ($files as $file) {
echo str_replace(./Tender, , $file) . \t .. date 
(d/m/Y,
filemtime($file)) . \n;

RE: [PHP] DOMNode children iteration (was Re: array() returns something weird)

2009-08-26 Thread Ford, Mike
 -Original Message-
 From: Szczepan Hołyszewski [mailto:webmas...@strefarytmu.pl]
 Sent: 26 August 2009 08:48
 
 Martin Scotta wrote:
 
  Fatal error: Call to a member function getAttribute() on a non-
 object in
  testme.php on line *121*
 
 Yes, this is _how_ the unmodified script errors out. It is not shown
 in the
 output I attached in my previous message because display_errors is
 Off in my
 php.ini, and the line that sets it to On in my script is commented
 out.
 
  I'm using a Apache/2.2.3 (Win32) PHP/5.2.6
 
 I am not using Apache at all. The same error can be seen when I run
 the script
 directly through php on the command line.
 
  Is the script correctly? I have removed the  in the loop

I really can't see why you'd want to use references in the posted loop anyway 
-- it's not likely to gain you any performance, and, as I understand it, may 
actually run more slowly than the non-reference version.
 
 I know that iterating a DOMNode's children using firstChild and
 nextSibling by
 reference causes trouble, thank you. The problem is that it causes
 trouble
 with objects unrelated to the loop itself, e.g. to variables defined
 _after_
 the loop has terminated.

I don't think it's possible to answer this for sure without seeing more of the 
code -- at least the complete body of the loop, plus as far as any further use 
of the variable $child (and any other variables assigned from it).


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


Re: [PHP] Re: Directory Listing

2009-08-26 Thread Ashley Sheridan
On Wed, 2009-08-26 at 09:50 +0100, Tom Chubb wrote:
 2009/8/26 Ashley Sheridan a...@ashleysheridan.co.uk:
  On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote:
  I've been playing about more and now I have the following code:
 
  ?
  error_reporting(E_ALL);
  ini_set('display_errors', true);
 
  function getDirectory($path = '.', $ignore = '') {
  $dirTree = array ();
  $dirTreeTemp = array ();
  $fileDate = array ();
  $ignore[] = '.';
  $ignore[] = '..';
  $dh = @opendir($path);
  while (false !== ($file = readdir($dh))) {
  if (!in_array($file, $ignore)) {
  if (!is_dir($path/$file)) {
  $dirTree[$path][] = $file;
  $fileDate[$file][] = date (d/m/Y,
  filemtime($path/$file));
  } else {
  $dirTreeTemp = getDirectory($path/$file, $ignore);
  if (is_array($dirTreeTemp))$dirTree =
  array_merge($dirTree, $dirTreeTemp, $fileDate);
  }
  }
  }
  closedir($dh);
  return $dirTree;
  }
 
  $ignore = array('.htaccess', 'Thumbs.db', 'index.php');
  $dirTree = getDirectory('.', $ignore);
  getdirectory('.');
 
  echo Gatwick Tender Documents\n;
 
  foreach( $dirTree as $key = $folder ){
 echo \n; //Don't need folders as they're shown with the files
 foreach( $folder as $file){
 echo str_replace(./, , $key) . \t . $file . \t\n; //Pad
  out with a tab for easy import into excel
 
 }
  }
  print_r($dirTree); //Just using this for debugging
  ?
 
 
  The output is fine for the paths and filenames but I still can't get
  the dates showing. It's getting the correct date for some but not all.
  I did something else earlier and found that all the dates were
  01/01/1970 but at least there was a date for every file but can't
  remember how I go there!
 
 
  Here is a sample output result:
 
  Gatwick Tender Documents
 
  . 9216_100_REV_V1.0_bound.dwg
 
  Tender Docs   BAA Works Terms v1.1 (22.05.08).pdf
  Tender Docs   Contents of Volumes 1 and 2.pdf
  Tender Docs   Cover Letter and Instructions.doc
  Tender Docs   Form of Tender.doc
 
  Tender Docs/Health and Safety Questionnaire   NT Baggage Tender
  Questionaire rev2.xls
 
  BAA Works Terms v1.1 (22.05.08).pdf   29/07/2009
 
  Contents of Volumes 1 and 2.pdf   29/07/2009
 
  Cover Letter and Instructions.doc 29/07/2009
 
  Form of Tender.doc29/07/2009
 
  Tender Docs/NTB BH Lighting   3J-B-1 PIR.xls
  Tender Docs/NTB BH Lighting   3J-B-2B PIR.xls
  Tender Docs/NTB BH Lighting   3J-B-2R PIR.xls
  Tender Docs/NTB BH Lighting   3J-B-3R PIR.xls
  Tender Docs/NTB BH Lighting   3J-D PIR.xls
  Tender Docs/NTB BH Lighting   4G-G PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-1B PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-1R PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-2B PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-2R PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-4 PIR.xls
  Tender Docs/NTB BH Lighting   5G-G PIR.xls
 
 
  Can anyone shed any light on it?
  I'm about to admit defeat!
 
  Thanks in advance and I'm not being lazy - I really am trying!!! :(
 
  Tom
 
 
  The only time I've ever noticed this problem was on a 32bit system where
  the files were above 2GB each. When the files are that size, none of the
  information functions seem to work correctly, including the filesize,
  date, etc.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 
 
 Cheers Ash,
 I read that too, but I was getting the error for over 90% of the files
 which I know are generally only a few MB.
 I've started from scratch again and come up with something that is
 easier to deal with but still having one last problem!
 
 ?php
 error_reporting(E_ALL);
 ini_set('display_errors', true);
 function directoryToArray($directory, $recursive) {
   $array_items = array();
   if ($handle = opendir($directory)) {
   while (false !== ($file = readdir($handle))) {
   if ($file !=index.php  $file != .  $file != 
 ..) {
   if (is_dir($directory. / . $file)) {
   //For Directories
   if($recursive) {
   $array_items = 
 array_merge($array_items,
 directoryToArray($directory. / . $file, $recursive));
   }
   $fullfile = $directory . / . $file;
   $array_items[] = 
 preg_replace(/\/\//si, /, $fullfile);
   } else {
   //For Files
   $fullfile = $directory . / . $file;
   $array_items[] = 
 preg_replace(/\/\//si, /, $fullfile);
   }
   }
   }
   closedir($handle);
   }
   return $array_items;
 }
 
 $files = 

Re: [PHP] DOMNode children iteration (was Re: array() returns something weird)

2009-08-26 Thread Szczepan Hołyszewski
 I really can't see why you'd want to use references in the posted
 loop anyway -- it's not likely to gain you any performance, and, as
 I understand it, may actually run more slowly than the
 non-reference version.

The why is irrelevant. It is perfectly legal PHP, and while it might be 
illegal usage of DOMNode, it should only break the DOMNode, and not PHP 
execution environment.

 I don't think it's possible to answer this for sure without seeing more of
 the code -- at least the complete body of the loop, plus as far as any
 further use of the variable $child (and any other variables assigned from
 it).

OK, I modified the example to show the problem _very_ directly. I commented out 
the recursion-tracing echos, and added this code in renderObject() below the 
if() that chooses between the good and evil loop, which means that the added 
code is always executed immediately after the loop:

$x=array();
$y=y;
$z=1;
var_dump($xy,$y,$z);
echo \n;

Note that these variables:

 - are first defined at this point
 - are initialized immediately
 - are initialized with immediate data (empty array and two scalars), not
   with results of prior computation
 - are never used or changed except for being dumped
 - don't get any references to them created

Therefore one must expect that var_dump will always dump this:

array(0) { 
}  
string(1) y  
int(1)

However it sometimes dumps this:

NULL   
NULL   
NULL

Best regards,
Szczepan Holyszewski
attachment: testme.php
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Re: Directory Listing

2009-08-26 Thread Tom Chubb
2009/8/26 Ashley Sheridan a...@ashleysheridan.co.uk:
 On Wed, 2009-08-26 at 09:50 +0100, Tom Chubb wrote:
 2009/8/26 Ashley Sheridan a...@ashleysheridan.co.uk:
  On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote:
  I've been playing about more and now I have the following code:
 
  ?
  error_reporting(E_ALL);
  ini_set('display_errors', true);
 
  function getDirectory($path = '.', $ignore = '') {
      $dirTree = array ();
      $dirTreeTemp = array ();
      $fileDate = array ();
      $ignore[] = '.';
      $ignore[] = '..';
      $dh = @opendir($path);
      while (false !== ($file = readdir($dh))) {
          if (!in_array($file, $ignore)) {
              if (!is_dir($path/$file)) {
                  $dirTree[$path][] = $file;
                  $fileDate[$file][] = date (d/m/Y,
  filemtime($path/$file));
              } else {
                  $dirTreeTemp = getDirectory($path/$file, $ignore);
                  if (is_array($dirTreeTemp))$dirTree =
  array_merge($dirTree, $dirTreeTemp, $fileDate);
              }
          }
      }
      closedir($dh);
      return $dirTree;
  }
 
  $ignore = array('.htaccess', 'Thumbs.db', 'index.php');
  $dirTree = getDirectory('.', $ignore);
  getdirectory('.');
 
  echo Gatwick Tender Documents\n;
 
  foreach( $dirTree as $key = $folder ){
     echo \n; //Don't need folders as they're shown with the files
     foreach( $folder as $file){
         echo str_replace(./, , $key) . \t . $file . \t\n; //Pad
  out with a tab for easy import into excel
 
     }
  }
  print_r($dirTree); //Just using this for debugging
  ?
 
 
  The output is fine for the paths and filenames but I still can't get
  the dates showing. It's getting the correct date for some but not all.
  I did something else earlier and found that all the dates were
  01/01/1970 but at least there was a date for every file but can't
  remember how I go there!
 
 
  Here is a sample output result:
 
  Gatwick Tender Documents
 
  .     9216_100_REV_V1.0_bound.dwg
 
  Tender Docs   BAA Works Terms v1.1 (22.05.08).pdf
  Tender Docs   Contents of Volumes 1 and 2.pdf
  Tender Docs   Cover Letter and Instructions.doc
  Tender Docs   Form of Tender.doc
 
  Tender Docs/Health and Safety Questionnaire   NT Baggage Tender
  Questionaire rev2.xls
 
  BAA Works Terms v1.1 (22.05.08).pdf   29/07/2009
 
  Contents of Volumes 1 and 2.pdf       29/07/2009
 
  Cover Letter and Instructions.doc     29/07/2009
 
  Form of Tender.doc    29/07/2009
 
  Tender Docs/NTB BH Lighting   3J-B-1 PIR.xls
  Tender Docs/NTB BH Lighting   3J-B-2B PIR.xls
  Tender Docs/NTB BH Lighting   3J-B-2R PIR.xls
  Tender Docs/NTB BH Lighting   3J-B-3R PIR.xls
  Tender Docs/NTB BH Lighting   3J-D PIR.xls
  Tender Docs/NTB BH Lighting   4G-G PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-1B PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-1R PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-2B PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-2R PIR.xls
  Tender Docs/NTB BH Lighting   4J-B-4 PIR.xls
  Tender Docs/NTB BH Lighting   5G-G PIR.xls
 
 
  Can anyone shed any light on it?
  I'm about to admit defeat!
 
  Thanks in advance and I'm not being lazy - I really am trying!!! :(
 
  Tom
 
 
  The only time I've ever noticed this problem was on a 32bit system where
  the files were above 2GB each. When the files are that size, none of the
  information functions seem to work correctly, including the filesize,
  date, etc.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 

 Cheers Ash,
 I read that too, but I was getting the error for over 90% of the files
 which I know are generally only a few MB.
 I've started from scratch again and come up with something that is
 easier to deal with but still having one last problem!

 ?php
 error_reporting(E_ALL);
 ini_set('display_errors', true);
 function directoryToArray($directory, $recursive) {
       $array_items = array();
       if ($handle = opendir($directory)) {
               while (false !== ($file = readdir($handle))) {
                       if ($file !=index.php  $file != .  $file != 
 ..) {
                               if (is_dir($directory. / . $file)) {
                                       //For Directories
                                       if($recursive) {
                                               $array_items = 
 array_merge($array_items,
 directoryToArray($directory. / . $file, $recursive));
                                       }
                                       $fullfile = $directory . / . $file;
                                       $array_items[] = 
 preg_replace(/\/\//si, /, $fullfile);
                               } else {
                                       //For Files
                                       $fullfile = $directory . / . $file;
                                       $array_items[] = 
 preg_replace(/\/\//si, /, $fullfile);
                               }
                       }
               }
               closedir($handle);
       }
       

Re: [PHP] Re: Directory Listing

2009-08-26 Thread hack988 hack988
have a tab inserted in the middle of the path ??? What it mean,I
can't find any diffrent between last one with other rows.

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



Re: [PHP] Re: Directory Listing

2009-08-26 Thread Ashley Sheridan
On Wed, 2009-08-26 at 18:21 +0800, hack988 hack988 wrote:
 have a tab inserted in the middle of the path ??? What it mean,I
 can't find any diffrent between last one with other rows.
 
It might be because of the way that the mailing list software converts
the content?

I tend to always make CSV files comma delimited, as it's easier on the
eye to open a file up in a ext editor and hack away at it, and you have
the benefit of being able to use other whitespace characters (tabs,
spaces, etc) to line up field data (although field values should really
be enclosed in quotation marks if you go down this route just in-case)

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



Re: [PHP] Re: Directory Listing

2009-08-26 Thread Tom Chubb
2009/8/26 hack988 hack988 hack...@dev.htwap.com:
 have a tab inserted in the middle of the path ??? What it mean,I
 can't find any diffrent between last one with other rows.


To clarify - this is what I was getting:

/tab here9216_100_REV_V1.0_bound.dwgtab here05/08/2009
/Tender Docs/tab hereBAA Works Terms v1.1 (22.05.08).pdftab
here29/07/2009
/Tender Docs/UNWANTED TAB HEREHealth and Safety Questionnaire 14/08/2009

-- 
Tom Chubb
t...@tomchubb.com | tomch...@gmail.com
07912 202846

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



Re: [PHP] Re: Directory Listing

2009-08-26 Thread Tom Chubb
2009/8/26 Ashley Sheridan a...@ashleysheridan.co.uk:
 On Wed, 2009-08-26 at 18:21 +0800, hack988 hack988 wrote:
 have a tab inserted in the middle of the path ??? What it mean,I
 can't find any diffrent between last one with other rows.

 It might be because of the way that the mailing list software converts
 the content?

 I tend to always make CSV files comma delimited, as it's easier on the
 eye to open a file up in a ext editor and hack away at it, and you have
 the benefit of being able to use other whitespace characters (tabs,
 spaces, etc) to line up field data (although field values should really
 be enclosed in quotation marks if you go down this route just in-case)

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk





Thanks Ash,
I've learnt quite a lot trying to get this working!
And yeah I think I might change it to csv now.

-- 
Tom Chubb
t...@tomchubb.com | tomch...@gmail.com
07912 202846

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



Re: [PHP] Can't find the server path when, in http.conf, using Alias and DirectoryIndex

2009-08-26 Thread Paul Gardiner

Paul Gardiner wrote:

I want to write a simple indexing script to display a
directory full of photos as a gallery of thumbnails.
(There are various solutions out there for this, but
they're all a bit more complicated than I need).

I've added a file in /etc/apache2/conf.d that
looks like this:

Alias /photos /home/public/photos
Directory /home/public/photos
AllowOverride None
Order allow,deny
Allow from all

DirectoryIndex /cgi-bin/index.php
/Directory


I use Alias so that I can leave the photos where they are
and not have to move them to DocumentRoot. I use DirectoryIndex
so that the script doesn't have to be in with the photos. My
problem is that the running script seems to have no way to
work out the photos are in /home/public/photos.

$_SERVER[REQUEST_URI] is /photos/, but I can't see how to
derive the server path from that, since $_SERVER[DOCUMENT_ROOT]
is /srv/www/htdocs.

$_SERVER[PHP_SELF] is /cgi-bin/index.php, so no use either.


How can I do this? Is there a way to interrogate the alias,
or can I set a variable in the conf file that PHP can pick up?


I've sussed it. If I use this apache2 conf file, where I
tag the server path onto the end of the index url:

Alias /photos /home/public/photos
Directory /home/public/photos
AllowOverride None
Order allow,deny
Allow from all

DirectoryIndex /cgi-bin/index.php/home/public/photos
/Directory

then the script can pick up the path as $_SERVER[PATH_INFO]

P.


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



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
Paul,

This all started because when I try this:

?php echo $rs-Fields(22);?

It work fine, as long as there is a non-null value there, otherwise it
produces an error.

Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
sure if that matters

But echo $rs-Fields(22) works perfectly for dumping values out of my
$rs recordset...that is, unless the value is NULL is the database - then
I get:

Catchable fatal error: Object of class variant could not be converted to
string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176


-Original Message-
From: Paul M Foster [mailto:pa...@quillandmouse.com] 
Sent: Tuesday, August 25, 2009 4:39 PM
To: php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

 $rs-Fields(22) equals a NULL in the database
 
 My Code:
 
 if(empty($rs-Fields(22))){
   $q4 = ;
 }else{
   $q4 = $rs-Fields(22);
 }
 
 Produces this error:
 Fatal error: Can't use method return value in write context in
 D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32
 
 Line 32 is the if line...
 
 If I switch the code to (using is_null):
 if(is_null($rs-Fields(22))){
   $q4 = ;
 }else{
   $q4 = $rs-Fields(22);
 }
 
 It produces this error:
 Catchable fatal error: Object of class variant could not be converted
to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196
 
 Line 196 is: ?php echo $q4;?
 
 What am I doing wrong?
 
 Thanks!

Just a thought... do you really mean $rs-Fields(22) or do you mean
$rs-Fields[22]? The former is a function call and the latter is an
array variable.

Paul

-- 
Paul M. Foster

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


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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread hack988 hack988
use is_null() check it

2009/8/26 David Stoltz dsto...@shh.org:
 Paul,

 This all started because when I try this:

 ?php echo $rs-Fields(22);?

 It work fine, as long as there is a non-null value there, otherwise it
 produces an error.

 Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
 sure if that matters

 But echo $rs-Fields(22) works perfectly for dumping values out of my
 $rs recordset...that is, unless the value is NULL is the database - then
 I get:

 Catchable fatal error: Object of class variant could not be converted to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176


 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: Tuesday, August 25, 2009 4:39 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

 $rs-Fields(22) equals a NULL in the database

 My Code:

 if(empty($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 Produces this error:
 Fatal error: Can't use method return value in write context in
 D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32

 Line 32 is the if line...

 If I switch the code to (using is_null):
 if(is_null($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 It produces this error:
 Catchable fatal error: Object of class variant could not be converted
 to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196

 Line 196 is: ?php echo $q4;?

 What am I doing wrong?

 Thanks!

 Just a thought... do you really mean $rs-Fields(22) or do you mean
 $rs-Fields[22]? The former is a function call and the latter is an
 array variable.

 Paul

 --
 Paul M. Foster

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
I tried that -it's in the first part of my message


-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
Sent: Wednesday, August 26, 2009 7:39 AM
To: David Stoltz
Cc: Paul M Foster; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

use is_null() check it

2009/8/26 David Stoltz dsto...@shh.org:
 Paul,

 This all started because when I try this:

 ?php echo $rs-Fields(22);?

 It work fine, as long as there is a non-null value there, otherwise it
 produces an error.

 Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
 sure if that matters

 But echo $rs-Fields(22) works perfectly for dumping values out of my
 $rs recordset...that is, unless the value is NULL is the database - then
 I get:

 Catchable fatal error: Object of class variant could not be converted to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176


 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: Tuesday, August 25, 2009 4:39 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

 $rs-Fields(22) equals a NULL in the database

 My Code:

 if(empty($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 Produces this error:
 Fatal error: Can't use method return value in write context in
 D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32

 Line 32 is the if line...

 If I switch the code to (using is_null):
 if(is_null($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 It produces this error:
 Catchable fatal error: Object of class variant could not be converted
 to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196

 Line 196 is: ?php echo $q4;?

 What am I doing wrong?

 Thanks!

 Just a thought... do you really mean $rs-Fields(22) or do you mean
 $rs-Fields[22]? The former is a function call and the latter is an
 array variable.

 Paul

 --
 Paul M. Foster

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to output a NULL field?

2009-08-26 Thread hack988 hack988
Could you post your database's class to here?
I'm use mssql with php for several years and read NULL Fields is never
appear your case.

2009/8/26 David Stoltz dsto...@shh.org:
 I tried that -it's in the first part of my message


 -Original Message-
 From: hack988 hack988 [mailto:hack...@dev.htwap.com]
 Sent: Wednesday, August 26, 2009 7:39 AM
 To: David Stoltz
 Cc: Paul M Foster; php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 use is_null() check it

 2009/8/26 David Stoltz dsto...@shh.org:
 Paul,

 This all started because when I try this:

 ?php echo $rs-Fields(22);?

 It work fine, as long as there is a non-null value there, otherwise it
 produces an error.

 Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
 sure if that matters

 But echo $rs-Fields(22) works perfectly for dumping values out of my
 $rs recordset...that is, unless the value is NULL is the database - then
 I get:

 Catchable fatal error: Object of class variant could not be converted to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176


 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: Tuesday, August 25, 2009 4:39 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

 $rs-Fields(22) equals a NULL in the database

 My Code:

 if(empty($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 Produces this error:
 Fatal error: Can't use method return value in write context in
 D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32

 Line 32 is the if line...

 If I switch the code to (using is_null):
 if(is_null($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 It produces this error:
 Catchable fatal error: Object of class variant could not be converted
 to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196

 Line 196 is: ?php echo $q4;?

 What am I doing wrong?

 Thanks!

 Just a thought... do you really mean $rs-Fields(22) or do you mean
 $rs-Fields[22]? The former is a function call and the latter is an
 array variable.

 Paul

 --
 Paul M. Foster

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Directory Listing

2009-08-26 Thread hack988 hack988
your means Health and Safety Questionnaireis directory?
so you want it display like this
full dir path tab filenametabdate

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



RE: [PHP] How to output a NULL field?

2009-08-26 Thread TG
Sorry, didn't follow this whole thread but have you tried print_r() or 
var_dump() to see what it looks like when it's type variant?  I'd be 
curious to see what you'd find in it.

Also, I forget about SQL Server, but MySQL has a function ifnull() which 
can make sure you never return a null value.  This is also handy for 
checking for empty fields where you don't know if it's going to be an 
empty string or a null:

SELECT * FROM table WHERE ifnull(somefield, '') = ''

If you know which columns are nullable, try seeing if there's an ifnull() 
function in SQL Server to adjust the data before it even gets to your DB 
class.

-TG

- Original Message -
From: David Stoltz dsto...@shh.org
To: Paul M Foster pa...@quillandmouse.com, php-general@lists.php.net
Date: Wed, 26 Aug 2009 07:29:53 -0400
Subject: RE: [PHP] How to output a NULL field?

 Paul,
 
 This all started because when I try this:
 
 ?php echo $rs-Fields(22);?
 
 It work fine, as long as there is a non-null value there, otherwise it
 produces an error.
 
 Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
 sure if that matters
 
 But echo $rs-Fields(22) works perfectly for dumping values out of my
 $rs recordset...that is, unless the value is NULL is the database - then
 I get:
 
 Catchable fatal error: Object of class variant could not be converted to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176
 
 
 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com] 
 Sent: Tuesday, August 25, 2009 4:39 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?
 
 On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:
 
  $rs-Fields(22) equals a NULL in the database
  
  My Code:
  
  if(empty($rs-Fields(22))){
  $q4 = ;
  }else{
  $q4 = $rs-Fields(22);
  }
  
  Produces this error:
  Fatal error: Can't use method return value in write context in
  D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32
  
  Line 32 is the if line...
  
  If I switch the code to (using is_null):
  if(is_null($rs-Fields(22))){
  $q4 = ;
  }else{
  $q4 = $rs-Fields(22);
  }
  
  It produces this error:
  Catchable fatal error: Object of class variant could not be converted
 to
  string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196
  
  Line 196 is: ?php echo $q4;?
  
  What am I doing wrong?
  
  Thanks!
 
 Just a thought... do you really mean $rs-Fields(22) or do you mean
 $rs-Fields[22]? The former is a function call and the latter is an
 array variable.
 
 Paul
 
 -- 
 Paul M. Foster
 


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



Re: [PHP] Re: Directory Listing

2009-08-26 Thread Tom Chubb
2009/8/26 hack988 hack988 hack...@dev.htwap.com:
 your means Health and Safety Questionnaireis directory?
 so you want it display like this
 full dir path tab filenametabdate


Yes.
I did try using if(is_dir($file)) { insert tab } but couldn't get it to work.
Also tried counting the length of the $file value and and comparing it
to the position of the first / using strpos and if they matched then
assume it was a directory but couldn't get it to work either.

Out of the 2000 files there are less than 50 directories so it wasn't
too much trouble to go through and sort them out manually but I'd love
to hear a way of doing it properly

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



RE: [PHP] Re: page works on public web site, but not on my computer

2009-08-26 Thread Bob McConnell
I recommend you start by replacing Vista. There are so many problems
with it that Microsoft is rushing to ship a replacement as soon as
possible. It remains to be seen whether Windows 7 is a real fix or
merely more of the same problems.

I am not aware of any serious developers writing code specifically for
Vista. We only test our products on it enough to decide if we will
support each product on that OS. If they don't work out of the box, we
don't support them nor recommend our clients install them on Vista.
There are no copies of Vista installed in the company outside of the ESX
servers used for testing.

I would recommend Red Hat as the replacement.

Bob McConnell

-Original Message-
From: mike bode [mailto:mikebo...@hotmail.com] 
Sent: Tuesday, August 25, 2009 11:41 PM
To: php-general@lists.php.net
Subject: [PHP] Re: page works on public web site, but not on my computer

I just de-installed, then re-installed MySQL, Apache and PHP 5.3. No 
changes. The script does not work on my computer.

Now I get in addition to the error message below this:

[Tue Aug 25 21:29:11 2009] [error] [client 127.0.0.1] PHP Deprecated: 
Function eregi() is deprecated in
C:\\webdev\\rmv3\\album\\getalbumpics.php 
on line 11, referer: http://localhost/album.php

Don't know if those warnings would stop the execution of the php script.


mike bode mikebo...@hotmail.com wrote in message 
news:99.f2.08117.ccf74...@pb1.pair.com...
I have posted the question in another thread a bit down, but only
buried 
within the thread, so please excuse me when I ask again.

 I want to use some PHP code from a web site 
 (http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm), and I
am 
 following their instruction how to implement it. I was not able to get
it 
 to work. Then I uploaded the code to a server, and lo and behold, it
does 
 work on the server. On the public site you see thumbnails of images
(never 
 mind the junk above them), when I run the SAME html and php code on my

 omputer, I get a blank white page.

 The error log has several entries, but they are all warnings:

 [Tue Aug 25 18:12:00 2009] [error] [client 127.0.0.1] PHP Warning: 
 date(): It is not safe to rely on the system's timezone settings. You
are 
 *required* to use the date.timezone setting or the 
 date_default_timezone_set() function. In case you used any of those 
 methods and you are still getting this warning, you most likely
misspelled 
 the timezone identifier. We selected 'America/Denver' for '-6.0/DST' 
 instead in C:\\webdev\\rmv3\\album\\getalbumpics.php on line 11,
referer: 
 http://localhost/album.htm

 (this error is repeated for as many images I have in the directory
that 
 the php script is reading).

 Between php.ini, httpd.conf, and Windows Vista, I can't figure out
where 
 to start to diagnose this, and how. Anybody out there who can give me
a 
 pointer on how to roubleshoot this issue? I am almost ready to throw
in 
 the towel and either start from scratch (although this is alrady the 
 second time that I have uninstalled and re-installed everything), or 
 simply forget about php altogether. that would be a shame, though... 


-- 
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: PHP5+APACHE 2.2 + Windows 2003 production server

2009-08-26 Thread Shawn McKenzie
Andrioli Darvin wrote:
 Hi all
 
 PHP manual state We do not recommend using a threaded MPM in production
 with Apache 2. Use the prefork MPM instead, or use Apache 1. For information
 on why, read the related FAQ entry on using Apache2 with a threaded MPM (
 http://www.php.net/manual/en/install.windows.apache2.php )
 From apache.org the compiled exe you can download it seems compiled against
 threaded MPM. Even the all-in-one packages like WAMPSERVER
 (http://www.wampserver.com/en/) or XAMPP Light install PHP as Apache module
 on threaded MPM Apache
 So I'm wondering, is the manual outdated, or should I consider other
 configuration to install on my production servers?
 
 Thank you 
 Darvin
 

Also from the FAQ: And finally, this warning against using a threaded
MPM is not as strong for Windows systems because most libraries on that
platform tend to be threadsafe.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



RE: [PHP] Re: page works on public web site, but not on my computer

2009-08-26 Thread Ashley Sheridan
On Wed, 2009-08-26 at 08:27 -0400, Bob McConnell wrote:
 I recommend you start by replacing Vista. There are so many problems
 with it that Microsoft is rushing to ship a replacement as soon as
 possible. It remains to be seen whether Windows 7 is a real fix or
 merely more of the same problems.
 
 I am not aware of any serious developers writing code specifically for
 Vista. We only test our products on it enough to decide if we will
 support each product on that OS. If they don't work out of the box, we
 don't support them nor recommend our clients install them on Vista.
 There are no copies of Vista installed in the company outside of the ESX
 servers used for testing.
 
 I would recommend Red Hat as the replacement.
 
 Bob McConnell
 
 -Original Message-
 From: mike bode [mailto:mikebo...@hotmail.com] 
 Sent: Tuesday, August 25, 2009 11:41 PM
 To: php-general@lists.php.net
 Subject: [PHP] Re: page works on public web site, but not on my computer
 
 I just de-installed, then re-installed MySQL, Apache and PHP 5.3. No 
 changes. The script does not work on my computer.
 
 Now I get in addition to the error message below this:
 
 [Tue Aug 25 21:29:11 2009] [error] [client 127.0.0.1] PHP Deprecated: 
 Function eregi() is deprecated in
 C:\\webdev\\rmv3\\album\\getalbumpics.php 
 on line 11, referer: http://localhost/album.php
 
 Don't know if those warnings would stop the execution of the php script.
 
 
 mike bode mikebo...@hotmail.com wrote in message 
 news:99.f2.08117.ccf74...@pb1.pair.com...
 I have posted the question in another thread a bit down, but only
 buried 
 within the thread, so please excuse me when I ask again.
 
  I want to use some PHP code from a web site 
  (http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm), and I
 am 
  following their instruction how to implement it. I was not able to get
 it 
  to work. Then I uploaded the code to a server, and lo and behold, it
 does 
  work on the server. On the public site you see thumbnails of images
 (never 
  mind the junk above them), when I run the SAME html and php code on my
 
  omputer, I get a blank white page.
 
  The error log has several entries, but they are all warnings:
 
  [Tue Aug 25 18:12:00 2009] [error] [client 127.0.0.1] PHP Warning: 
  date(): It is not safe to rely on the system's timezone settings. You
 are 
  *required* to use the date.timezone setting or the 
  date_default_timezone_set() function. In case you used any of those 
  methods and you are still getting this warning, you most likely
 misspelled 
  the timezone identifier. We selected 'America/Denver' for '-6.0/DST' 
  instead in C:\\webdev\\rmv3\\album\\getalbumpics.php on line 11,
 referer: 
  http://localhost/album.htm
 
  (this error is repeated for as many images I have in the directory
 that 
  the php script is reading).
 
  Between php.ini, httpd.conf, and Windows Vista, I can't figure out
 where 
  to start to diagnose this, and how. Anybody out there who can give me
 a 
  pointer on how to roubleshoot this issue? I am almost ready to throw
 in 
  the towel and either start from scratch (although this is alrady the 
  second time that I have uninstalled and re-installed everything), or 
  simply forget about php altogether. that would be a shame, though... 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
I'll second that. I don't use Windows myself anymore for anything except
World of Warcraft, but my little time spent using Vista has left me
wanting to do violence! You can't go too wrong with using a Linux OS as
your development server, as that is what is in use on the majority of
the worlds web servers anyway. I've also not yet seen any PHP apps which
will only work on Windows, and I believe that most of the modules that
are in mainstream use at the moment are available on Linux (and more
than likely were available to that platform before Windows) and in a lot
of cases perform better.

Also, having a good bit of Linux experience under your belt can work
wonders on your CV!

RedHat is good for this sort of thing, or Fedora if you intend to use it
as your desktop machine also (as they are pretty much the same, but
Fedora is where new features, etc are seen first out of the two. Suse
isn't bad, and has some good Windows network integration (for things
like Active Directory) if you are using it as a work desktop machine as
well as a development server.



Thanks,
Ash
http://www.ashleysheridan.co.uk




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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Stuart
2009/8/26 David Stoltz dsto...@shh.org:
 Paul,

 This all started because when I try this:

 ?php echo $rs-Fields(22);?

 It work fine, as long as there is a non-null value there, otherwise it
 produces an error.

 Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
 sure if that matters

 But echo $rs-Fields(22) works perfectly for dumping values out of my
 $rs recordset...that is, unless the value is NULL is the database - then
 I get:

 Catchable fatal error: Object of class variant could not be converted to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176

That error indicates that you're not getting NULL since NULL is easily
converted to a string.

Try this...

$var = $rs-Fields(22);
var_dump($var);

...and tell us what you get.

-Stuart

-- 
http://stut.net/

 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: Tuesday, August 25, 2009 4:39 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

 $rs-Fields(22) equals a NULL in the database

 My Code:

 if(empty($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 Produces this error:
 Fatal error: Can't use method return value in write context in
 D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32

 Line 32 is the if line...

 If I switch the code to (using is_null):
 if(is_null($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 It produces this error:
 Catchable fatal error: Object of class variant could not be converted
 to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196

 Line 196 is: ?php echo $q4;?

 What am I doing wrong?

 Thanks!

 Just a thought... do you really mean $rs-Fields(22) or do you mean
 $rs-Fields[22]? The former is a function call and the latter is an
 array variable.

 Paul

 --
 Paul M. Foster

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread tedd

At 11:34 PM +0100 8/25/09, Stuart wrote:

2009/8/25 tedd tedd.sperl...@gmail.com:

  I can't believe that you are wasting time on this. This guy is beyond

 clueless.


To be fair tedd English is clearly not his main language and I can see
how you could misunderstand the original question as he did. What I
objected to was that he took what he interpreted as the question being
asked, saw that it did in fact behave that way and then proceeded to
completely fabricate an explanation as to why it does so when that
explanation does little more than demonstrate that he clearly has no
understanding of what's actually going on. I can't stand people who
claim to know what they're talking about when they're really making it
up as they go along.

Actually, an explanation like that does do a lot more than demonstrate
ignorance. It gives naive observers of this thread, now and in the
future, incorrect information that they may potentially rely upon if
nobody corrects it. That's why I'm wasting my time on this - I do it
for the greater good.

Hmm, maybe I just need a holiday...

-Stuart

--
http://stut.net/


-Stuart:

I understand the language problem and how someone might use incorrect 
diction when speaking/writing English, but php is not English 
dependant.


When someone says that unset(); does not work and provides an example 
that clearly demonstrates they don't know how to use it, then I throw 
up my hands and say RFTM in whatever language it's available. So, I 
wasn't objecting to the OP original statement but rather his proof 
that unset() wasn't working. You and I are objecting to the same 
thing.


My hat is off to you for contributing to the greater good, but your 
efforts might be better spent attending to the needs of higher level 
idiots (like myself) and let us middle level idiots attend to the 
idiots, if you get my drift. :-)


My comment is only a suggestion for you to consider. From my 
perspective, I hate to see such a valuable resource as yourself 
wasted on the clueless.


And, we all need a holiday...

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread Stuart
2009/8/26 Ralph Deffke ralph_def...@yahoo.de:
 sorry I mixed 'set' with 'given' and if my mistake did prevent all the
 smarter guys to give u an answer I'm sorry too.

 I hope not to be too limited to give u an answer

 well, think about how PHP 5 works.
 $a e.g. is a REFENCE to some memory where the variable resides.

 so the interpreter running into this unset() statement searches the
 reference table to find the pointer named $a to delete its name from the
 reference table. it doesn't find it, but it's ment to unset it anyway, why
 should be complained about it. in the next line the $a is not set, as u want
 it.

 mmmh nice as well that nobody told me direcly that I mixed set with given

Excuse me? I told you as soon as I knew that's why you were getting it so wrong.

 ps.: great behavior, I think for less then 10% of the world population is
 english the native language, such a behavior prevents very good and smart
 programmers arround the world to share their knowledge.

I actually think it's perfectly reasonable to expect people
contributing to this mailing list to have a good grasp of the English
language... at least enough not to make errors like the one you have
here. I understand how rude it can appear but I think it's important
that information resources such as this are as reliable as possible,
and if that means you need to be a bit more careful about asserting
your expertise when there's a chance that you've misunderstood the
question. I see no difference between misunderstanding due to language
issues and misunderstanding due to having not read the question
correctly. They both have the same effect.

Maybe I'm being too harsh. I'm sure you have a lot of knowledge to
share, but if you want to participate in what is an English mailing
list please be more careful in future.

Now, on to my real problem with the way you answered the question.
After your initial mistake you proceeded to, as far as I can tell,
completely fabricate a reason for the behaviour you were seeing with
absolutely nothing to back it up whatsoever. And then, despite being
corrected you repeated it. That's what I really objected to - anyone
can misunderstand a question, but filling in the blanks from thin air
helps nobody. Ever.

And that's all I've got to say about that. Now, about that holiday...

-Stuart

-- 
http://stut.net/

 Tom Worster f...@thefsb.org wrote in message
 news:c6b93df9.114fa%...@thefsb.org...
 On 8/25/09 5:00 AM, Ralph Deffke ralph_def...@yahoo.de wrote:

  of course its a syntax error, because unset() IS NOT A FUNCTION its a
  language construct

 that's hard to believe. i can't imagine how the compiler could reliably
 predict if the argument will be set or not when the unset line is
 executed.


  Stuart stut...@gmail.com wrote in message
  news:a5f019de0908250201g14e4b61cn73c6cd67da6f...@mail.gmail.com...
  2009/8/25 Ralph Deffke ralph_def...@yahoo.de:
  causes an error
  Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
 `'$''
  in
  C:\wamp\www\TinyCreator\testCrapp6.php on line 42
 
  This is a syntax error, not a runtime error. You've clearly done
  something wrong.
 
  Tom Worster f...@thefsb.org wrote in message
  news:c6b87877.11463%...@thefsb.org...
  is it the case that unset() does not trigger an error or throw an
  exception
  if it's argument was never set?
 
  Absolutely.
 
  -Stuart
 
  --
  http://stut.net/
 
 





 --
 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] Re: unset() something that doesn't exist

2009-08-26 Thread Stuart
2009/8/26 tedd tedd.sperl...@gmail.com:
 At 11:34 PM +0100 8/25/09, Stuart wrote:

 2009/8/25 tedd tedd.sperl...@gmail.com:

   I can't believe that you are wasting time on this. This guy is beyond

  clueless.

 To be fair tedd English is clearly not his main language and I can see
 how you could misunderstand the original question as he did. What I
 objected to was that he took what he interpreted as the question being
 asked, saw that it did in fact behave that way and then proceeded to
 completely fabricate an explanation as to why it does so when that
 explanation does little more than demonstrate that he clearly has no
 understanding of what's actually going on. I can't stand people who
 claim to know what they're talking about when they're really making it
 up as they go along.

 Actually, an explanation like that does do a lot more than demonstrate
 ignorance. It gives naive observers of this thread, now and in the
 future, incorrect information that they may potentially rely upon if
 nobody corrects it. That's why I'm wasting my time on this - I do it
 for the greater good.

 Hmm, maybe I just need a holiday...

 -Stuart

 --
 http://stut.net/

 -Stuart:

 I understand the language problem and how someone might use incorrect
 diction when speaking/writing English, but php is not English dependant.

 When someone says that unset(); does not work and provides an example that
 clearly demonstrates they don't know how to use it, then I throw up my hands
 and say RFTM in whatever language it's available. So, I wasn't objecting to
 the OP original statement but rather his proof that unset() wasn't
 working. You and I are objecting to the same thing.

 My hat is off to you for contributing to the greater good, but your
 efforts might be better spent attending to the needs of higher level idiots
 (like myself) and let us middle level idiots attend to the idiots, if you
 get my drift. :-)

 My comment is only a suggestion for you to consider. From my perspective, I
 hate to see such a valuable resource as yourself wasted on the clueless.

 And, we all need a holiday...

Apparently a holiday is out of the question, so I've decided to change
jobs instead. A new environment, that's all I need.

Loving your view of this list as a hierarchy of idiots btw, I think
that works as a description for a lot of places.

-Stuart

-- 
http://stut.net/

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



[PHP] downloading winword mp3 files the fancy way through a browser

2009-08-26 Thread Grega Leskovšek
I tried to download the file from another server the fancy way in PHP, but
it just display blank screen. Can You please look at my code:

?php
$filepath = http://aa.yolasite.com/resources/happytears.doc;;
// $filepath = http://users.skavt.net/~gleskovs/else/happytears.doc;;
  if (file_exists($filepath)) {
 header(Content-Type: application/force-download);
 header(Content-Disposition:filename=\happytears.doc\);
 $fd = fopen($filepath,'rb');//I tried also just 'r' and am not clear on
which documents should I add b for binary? As I understand only text plain
files and html files and php etc files are without 'b'. All documents,
presentations, mp3 files, video files should have also 'b' for binary along
r. Am I wrong?
 fpassthru($fd);
 fclose($fd);
  }
?
Both filepaths are valid and accessible to the same document. I double
checked them. Please help me. Thanks in advance, Yours, Grega


RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
This:
$var = $rs-Fields(22);
var_dump($var);

Produces this:
object(variant)#3 (0) { }

-Original Message-
From: Stuart [mailto:stut...@gmail.com] 
Sent: Wednesday, August 26, 2009 8:47 AM
To: David Stoltz
Cc: Paul M Foster; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

2009/8/26 David Stoltz dsto...@shh.org:
 Paul,

 This all started because when I try this:

 ?php echo $rs-Fields(22);?

 It work fine, as long as there is a non-null value there, otherwise it
 produces an error.

 Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
 sure if that matters

 But echo $rs-Fields(22) works perfectly for dumping values out of my
 $rs recordset...that is, unless the value is NULL is the database - then
 I get:

 Catchable fatal error: Object of class variant could not be converted to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176

That error indicates that you're not getting NULL since NULL is easily
converted to a string.

Try this...

$var = $rs-Fields(22);
var_dump($var);

...and tell us what you get.

-Stuart

-- 
http://stut.net/

 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: Tuesday, August 25, 2009 4:39 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

 $rs-Fields(22) equals a NULL in the database

 My Code:

 if(empty($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 Produces this error:
 Fatal error: Can't use method return value in write context in
 D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32

 Line 32 is the if line...

 If I switch the code to (using is_null):
 if(is_null($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 It produces this error:
 Catchable fatal error: Object of class variant could not be converted
 to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196

 Line 196 is: ?php echo $q4;?

 What am I doing wrong?

 Thanks!

 Just a thought... do you really mean $rs-Fields(22) or do you mean
 $rs-Fields[22]? The former is a function call and the latter is an
 array variable.

 Paul

 --
 Paul M. Foster

 --
 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] Re: Directory Listing

2009-08-26 Thread Eddie Drapkin
On Wed, Aug 26, 2009 at 9:45 AM, hack988 hack988hack...@dev.htwap.com wrote:
 I'm write a php file for you
 =
 define('Line_End', (PHP_OS == 'WINNT')?\r\n:\n);
 clearstatcache();

 $mylist=array();
 listdir(F:\\Programming\\Web\\php,$mylist);
 function listdir($dir,$list){
  if ($handle = opendir( $dir )){
   while ( false !== ( $item = readdir( $handle ) ) ) {
     if ( $item != .  $item != .. ) {
           $item=str_replace(Line_End,,$item);
       if ( is_dir( $dir.DIRECTORY_SEPARATOR.$item ) ) {
         listdir($dir.DIRECTORY_SEPARATOR.$item, $list);
       } else {
         $list[]=$dir.DIRECTORY_SEPARATOR.\t.$item.\t.date(m/d/Y,
 filemtime($dir.DIRECTORY_SEPARATOR.$item));
       }
     }
   }
   closedir( $handle );
  }
 }
 var_dump($mylist);

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



Why manually define Line_End when PHP_EOL already exists?

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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread tedd

At 2:12 PM +0100 8/26/09, Stuart wrote:

2009/8/26 tedd tedd.sperl...@gmail.com:

  And, we all need a holiday...

Apparently a holiday is out of the question, so I've decided to change
jobs instead. A new environment, that's all I need.

Loving your view of this list as a hierarchy of idiots btw, I think
that works as a description for a lot of places.

-Stuart



-Stuart:

I hope your new job still includes this list.

As for the hierarchy of idiots, but of course -- if we weren't 
idiots we would be doing something that made lot's of money.


I had a client say to me once If you're so smart, then why aren't 
you rich? I answered quickly What makes you think I'm not? But 
privately his comment cut me to the quick. There was no question that 
much dumber people than me (according to me) were making far more 
bucks than I was.


So, who's the smart one? Is it the guy that went to college to get 
three degrees to work his ass off for a moron who pays a a fraction 
of what he makes on the deal? Or is it the moron who sniffs out the 
deal and gets idiots to work for him?


It appears that the world is made up of morons and idiots -- the 
problem is that idiots do all the work and morons make all the money. 
The smarter the idiot, the more work that's available. The craftier 
the moron, the more money they make and thus the more idiots they 
hire.


As for me, sometimes I'm an idiot and other times I'm a moron. But 
what I really would like to be is retired so I could do this for a 
hobby.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] downloading winword mp3 files the fancy way through a browser

2009-08-26 Thread Ryan Cavicchioni
On Wed, Aug 26, 2009 at 03:38:27PM +0200, Grega Leskov??ek wrote:
 I tried to download the file from another server the fancy way in PHP, but
 it just display blank screen. Can You please look at my code:
 
 $filepath = http://aa.yolasite.com/resources/happytears.doc;;

Try using a local filepath instead of a URL.

Example: $filepath = /path/to/file/;

Regards,
Ryan

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



Re: [PHP] php cms?

2009-08-26 Thread Miller, Terion



On 8/25/09 11:42 PM, hack988 hack988 hack...@dev.htwap.com wrote:

i like durpal or e107

2009/8/26 Lars Nielsen l...@mit-web.dk:
 tir, 25 08 2009 kl. 17:05 -0400, skrev Bastien Koert:
 On Tue, Aug 25, 2009 at 4:35 PM, Lars Nielsenl...@mit-web.dk wrote:
  Hey list,
 
  I am going to use a cms for some sites and I have looked a little at
  Typo3, Joomla and php-fusion.
  Can anyone recommend a system where it is easy to customize the
  templates?
 
  regards
  Lars Nielsen
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 Joomla or Drupal are good

 --

 Bastien

 Cat, the other other white meat


 ok, thanks

 I'll give joomla! another shot.

 /Lars



Joomla definitely gets my vote!! I love it!

Terion


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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread hack988 hack988
My code for mssql
please enable the php's mssql extentions.
it used like so many mysql class that you can find by google
--
?php
if(!defined('IN_WEB')) {
exit('Access Denied');
}
ini_set('mssql.datetimeconvert',0);//php4.2.0 disable php's automatic
datetime convert
Class DB {
var $querynum=0;
var $mssql_link;
var $conn_link;
var $sp_link;
var $sp_name='';
var $error_stop=0;
var $show_error=0;
var $dbhost;
var $dbuser;
var $dbpw;
var $dbname;
var $pconnect;
var $var_type=array();
var $fields_name=array();
var $last_error_msg='';
var $phprunversion='';
function DB() {
//define type for sp
$this-var_type['sp_bit']=SQLBIT;
$this-var_type['sp_tinyint']=SQLINT1;
$this-var_type['sp_smallint']=SQLINT2;
$this-var_type['sp_int']=SQLINT4;
$this-var_type['sp_bigint']=SQLVARCHAR;
$this-var_type['sp_real']=SQLFLT4;
$this-var_type['sp_float']=SQLFLT8;
$this-var_type['sp_float-null']=SQLFLTN;
$this-var_type['sp_smallmoney']=SQLFLT8;
$this-var_type['sp_money']=SQLFLT8;
$this-var_type['sp_money-null']=SQLFLT8;
$this-var_type['sp_char']=SQLCHAR;
$this-var_type['sp_varchar']=SQLVARCHAR;
$this-var_type['sp_text']=SQLTEXT;
$this-var_type['sp_datetime']=SQLINT4;
$this-phprunversion=phpversion();
//end
}
/*=php4.4.1,=php5.1.1
a new paramate for if use newlink for connect,pconnect
*/
function rconnect($newlink=false){//2007.03.01 by hack988 fix 
phpversion check
if($this-phprunversion = '4.4.1'  $this-phprunversion  
'5.0.0'
|| $this-phprunversion = '5.1.1'){
return $this-rconnect4p($newlink);
}else{
return $this-rconnect3p();
}
}
function rconnect3p(){
$this-mssql_link = $this-pconnect==0 ?
mssql_connect($this-dbhost, $this-dbuser, $this-dbpw) :
mssql_pconnect($this-dbhost, $this-dbuser, $this-dbpw);
if(!$this-mssql_link){
$this-halt(connect
($this-pconnect)MSSQL($this-dbhost,$this-dbuser)failed!);
return false;
}else{
$this-conn_link=$this-mssql_link;
if($this-dbname) {
if 
(!...@$this-select_db($this-dbname,$this-conn_link)){
$this-halt('can not use database 
'.$this-dbname);
return false;
}else{
return true;
}
}else{
return true;
}
}
}
function rconnect4p($newlink=false){
$this-mssql_link = $this-pconnect==0 ?
mssql_connect($this-dbhost, $this-dbuser, $this-dbpw , $newlink) :
mssql_pconnect($this-dbhost, $this-dbuser, $this-dbpw, $newlink);
if(!$this-mssql_link){

$this-halt(reconect($this-pconnect)MSSQL($this-dbhost,$this-dbuser)failed);
return false;
}else{
$this-conn_link=$this-mssql_link;
if($this-dbname) {
if 
(!...@$this-select_db($this-dbname,$this-conn_link)){
$this-halt('can not use database 
'.$this-dbname);
return false;
}else{
return true;
}
}else{
return true;
}
}
}

function connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect =
0,$auto_conn=0 ,$newlink=false) {
$this-dbhost=$dbhost;
$this-dbuser=$dbuser;
$this-dbpw=$dbpw;
$this-dbname=$dbname;
$this-pconnect=$pconnect;
if($auto_conn){
return $this-rconnect($newlink);
}else{
return true;
}
}

function close() {
if($this-conn_link){
$result=mssql_close($this-conn_link);
}else{
   

RE: [PHP] SESSIONS lost sometimes - SOLVED

2009-08-26 Thread Angelo Zanetti


-Original Message-
From: Angelo Zanetti [mailto:ang...@zlogic.co.za] 
Sent: 24 August 2009 04:30 PM
To: 'Nitebirdz'; php-general@lists.php.net
Subject: RE: [PHP] SESSIONS lost sometimes



-Original Message-
From: Nitebirdz [mailto:nitebi...@sacredchaos.com] 
Sent: 20 August 2009 02:58 PM
To: php-general@lists.php.net
Subject: Re: [PHP] SESSIONS lost sometimes

On Thu, Aug 20, 2009 at 02:34:54PM +0200, Angelo Zanetti wrote:
 Hi Leon, 
 
 No harm intended :) Just thought that people were missing my post now and
 only answering yours.
 

Angelo, excuse me if I'm bringing up something very basic, but I'm new
to this.  Just trying to help.  

I imagine redirects couldn't be the cause of the problem, right?  

http://www.oscarm.org/news/detail/1877-avoiding_frustration_with_php_session
s

http://www.webmasterworld.com/forum88/8486.htm


Hi thanks for the links it appears that its all in order also I'm not losing
SESSIONS on the redirect but somewhere else.

I have checked the garbage collection, disk space and other settings in the
PHP.ini file. ALL FINE.

So now I am really stuck and confused as to what could sometimes cause the
loss of these variables and other times it just works fine. 

Is there possibly a way that I can call some function that will ensure that
the sessions are saved (I checked the manual - nothing much).

Any other ideas? Anything that you think might be causing issues? 

Thanks
Angelo

Hi all, 

I have solved the issue of lost session variables.

It appeared to be losing the SESSION variables when going from a POST from
HTTP to HTTPS, however it didn't always happen, so the logging allowed me to
narrow down where the losing was occurring.

The solution.

In my form that I post from the HTTP site, I put a hidden variable in there
and with the session variable. 

In HTTPS it sometimes doesn't carry over the hidden variable therefore we
need to start the session with the old SESSION ID from the HTTP site.

So what I did was the following on the https site: 

if (isset($_POST['sessionID']))
{

//http://stackoverflow.com/questions/441496/session-lost-when-switching-from
-http-to-https-in-php
// Retrieve the session ID as passed via the GET method.
$currentSessionID = $_POST['sessionID'];
//echo $currentSessionID;
// Set a cookie for the session ID.
$sessionid2 = session_id($currentSessionID);
}

Therefore setting the session ID with the session_id() function. This must
go before the session_start() function!!! Very NB!.

Hope this helps anyone who has a similar problem.

Regards
Angelo

http://www.elemental.co.za
http://www.wapit.co.za




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



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
Sorry - I don't know what you mean by DB class?

I'm using Microsoft SQL 2000with this code:

?php
//create an instance of the  ADO connection object
$conn = new COM (ADODB.Connection)
  or die(Cannot start ADO);
//define connection string, specify database driver
$connStr = PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=; 
$conn-open($connStr); //Open the connection to the database

$query = SELECT * FROM eval_evaluations WHERE id = .$_POST[eval];

$rs = $conn-execute($query);

echo $rs-Fields(22); //this is where that particular field is NULL, and 
produces the error



-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
Sent: Wednesday, August 26, 2009 8:08 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

Could you post your database's class to here?
I'm use mssql with php for several years and read NULL Fields is never
appear your case.

2009/8/26 David Stoltz dsto...@shh.org:
 I tried that -it's in the first part of my message


 -Original Message-
 From: hack988 hack988 [mailto:hack...@dev.htwap.com]
 Sent: Wednesday, August 26, 2009 7:39 AM
 To: David Stoltz
 Cc: Paul M Foster; php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 use is_null() check it

 2009/8/26 David Stoltz dsto...@shh.org:
 Paul,

 This all started because when I try this:

 ?php echo $rs-Fields(22);?

 It work fine, as long as there is a non-null value there, otherwise it
 produces an error.

 Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
 sure if that matters

 But echo $rs-Fields(22) works perfectly for dumping values out of my
 $rs recordset...that is, unless the value is NULL is the database - then
 I get:

 Catchable fatal error: Object of class variant could not be converted to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176


 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: Tuesday, August 25, 2009 4:39 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

 $rs-Fields(22) equals a NULL in the database

 My Code:

 if(empty($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 Produces this error:
 Fatal error: Can't use method return value in write context in
 D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32

 Line 32 is the if line...

 If I switch the code to (using is_null):
 if(is_null($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 It produces this error:
 Catchable fatal error: Object of class variant could not be converted
 to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196

 Line 196 is: ?php echo $q4;?

 What am I doing wrong?

 Thanks!

 Just a thought... do you really mean $rs-Fields(22) or do you mean
 $rs-Fields[22]? The former is a function call and the latter is an
 array variable.

 Paul

 --
 Paul M. Foster

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Directory Listing

2009-08-26 Thread hack988 hack988
some code copy from my old codes for truncatedir function,it for
backend compatibility.
see this
PHP_EOL (string)
Available since PHP 4.3.10 and PHP 5.0.2

http://cn.php.net/manual/en/reserved.constants.php

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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread hack988 hack988
my god you use ado connect sorry I'm use php_mysql extentions for all
mssql function.
I'm never use ado connect before.

2009/8/26 David Stoltz dsto...@shh.org:
 Sorry - I don't know what you mean by DB class?

 I'm using Microsoft SQL 2000with this code:

 ?php
 //create an instance of the  ADO connection object
 $conn = new COM (ADODB.Connection)
  or die(Cannot start ADO);
 //define connection string, specify database driver
 $connStr = PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=;
 $conn-open($connStr); //Open the connection to the database

 $query = SELECT * FROM eval_evaluations WHERE id = .$_POST[eval];

 $rs = $conn-execute($query);

 echo $rs-Fields(22); //this is where that particular field is NULL, and 
 produces the error

 

 -Original Message-
 From: hack988 hack988 [mailto:hack...@dev.htwap.com]
 Sent: Wednesday, August 26, 2009 8:08 AM
 To: David Stoltz
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 Could you post your database's class to here?
 I'm use mssql with php for several years and read NULL Fields is never
 appear your case.

 2009/8/26 David Stoltz dsto...@shh.org:
 I tried that -it's in the first part of my message


 -Original Message-
 From: hack988 hack988 [mailto:hack...@dev.htwap.com]
 Sent: Wednesday, August 26, 2009 7:39 AM
 To: David Stoltz
 Cc: Paul M Foster; php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 use is_null() check it

 2009/8/26 David Stoltz dsto...@shh.org:
 Paul,

 This all started because when I try this:

 ?php echo $rs-Fields(22);?

 It work fine, as long as there is a non-null value there, otherwise it
 produces an error.

 Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
 sure if that matters

 But echo $rs-Fields(22) works perfectly for dumping values out of my
 $rs recordset...that is, unless the value is NULL is the database - then
 I get:

 Catchable fatal error: Object of class variant could not be converted to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176


 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com]
 Sent: Tuesday, August 25, 2009 4:39 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?

 On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

 $rs-Fields(22) equals a NULL in the database

 My Code:

 if(empty($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 Produces this error:
 Fatal error: Can't use method return value in write context in
 D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32

 Line 32 is the if line...

 If I switch the code to (using is_null):
 if(is_null($rs-Fields(22))){
       $q4 = ;
 }else{
       $q4 = $rs-Fields(22);
 }

 It produces this error:
 Catchable fatal error: Object of class variant could not be converted
 to
 string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196

 Line 196 is: ?php echo $q4;?

 What am I doing wrong?

 Thanks!

 Just a thought... do you really mean $rs-Fields(22) or do you mean
 $rs-Fields[22]? The former is a function call and the latter is an
 array variable.

 Paul

 --
 Paul M. Foster

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Directory Listing

2009-08-26 Thread hack988 hack988
I'm write a php file for you
=
define('Line_End', (PHP_OS == 'WINNT')?\r\n:\n);
clearstatcache();

$mylist=array();
listdir(F:\\Programming\\Web\\php,$mylist);
function listdir($dir,$list){
  if ($handle = opendir( $dir )){
   while ( false !== ( $item = readdir( $handle ) ) ) {
 if ( $item != .  $item != .. ) {
   $item=str_replace(Line_End,,$item);
   if ( is_dir( $dir.DIRECTORY_SEPARATOR.$item ) ) {
 listdir($dir.DIRECTORY_SEPARATOR.$item, $list);
   } else {
 $list[]=$dir.DIRECTORY_SEPARATOR.\t.$item.\t.date(m/d/Y,
filemtime($dir.DIRECTORY_SEPARATOR.$item));
   }
 }
   }
   closedir( $handle );
  }
}
var_dump($mylist);

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



[PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

Hi.

During a socket read, why would all the requested number of bytes not  
get sent? For example, I request 1000 bytes:


?php
$data = @socket_read ($socket, 2048, PHP_BINARY_READ);
?

This is actually in a loop, so I can get all the data if split up. So,  
for example, here's how the data split up in 3 iterations (for 1000  
bytes):


650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it not  
pull all 1000 bytes initially in 1 step? Any thoughts on this would be  
greatly appreciated!


Thanks,
~Philip

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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Ashley Sheridan
On Wed, 2009-08-26 at 22:00 +0800, hack988 hack988 wrote:
 my god you use ado connect sorry I'm use php_mysql extentions for all
 mssql function.
 I'm never use ado connect before.
 
 2009/8/26 David Stoltz dsto...@shh.org:
  Sorry - I don't know what you mean by DB class?
 
  I'm using Microsoft SQL 2000with this code:
 
  ?php
  //create an instance of the  ADO connection object
  $conn = new COM (ADODB.Connection)
   or die(Cannot start ADO);
  //define connection string, specify database driver
  $connStr = PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=;
  $conn-open($connStr); //Open the connection to the database
 
  $query = SELECT * FROM eval_evaluations WHERE id = .$_POST[eval];
 
  $rs = $conn-execute($query);
 
  echo $rs-Fields(22); //this is where that particular field is NULL, and 
  produces the error
 
  
 
  -Original Message-
  From: hack988 hack988 [mailto:hack...@dev.htwap.com]
  Sent: Wednesday, August 26, 2009 8:08 AM
  To: David Stoltz
  Cc: php-general@lists.php.net
  Subject: Re: [PHP] How to output a NULL field?
 
  Could you post your database's class to here?
  I'm use mssql with php for several years and read NULL Fields is never
  appear your case.
 
  2009/8/26 David Stoltz dsto...@shh.org:
  I tried that -it's in the first part of my message
 
 
  -Original Message-
  From: hack988 hack988 [mailto:hack...@dev.htwap.com]
  Sent: Wednesday, August 26, 2009 7:39 AM
  To: David Stoltz
  Cc: Paul M Foster; php-general@lists.php.net
  Subject: Re: [PHP] How to output a NULL field?
 
  use is_null() check it
 
  2009/8/26 David Stoltz dsto...@shh.org:
  Paul,
 
  This all started because when I try this:
 
  ?php echo $rs-Fields(22);?
 
  It work fine, as long as there is a non-null value there, otherwise it
  produces an error.
 
  Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
  sure if that matters
 
  But echo $rs-Fields(22) works perfectly for dumping values out of my
  $rs recordset...that is, unless the value is NULL is the database - then
  I get:
 
  Catchable fatal error: Object of class variant could not be converted to
  string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176
 
 
  -Original Message-
  From: Paul M Foster [mailto:pa...@quillandmouse.com]
  Sent: Tuesday, August 25, 2009 4:39 PM
  To: php-general@lists.php.net
  Subject: Re: [PHP] How to output a NULL field?
 
  On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:
 
  $rs-Fields(22) equals a NULL in the database
 
  My Code:
 
  if(empty($rs-Fields(22))){
$q4 = ;
  }else{
$q4 = $rs-Fields(22);
  }
 
  Produces this error:
  Fatal error: Can't use method return value in write context in
  D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32
 
  Line 32 is the if line...
 
  If I switch the code to (using is_null):
  if(is_null($rs-Fields(22))){
$q4 = ;
  }else{
$q4 = $rs-Fields(22);
  }
 
  It produces this error:
  Catchable fatal error: Object of class variant could not be converted
  to
  string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196
 
  Line 196 is: ?php echo $q4;?
 
  What am I doing wrong?
 
  Thanks!
 
  Just a thought... do you really mean $rs-Fields(22) or do you mean
  $rs-Fields[22]? The former is a function call and the latter is an
  array variable.
 
  Paul
 
  --
  Paul M. Foster
 
  --
  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
 
 
 
 
 
That's impressive, but are you sure you don't use php_mssql extensions
instead? :p

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
Wow - thanks for the code, but it's over my head at this point.

I'm a PHP newbieI typically use ASP Classic, but I realize I need to learn 
PHP for ongoing development. Problem is, we don't have MySQL here, so I have to 
fumble my way through with MS SQL.

Thanks!


-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
Sent: Wednesday, August 26, 2009 10:13 AM
To: a...@ashleysheridan.co.uk
Cc: David Stoltz; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

My code for mssql
please enable the php's mssql extentions.
it used like so many mysql class that you can find by google
--
?php
if(!defined('IN_WEB')) {
exit('Access Denied');
}
ini_set('mssql.datetimeconvert',0);//php4.2.0 disable php's automatic
datetime convert
Class DB {
var $querynum=0;
var $mssql_link;
var $conn_link;
var $sp_link;
var $sp_name='';
var $error_stop=0;
var $show_error=0;
var $dbhost;
var $dbuser;
var $dbpw;
var $dbname;
var $pconnect;
var $var_type=array();
var $fields_name=array();
var $last_error_msg='';
var $phprunversion='';
function DB() {
//define type for sp
$this-var_type['sp_bit']=SQLBIT;
$this-var_type['sp_tinyint']=SQLINT1;
$this-var_type['sp_smallint']=SQLINT2;
$this-var_type['sp_int']=SQLINT4;
$this-var_type['sp_bigint']=SQLVARCHAR;
$this-var_type['sp_real']=SQLFLT4;
$this-var_type['sp_float']=SQLFLT8;
$this-var_type['sp_float-null']=SQLFLTN;
$this-var_type['sp_smallmoney']=SQLFLT8;
$this-var_type['sp_money']=SQLFLT8;
$this-var_type['sp_money-null']=SQLFLT8;
$this-var_type['sp_char']=SQLCHAR;
$this-var_type['sp_varchar']=SQLVARCHAR;
$this-var_type['sp_text']=SQLTEXT;
$this-var_type['sp_datetime']=SQLINT4;
$this-phprunversion=phpversion();
//end
}
/*=php4.4.1,=php5.1.1
a new paramate for if use newlink for connect,pconnect
*/
function rconnect($newlink=false){//2007.03.01 by hack988 fix 
phpversion check
if($this-phprunversion = '4.4.1'  $this-phprunversion  
'5.0.0'
|| $this-phprunversion = '5.1.1'){
return $this-rconnect4p($newlink);
}else{
return $this-rconnect3p();
}
}
function rconnect3p(){
$this-mssql_link = $this-pconnect==0 ?
mssql_connect($this-dbhost, $this-dbuser, $this-dbpw) :
mssql_pconnect($this-dbhost, $this-dbuser, $this-dbpw);
if(!$this-mssql_link){
$this-halt(connect
($this-pconnect)MSSQL($this-dbhost,$this-dbuser)failed!);
return false;
}else{
$this-conn_link=$this-mssql_link;
if($this-dbname) {
if 
(!...@$this-select_db($this-dbname,$this-conn_link)){
$this-halt('can not use database 
'.$this-dbname);
return false;
}else{
return true;
}
}else{
return true;
}
}
}
function rconnect4p($newlink=false){
$this-mssql_link = $this-pconnect==0 ?
mssql_connect($this-dbhost, $this-dbuser, $this-dbpw , $newlink) :
mssql_pconnect($this-dbhost, $this-dbuser, $this-dbpw, $newlink);
if(!$this-mssql_link){

$this-halt(reconect($this-pconnect)MSSQL($this-dbhost,$this-dbuser)failed);
return false;
}else{
$this-conn_link=$this-mssql_link;
if($this-dbname) {
if 
(!...@$this-select_db($this-dbname,$this-conn_link)){
$this-halt('can not use database 
'.$this-dbname);
return false;
}else{
return true;
}
}else{
return true;
}
}
}

function connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect =
0,$auto_conn=0 ,$newlink=false) {

[PHP] Getting backtrace through GDB?

2009-08-26 Thread Jason Young

Hi all,

I'm trying to follow the instructions for getting a GDB backtrace from 
the PECL site ( http://bugs.php.net/bugs-generating-backtrace.php ).


For some reason, I'm not getting any symbol output when I try to 
generate the backtrace, it simply gives me the memory address and '??'.


I'm using a clean install of PHP, and I've specified --enable-debug in 
the configure script (which I know works, since PHP will identify and 
print memory leaks).


Has anyone else had any trouble with this and found a solution? I'd 
really like to get generate these so I can better help the PECL 
developer this is needed for.


Thanks for any insight or suggestions you can give!
-Jason Young

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



RE: [PHP] How to output a NULL field?

2009-08-26 Thread Ashley Sheridan
On Wed, 2009-08-26 at 10:50 -0400, David Stoltz wrote:
 Wow - thanks for the code, but it's over my head at this point.
 
 I'm a PHP newbieI typically use ASP Classic, but I realize I need to 
 learn PHP for ongoing development. Problem is, we don't have MySQL here, so I 
 have to fumble my way through with MS SQL.
 
 Thanks!
 
 
 -Original Message-
 From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
 Sent: Wednesday, August 26, 2009 10:13 AM
 To: a...@ashleysheridan.co.uk
 Cc: David Stoltz; php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?
 
 My code for mssql
 please enable the php's mssql extentions.
 it used like so many mysql class that you can find by google
 --
 ?php
 if(!defined('IN_WEB')) {
   exit('Access Denied');
 }
 ini_set('mssql.datetimeconvert',0);//php4.2.0 disable php's automatic
 datetime convert
 Class DB {
   var $querynum=0;
   var $mssql_link;
   var $conn_link;
   var $sp_link;
   var $sp_name='';
   var $error_stop=0;
   var $show_error=0;
   var $dbhost;
   var $dbuser;
   var $dbpw;
   var $dbname;
   var $pconnect;
   var $var_type=array();
   var $fields_name=array();
   var $last_error_msg='';
   var $phprunversion='';
   function DB() {
   //define type for sp
   $this-var_type['sp_bit']=SQLBIT;
   $this-var_type['sp_tinyint']=SQLINT1;
   $this-var_type['sp_smallint']=SQLINT2;
   $this-var_type['sp_int']=SQLINT4;
   $this-var_type['sp_bigint']=SQLVARCHAR;
   $this-var_type['sp_real']=SQLFLT4;
   $this-var_type['sp_float']=SQLFLT8;
   $this-var_type['sp_float-null']=SQLFLTN;
   $this-var_type['sp_smallmoney']=SQLFLT8;
   $this-var_type['sp_money']=SQLFLT8;
   $this-var_type['sp_money-null']=SQLFLT8;
   $this-var_type['sp_char']=SQLCHAR;
   $this-var_type['sp_varchar']=SQLVARCHAR;
   $this-var_type['sp_text']=SQLTEXT;
   $this-var_type['sp_datetime']=SQLINT4;
   $this-phprunversion=phpversion();
   //end
   }
 /*=php4.4.1,=php5.1.1
 a new paramate for if use newlink for connect,pconnect
 */
   function rconnect($newlink=false){//2007.03.01 by hack988 fix 
 phpversion check
   if($this-phprunversion = '4.4.1'  $this-phprunversion  
 '5.0.0'
 || $this-phprunversion = '5.1.1'){
   return $this-rconnect4p($newlink);
   }else{
   return $this-rconnect3p();
   }
   }
   function rconnect3p(){
   $this-mssql_link = $this-pconnect==0 ?
 mssql_connect($this-dbhost, $this-dbuser, $this-dbpw) :
 mssql_pconnect($this-dbhost, $this-dbuser, $this-dbpw);
   if(!$this-mssql_link){
   $this-halt(connect
 ($this-pconnect)MSSQL($this-dbhost,$this-dbuser)failed!);
   return false;
   }else{
   $this-conn_link=$this-mssql_link;
   if($this-dbname) {
   if 
 (!...@$this-select_db($this-dbname,$this-conn_link)){
   $this-halt('can not use database 
 '.$this-dbname);
   return false;
   }else{
   return true;
   }
   }else{
   return true;
   }
   }
   }
   function rconnect4p($newlink=false){
   $this-mssql_link = $this-pconnect==0 ?
 mssql_connect($this-dbhost, $this-dbuser, $this-dbpw , $newlink) :
 mssql_pconnect($this-dbhost, $this-dbuser, $this-dbpw, $newlink);
   if(!$this-mssql_link){
   
 $this-halt(reconect($this-pconnect)MSSQL($this-dbhost,$this-dbuser)failed);
   return false;
   }else{
   $this-conn_link=$this-mssql_link;
   if($this-dbname) {
   if 
 (!...@$this-select_db($this-dbname,$this-conn_link)){
   $this-halt('can not use database 
 '.$this-dbname);
   return false;
   }else{
   return true;
   }
   }else{
   return true;
   }
   }
   }
 
   function connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect =
 0,$auto_conn=0 ,$newlink=false) {
   

Re: [PHP] downloading winword mp3 files the fancy way through a browser

2009-08-26 Thread Jim Lucas
Grega Leskovšek wrote:
 I tried to download the file from another server the fancy way in PHP, but
 it just display blank screen. Can You please look at my code:
 
 ?php
 $filepath = http://aa.yolasite.com/resources/happytears.doc;;
 // $filepath = http://users.skavt.net/~gleskovs/else/happytears.doc;;
   if (file_exists($filepath)) {

I see in the manual that file_exists can now check URLs, but my guess
would be that it needs to have the allow_url_fopen statement in the
php.ini set to On.

See

  header(Content-Type: application/force-download);
  header(Content-Disposition:filename=\happytears.doc\);
  $fd = fopen($filepath,'rb');//I tried also just 'r' and am not clear on
 which documents should I add b for binary? As I understand only text plain
 files and html files and php etc files are without 'b'. All documents,
 presentations, mp3 files, video files should have also 'b' for binary along
 r. Am I wrong?
  fpassthru($fd);
  fclose($fd);
   }
 ?
 Both filepaths are valid and accessible to the same document. I double
 checked them. Please help me. Thanks in advance, Yours, Grega


See what you get with this
?php
$filepath = http://aa.yolasite.com/resources/happytears.doc;;
if (file_exists($filepath)) {
  echo 'File found';
} else {
  echo 'File NOT found';
}
?

Jim


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



Re: [PHP] downloading winword mp3 files the fancy way through a browser

2009-08-26 Thread Ryan Cavicchioni
On Wed, Aug 26, 2009 at 03:38:27PM +0200, Grega Leskov??ek wrote:
 I tried to download the file from another server the fancy way in PHP, but
 it just display blank screen. Can You please look at my code:

If it helps, here is some code that I dug up from an old project:

?php

$filepath = /var/www/test.doc;
$filename = basename($filepath);
$filesize = filesize($filepath);

if ( file_exists($filepath) )
{
header(Cache-Control: no-store, must-revalidate);
header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
header(Content-Transfer-Encoding: binary);
header(Content-Type: application/force-download);
header(Content-Type: application/octet-stream);
header(Content-Type: application/download);
header(Content-disposition: attachment; filename= . $filename);
header(Content-length:  . $filesize);
$fh = fopen($filepath, rb) or exit(Could not open file.);
while (!feof($fh))
{
print(fgets($fh,4096));
}
fclose($fh);
} else {
echo The file does not exist.;
}

?

I would also verify that the web server has permissions to the files
that php is trying to open. Internet Explorer 8 seems to have a
problem with the filename parameter in the Content-disposition header
being enclosed in quotes. It would just dump the binary data in the
page when I was testing this.

Regards,
Ryan

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



Re: [PHP] downloading winword mp3 files the fancy way through a browser

2009-08-26 Thread hack988 hack988
All IE has a bug for download file so.:)
see this http://support.microsoft.com/default.aspx?scid=kb;en-us;308090
some unkown mime type also display in IE no popup a download window

2009/8/26 Ryan Cavicchioni r...@confabulator.net:
 On Wed, Aug 26, 2009 at 03:38:27PM +0200, Grega Leskov??ek wrote:
 I tried to download the file from another server the fancy way in PHP, but
 it just display blank screen. Can You please look at my code:

 If it helps, here is some code that I dug up from an old project:

 ?php

 $filepath = /var/www/test.doc;
 $filename = basename($filepath);
 $filesize = filesize($filepath);

 if ( file_exists($filepath) )
 {
    header(Cache-Control: no-store, must-revalidate);
    header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
    header(Content-Transfer-Encoding: binary);
    header(Content-Type: application/force-download);
    header(Content-Type: application/octet-stream);
    header(Content-Type: application/download);
    header(Content-disposition: attachment; filename= . $filename);
    header(Content-length:  . $filesize);
    $fh = fopen($filepath, rb) or exit(Could not open file.);
    while (!feof($fh))
    {
        print(fgets($fh,4096));
    }
    fclose($fh);
 } else {
        echo The file does not exist.;
 }

 ?

 I would also verify that the web server has permissions to the files
 that php is trying to open. Internet Explorer 8 seems to have a
 problem with the filename parameter in the Content-disposition header
 being enclosed in quotes. It would just dump the binary data in the
 page when I was testing this.

 Regards,
 Ryan

 --
 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] Re: Directory Listing

2009-08-26 Thread Steve

Ashley Sheridan wrote:

On Wed, 2009-08-26 at 09:50 +0100, Tom Chubb wrote:
  

2009/8/26 Ashley Sheridan a...@ashleysheridan.co.uk:


On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote:
  

I've been playing about more and now I have the following code:

?
error_reporting(E_ALL);
ini_set('display_errors', true);

function getDirectory($path = '.', $ignore = '') {
$dirTree = array ();
$dirTreeTemp = array ();
$fileDate = array ();
$ignore[] = '.';
$ignore[] = '..';
$dh = @opendir($path);
while (false !== ($file = readdir($dh))) {
if (!in_array($file, $ignore)) {
if (!is_dir($path/$file)) {
$dirTree[$path][] = $file;
$fileDate[$file][] = date (d/m/Y,
filemtime($path/$file));
} else {
$dirTreeTemp = getDirectory($path/$file, $ignore);
if (is_array($dirTreeTemp))$dirTree =
array_merge($dirTree, $dirTreeTemp, $fileDate);
}
}
}
closedir($dh);
return $dirTree;
}

$ignore = array('.htaccess', 'Thumbs.db', 'index.php');
$dirTree = getDirectory('.', $ignore);
getdirectory('.');

echo Gatwick Tender Documents\n;

foreach( $dirTree as $key = $folder ){
   echo \n; //Don't need folders as they're shown with the files
   foreach( $folder as $file){
   echo str_replace(./, , $key) . \t . $file . \t\n; //Pad
out with a tab for easy import into excel

   }
}
print_r($dirTree); //Just using this for debugging
?


The output is fine for the paths and filenames but I still can't get
the dates showing. It's getting the correct date for some but not all.
I did something else earlier and found that all the dates were
01/01/1970 but at least there was a date for every file but can't
remember how I go there!


Here is a sample output result:

Gatwick Tender Documents

. 9216_100_REV_V1.0_bound.dwg

Tender Docs   BAA Works Terms v1.1 (22.05.08).pdf
Tender Docs   Contents of Volumes 1 and 2.pdf
Tender Docs   Cover Letter and Instructions.doc
Tender Docs   Form of Tender.doc

Tender Docs/Health and Safety Questionnaire   NT Baggage Tender
Questionaire rev2.xls

BAA Works Terms v1.1 (22.05.08).pdf   29/07/2009

Contents of Volumes 1 and 2.pdf   29/07/2009

Cover Letter and Instructions.doc 29/07/2009

Form of Tender.doc29/07/2009

Tender Docs/NTB BH Lighting   3J-B-1 PIR.xls
Tender Docs/NTB BH Lighting   3J-B-2B PIR.xls
Tender Docs/NTB BH Lighting   3J-B-2R PIR.xls
Tender Docs/NTB BH Lighting   3J-B-3R PIR.xls
Tender Docs/NTB BH Lighting   3J-D PIR.xls
Tender Docs/NTB BH Lighting   4G-G PIR.xls
Tender Docs/NTB BH Lighting   4J-B-1B PIR.xls
Tender Docs/NTB BH Lighting   4J-B-1R PIR.xls
Tender Docs/NTB BH Lighting   4J-B-2B PIR.xls
Tender Docs/NTB BH Lighting   4J-B-2R PIR.xls
Tender Docs/NTB BH Lighting   4J-B-4 PIR.xls
Tender Docs/NTB BH Lighting   5G-G PIR.xls


Can anyone shed any light on it?
I'm about to admit defeat!

Thanks in advance and I'm not being lazy - I really am trying!!! :(

Tom



The only time I've ever noticed this problem was on a 32bit system where
the files were above 2GB each. When the files are that size, none of the
information functions seem to work correctly, including the filesize,
date, etc.

Thanks,
Ash
http://www.ashleysheridan.co.uk




  

Cheers Ash,
I read that too, but I was getting the error for over 90% of the files
which I know are generally only a few MB.
I've started from scratch again and come up with something that is
easier to deal with but still having one last problem!

?php
error_reporting(E_ALL);
ini_set('display_errors', true);
function directoryToArray($directory, $recursive) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file !=index.php  $file != .  $file != 
..) {
if (is_dir($directory. / . $file)) {
//For Directories
if($recursive) {
$array_items = 
array_merge($array_items,
directoryToArray($directory. / . $file, $recursive));
}
$fullfile = $directory . / . $file;
$array_items[] = preg_replace(/\/\//si, 
/, $fullfile);
} else {
//For Files
$fullfile = $directory . / . $file;
$array_items[] = preg_replace(/\/\//si, 
/, $fullfile);
}
}
}
closedir($handle);
}
return $array_items;
}

$files = directoryToArray(./Tender, true);


//Output to browser
foreach ($files as $file) {
echo str_replace(./Tender, , $file) . \t . . date 

Re: [PHP] Sockets (reading)

2009-08-26 Thread Jim Lucas
Philip Thompson wrote:
 Hi.
 
 During a socket read, why would all the requested number of bytes not
 get sent? For example, I request 1000 bytes:
 
 ?php
 $data = @socket_read ($socket, 2048, PHP_BINARY_READ);
 ?
 
 This is actually in a loop, so I can get all the data if split up. So,
 for example, here's how the data split up in 3 iterations (for 1000 bytes):
 
 650 bytes
 200 bytes
 150 bytes
 
 But if I can accept up to 2048 bytes per socket read, why would it not
 pull all 1000 bytes initially in 1 step? Any thoughts on this would be
 greatly appreciated!
 
 Thanks,
 ~Philip
 

Is it possible that you are receiving a \r, \n, or \0 and that is
stopping the input?

Check the Parameters the second argument for Length options.
http://us3.php.net/socket_read


Here is a shortened version of a script that I use to do something similar.

?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');

// Set time limit to indefinite execution
set_time_limit(0);

// Set the ip and port we will listen on
define('LISTEN_IP', 'your IP address');  // IP to listin on
define('LISTEN_PORT',   port);   // Port number
define('PACKET_SIZE',   512);  // 512 bytes
define('SOCKET_TIMOUT', 2);// Seconds

/* Open a server socket to port 1234 on localhost */
if ( $socket = @stream_socket_server('udp://'.LISTEN_IP.':'.LISTEN_PORT,
$errno, $errstr, STREAM_SERVER_BIND) ) {
  while ( true ) {
$buff = stream_socket_recvfrom($socket, PACKET_SIZE, 0, $remote_ip);
if ( !empty($buff) ) {
  print('Received Data: '.PHP_EOL);
  print('Do something with it...'.PHP_EOL);
} else {
  print('Empty String'.PHP_EOL);
}
  }
  fclose($socket);
} else {
  print([{$errno}] {$error}.PHP_EOL);
}

?


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



Re: [PHP] Re: Directory Listing

2009-08-26 Thread hack988 hack988
use realpath is better that i think

2009/8/26 Steve ad...@ultramegatech.com:
 Ashley Sheridan wrote:

 On Wed, 2009-08-26 at 09:50 +0100, Tom Chubb wrote:


 2009/8/26 Ashley Sheridan a...@ashleysheridan.co.uk:


 On Tue, 2009-08-25 at 17:08 +0100, Tom Chubb wrote:


 I've been playing about more and now I have the following code:

 ?
 error_reporting(E_ALL);
 ini_set('display_errors', true);

 function getDirectory($path = '.', $ignore = '') {
    $dirTree = array ();
    $dirTreeTemp = array ();
    $fileDate = array ();
    $ignore[] = '.';
    $ignore[] = '..';
    $dh = @opendir($path);
    while (false !== ($file = readdir($dh))) {
        if (!in_array($file, $ignore)) {
            if (!is_dir($path/$file)) {
                $dirTree[$path][] = $file;
                $fileDate[$file][] = date (d/m/Y,
 filemtime($path/$file));
            } else {
                $dirTreeTemp = getDirectory($path/$file, $ignore);
                if (is_array($dirTreeTemp))$dirTree =
 array_merge($dirTree, $dirTreeTemp, $fileDate);
            }
        }
    }
    closedir($dh);
    return $dirTree;
 }

 $ignore = array('.htaccess', 'Thumbs.db', 'index.php');
 $dirTree = getDirectory('.', $ignore);
 getdirectory('.');

 echo Gatwick Tender Documents\n;

 foreach( $dirTree as $key = $folder ){
   echo \n; //Don't need folders as they're shown with the files
   foreach( $folder as $file){
       echo str_replace(./, , $key) . \t . $file . \t\n; //Pad
 out with a tab for easy import into excel

   }
 }
 print_r($dirTree); //Just using this for debugging
 ?


 The output is fine for the paths and filenames but I still can't get
 the dates showing. It's getting the correct date for some but not all.
 I did something else earlier and found that all the dates were
 01/01/1970 but at least there was a date for every file but can't
 remember how I go there!


 Here is a sample output result:

 Gatwick Tender Documents

 .     9216_100_REV_V1.0_bound.dwg

 Tender Docs   BAA Works Terms v1.1 (22.05.08).pdf
 Tender Docs   Contents of Volumes 1 and 2.pdf
 Tender Docs   Cover Letter and Instructions.doc
 Tender Docs   Form of Tender.doc

 Tender Docs/Health and Safety Questionnaire   NT Baggage Tender
 Questionaire rev2.xls

 BAA Works Terms v1.1 (22.05.08).pdf   29/07/2009

 Contents of Volumes 1 and 2.pdf       29/07/2009

 Cover Letter and Instructions.doc     29/07/2009

 Form of Tender.doc    29/07/2009

 Tender Docs/NTB BH Lighting   3J-B-1 PIR.xls
 Tender Docs/NTB BH Lighting   3J-B-2B PIR.xls
 Tender Docs/NTB BH Lighting   3J-B-2R PIR.xls
 Tender Docs/NTB BH Lighting   3J-B-3R PIR.xls
 Tender Docs/NTB BH Lighting   3J-D PIR.xls
 Tender Docs/NTB BH Lighting   4G-G PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-1B PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-1R PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-2B PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-2R PIR.xls
 Tender Docs/NTB BH Lighting   4J-B-4 PIR.xls
 Tender Docs/NTB BH Lighting   5G-G PIR.xls


 Can anyone shed any light on it?
 I'm about to admit defeat!

 Thanks in advance and I'm not being lazy - I really am trying!!! :(

 Tom



 The only time I've ever noticed this problem was on a 32bit system where
 the files were above 2GB each. When the files are that size, none of the
 information functions seem to work correctly, including the filesize,
 date, etc.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk






 Cheers Ash,
 I read that too, but I was getting the error for over 90% of the files
 which I know are generally only a few MB.
 I've started from scratch again and come up with something that is
 easier to deal with but still having one last problem!

 ?php
 error_reporting(E_ALL);
 ini_set('display_errors', true);
 function directoryToArray($directory, $recursive) {
        $array_items = array();
        if ($handle = opendir($directory)) {
                while (false !== ($file = readdir($handle))) {
                        if ($file !=index.php  $file != .  $file
 != ..) {
                                if (is_dir($directory. / . $file)) {
                                        //For Directories
                                        if($recursive) {
                                                $array_items =
 array_merge($array_items,
 directoryToArray($directory. / . $file, $recursive));
                                        }
                                        $fullfile = $directory . / .
 $file;
                                        $array_items[] =
 preg_replace(/\/\//si, /, $fullfile);
                                } else {
                                        //For Files
                                        $fullfile = $directory . / .
 $file;
                                        $array_items[] =
 preg_replace(/\/\//si, /, $fullfile);
                                }
                        }
                }
                closedir($handle);
        }
        return $array_items;
 }

 $files = 

Re: [PHP] How to output a NULL field?

2009-08-26 Thread Andrew Ballard
On Wed, Aug 26, 2009 at 10:52 AM, Ashley
Sheridana...@ashleysheridan.co.uk wrote:
 You should try and see if you can get it installed there, as it will
 work on Windows servers. I've found it generally to be faster than MS
 SQL, and the choice of different database engines for each table gives
 you a LOT of flexibility for the future too. Also, MySQL offers a bit
 more functionality I've found.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk

To be fair, I've not had found any performance problems when using SQL
Server. And, while there is one main feature MySQL has that I really
miss in SQL Server (the LIMIT clause), I miss enforcement of CHECK
constraints in MySQL. (I suppose I could implement them via triggers,
but that just seems messy to me.)

I'm all for flexibility, though.

Andrew

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



[PHP] String Formulas

2009-08-26 Thread Floyd Resler
How can I take a mathematical formula that is in a string and have the  
result, product, sum, etc. returned?  I did a search on the Web and  
couldn't find any suitable solutions.


Thanks!
Floyd


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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Andrew Ballard
On Wed, Aug 26, 2009 at 9:51 AM, David Stoltzdsto...@shh.org wrote:
 Sorry - I don't know what you mean by DB class?

 I'm using Microsoft SQL 2000with this code:

 ?php
 //create an instance of the  ADO connection object
 $conn = new COM (ADODB.Connection)
  or die(Cannot start ADO);
 //define connection string, specify database driver
 $connStr = PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=;
 $conn-open($connStr); //Open the connection to the database

 $query = SELECT * FROM eval_evaluations WHERE id = .$_POST[eval];

 $rs = $conn-execute($query);

 echo $rs-Fields(22); //this is where that particular field is NULL, and 
 produces the error

 


Because you are using COM, you can't use PHP's empty(), isset(), or
is_null() in your if(...) statement. I've not used COM for much in
PHP, but I think you'll have to do something like this:

switch (variant_get_type($rs-Fields(22)) {
case VT_EMPTY:
case VT_NULL:
$q4 = '';
break;

case VT_UI1:

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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread hack988 hack988
Com function is just for Windows,I don't kown why some body like use it.:(

2009/8/27 Andrew Ballard aball...@gmail.com:
 On Wed, Aug 26, 2009 at 9:51 AM, David Stoltzdsto...@shh.org wrote:
 Sorry - I don't know what you mean by DB class?

 I'm using Microsoft SQL 2000with this code:

 ?php
 //create an instance of the  ADO connection object
 $conn = new COM (ADODB.Connection)
  or die(Cannot start ADO);
 //define connection string, specify database driver
 $connStr = PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=;
 $conn-open($connStr); //Open the connection to the database

 $query = SELECT * FROM eval_evaluations WHERE id = .$_POST[eval];

 $rs = $conn-execute($query);

 echo $rs-Fields(22); //this is where that particular field is NULL, and 
 produces the error

 


 Because you are using COM, you can't use PHP's empty(), isset(), or
 is_null() in your if(...) statement. I've not used COM for much in
 PHP, but I think you'll have to do something like this:

 switch (variant_get_type($rs-Fields(22)) {
    case VT_EMPTY:
    case VT_NULL:
        $q4 = '';
        break;

    case VT_UI1:


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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Andrew Ballard
On Wed, Aug 26, 2009 at 12:13 PM, Andrew Ballardaball...@gmail.com wrote:
 On Wed, Aug 26, 2009 at 9:51 AM, David Stoltzdsto...@shh.org wrote:
 Sorry - I don't know what you mean by DB class?

 I'm using Microsoft SQL 2000with this code:

 ?php
 //create an instance of the  ADO connection object
 $conn = new COM (ADODB.Connection)
  or die(Cannot start ADO);
 //define connection string, specify database driver
 $connStr = PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=;
 $conn-open($connStr); //Open the connection to the database

 $query = SELECT * FROM eval_evaluations WHERE id = .$_POST[eval];

 $rs = $conn-execute($query);

 echo $rs-Fields(22); //this is where that particular field is NULL, and 
 produces the error

 


 Because you are using COM, you can't use PHP's empty(), isset(), or
 is_null() in your if(...) statement. I've not used COM for much in
 PHP, but I think you'll have to do something like this:

 switch (variant_get_type($rs-Fields(22)) {
    case VT_EMPTY:
    case VT_NULL:
        $q4 = '';
        break;

    case VT_UI1:


blast ... hit some key and Gmail just sent what I had typed so far.

At any rate, hopefully you can get the idea from that last post. Look
at this reference for handling different types returned from COM:

http://www.php.net/manual/en/com.constants.php


I would also suggest looking into a PHP library for querying SQL
Server rather than relying on COM. There are several, some work better
than others. I've found that the SQL Server Driver for PHP works best
for what I use. It is documented as being for 2005 and newer, but I
have been able to use it just fine with 2000 as well.

Andrew

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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Andrew Ballard
On Wed, Aug 26, 2009 at 12:06 PM, hack988 hack988hack...@dev.htwap.com wrote:
 Mysql,mssql has its own feature,you can't say Mysql is better than
 Mssql or Mssql it better than Mysql,Is'nt is?
 My the Way ,Mssql support Top n,m form mssql 2005 :)


Perhaps, but the OP said he's using SQL Server 2000.

Andrew

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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread hack988 hack988
I'm sorry for my poor English,what is OP? I don't kown what is OP mean.

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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Ashley Sheridan
On Thu, 2009-08-27 at 00:25 +0800, hack988 hack988 wrote:
 I'm sorry for my poor English,what is OP? I don't kown what is OP mean.
 

It's basically the original person who asked the question.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread Paul M Foster
On Wed, Aug 26, 2009 at 10:08:35AM -0400, tedd wrote:

 2009/8/26 tedd tedd.sperl...@gmail.com:

snip

 I had a client say to me once If you're so smart, then why aren't
 you rich? I answered quickly What makes you think I'm not? But
 privately his comment cut me to the quick. There was no question that
 much dumber people than me (according to me) were making far more
 bucks than I was.

I've had people say or imply this to me. Here's my take on it: I'm
absolutely certain that I'm easily smart enough to be rich. Why aren't
I? Because I've just never been that interested in making a lot of
money. Of course, I can see the advantages of being rich, and of course,
I'd like to be. But I've never placed that much importance on it. I'm
much more interested in doing something I like (programming), running my
own business (and not having to answer to a boss who's an idiot) and
having a great marriage to a woman I can spend hours talking about
nothing to. Etc.

My step-brother is a smart guy. He spends all his waking time trying to
figure out how to make more money. He's rich. I don't, and I'm not.

It's okay. I don't mind.

Paul

-- 
Paul M. Foster

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



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
I'm using COM because I don't know what else to use ;-)

Like I said, I'm new to PHP. Here is another way I communicate with the 
database, let me know if this is a better way (it requires a stored procedure):

//Assign the server connection to a variable
$connect = mssql_connect(SERVER,1433', USER, 'PASSWORD');
 
//Select your database and reference the connection
mssql_select_db('DATABASE', $connect);

// Create a new stored prodecure
$stmt = mssql_init('StoredProcedureName');

// Bind the field names
mssql_bind($stmt, '@category',$cat,SQLINT4,false,false,4);
mssql_bind($stmt, '@userid',$userid,SQLINT4,false,false,4);
mssql_bind($stmt, '@passwordtitle',$pname,SQLVARCHAR,false,false,100);
mssql_bind($stmt, '@password',$encrypted_data,SQLVARCHAR,false,false,1000);
mssql_bind($stmt, '@alt',$alt,SQLVARCHAR,false,false,150);
mssql_bind($stmt, '@desc',$desc,SQLVARCHAR,false,false,100);

// Execute 
mssql_execute($stmt);


-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
Sent: Wednesday, August 26, 2009 12:18 PM
To: Andrew Ballard
Cc: David Stoltz; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

Com function is just for Windows,I don't kown why some body like use it.:(

2009/8/27 Andrew Ballard aball...@gmail.com:
 On Wed, Aug 26, 2009 at 9:51 AM, David Stoltzdsto...@shh.org wrote:
 Sorry - I don't know what you mean by DB class?

 I'm using Microsoft SQL 2000with this code:

 ?php
 //create an instance of the  ADO connection object
 $conn = new COM (ADODB.Connection)
  or die(Cannot start ADO);
 //define connection string, specify database driver
 $connStr = PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=;
 $conn-open($connStr); //Open the connection to the database

 $query = SELECT * FROM eval_evaluations WHERE id = .$_POST[eval];

 $rs = $conn-execute($query);

 echo $rs-Fields(22); //this is where that particular field is NULL, and 
 produces the error

 


 Because you are using COM, you can't use PHP's empty(), isset(), or
 is_null() in your if(...) statement. I've not used COM for much in
 PHP, but I think you'll have to do something like this:

 switch (variant_get_type($rs-Fields(22)) {
    case VT_EMPTY:
    case VT_NULL:
        $q4 = '';
        break;

    case VT_UI1:


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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Paul M Foster
On Thu, Aug 27, 2009 at 12:25:35AM +0800, hack988 hack988 wrote:

 I'm sorry for my poor English,what is OP? I don't kown what is OP mean.

OP = Original Poster. That's usually the person who first started
(posted) a thread on a list.

Paul

-- 
Paul M. Foster

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



[PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
Looking on Amazon and other book sites, I can't even find a book for
PHP and MS SQL...

It's all PHP and MySQL...

Should I avoid developing PHP application with MS SQL databases?


-Original Message-
From: Paul M Foster [mailto:pa...@quillandmouse.com] 
Sent: Wednesday, August 26, 2009 12:38 PM
To: php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

On Thu, Aug 27, 2009 at 12:25:35AM +0800, hack988 hack988 wrote:

 I'm sorry for my poor English,what is OP? I don't kown what is OP
mean.

OP = Original Poster. That's usually the person who first started
(posted) a thread on a list.

Paul

-- 
Paul M. Foster

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


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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Ashley Sheridan
On Wed, 2009-08-26 at 12:48 -0400, David Stoltz wrote:
 Looking on Amazon and other book sites, I can't even find a book for
 PHP and MS SQL...
 
 It's all PHP and MySQL...
 
 Should I avoid developing PHP application with MS SQL databases?
 
 
 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com] 
 Sent: Wednesday, August 26, 2009 12:38 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] How to output a NULL field?
 
 On Thu, Aug 27, 2009 at 12:25:35AM +0800, hack988 hack988 wrote:
 
  I'm sorry for my poor English,what is OP? I don't kown what is OP
 mean.
 
 OP = Original Poster. That's usually the person who first started
 (posted) a thread on a list.
 
 Paul
 
 -- 
 Paul M. Foster
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
I'd definately recommend going down the MySQL route, but it may well
depend on what sort of apps you are developing and where your target
markets lie.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread sono-io


On Aug 26, 2009, at 9:28 AM, Paul M Foster wrote:


and having a great marriage to a woman I can spend hours talking about
nothing to.


I'm jealous.  Does she have a sister who's not spoken for?  =;)

Frank

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



RE: [PHP] Sockets (reading)

2009-08-26 Thread Bob McConnell
From: Philip Thompson
 
 During a socket read, why would all the requested number of bytes not

 get sent? For example, I request 1000 bytes:
 
 ?php
 $data = @socket_read ($socket, 2048, PHP_BINARY_READ);
 ?
 
 This is actually in a loop, so I can get all the data if split up. So,

 for example, here's how the data split up in 3 iterations (for 1000  
 bytes):
 
 650 bytes
 200 bytes
 150 bytes
 
 But if I can accept up to 2048 bytes per socket read, why would it not

 pull all 1000 bytes initially in 1 step? Any thoughts on this would be

 greatly appreciated!

Because that's the way TCP/IP works, by design. TCP is a stream
protocol. It guarantees all of the bytes written to one end of the pipe
will come out the other end in the same order, but not necessarily in
the same groupings. There are a number of buffers along the way that
might split them up, as well as limits on packet sizes in the various
networks it passed through. So you get what is available in the last
buffer when a timer expires, no more, and no less.

If you have serialized data that needs to be grouped in specific blocks,
your application will need to keep track of those blocks, reassembling
or splitting the streamed data as necessary. You could use UDP which
does guarantee that packets will be kept together, but that protocol
doesn't guarantee delivery.

Bob McConnell

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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread Tom Worster
On 8/25/09 5:01 AM, Stuart stut...@gmail.com wrote:

 2009/8/25 Ralph Deffke ralph_def...@yahoo.de:
 causes an error
 Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'$'' in
 C:\wamp\www\TinyCreator\testCrapp6.php on line 42
 
 This is a syntax error, not a runtime error. You've clearly done
 something wrong.
 
 Tom Worster f...@thefsb.org wrote in message
 news:c6b87877.11463%...@thefsb.org...
 is it the case that unset() does not trigger an error or throw an
 exception
 if it's argument was never set?
 
 Absolutely.
 
 -Stuart

thank you, stuart.

in the interest of wrapping up the archive of this thread on topic, may i
summarize?

in a statement like:

unset($something);

if $something is not set, i.e. isset($something) would, in the same context,
evaluate to false, the statement WILL NOT trigger an error at any level or
throw an exception.

the reason i ask is this: sometimes it's important to unset a variable at a
position in a script where as programmer i don't know if the variable is set
or not. session variables are good examples. i sure don't what reports of
such unsets in my php error logs. but i also don't want to do:

if (isset($something)) unset($something);

if i don't need to.

and the answer is: i don't.


tom



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



[PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Tom Worster
On 8/26/09 10:08 AM, tedd tedd.sperl...@gmail.com wrote:

 I had a client say to me once If you're so smart, then why aren't
 you rich?

how about: i'm smart enough that i know not to waste my allotted time on
this planet amassing riches.

i know plenty of rich people, many of whom earned their wealth. i envy the
financial security but little else of that their wealth has done to their
lives. time is really what i want more of. some wealthy trust fund types
have wealth and time but they have other problems i'm glad i don't. 



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



[PHP] Some body test php6-dev version for mbs?

2009-08-26 Thread hack988 hack988
I'm try php6-dev recently.I found it had so many diffrent with older
versions.I'll discuss with everybody in later:)
now i have a problem in php6-dev

codes follow:(warning:this code include some no-english characters and
it hex string is B2E2 In GBK char-set)
==
echo 测;
==
everything is ok in php5,php4 but a error tigger throw by php6

---
Warning: Illegal or truncated character in input: offset 0, state=0 in
F:\Programming\Web\php\maillist\charset.php on line 2

Parse error: parse error in
F:\Programming\Web\php\maillist\charset.php on line 2
PHP Warning: Illegal or truncated character in input: offset 0,
state=0 in F:\Programming\Web\php\maillist\charset.php on line 2 PHP
Parse error: parse error in
F:\Programming\Web\php\maillist\charset.php on line 2
---

I must change the php file's char-set to utf-8 for codes run successful.
Attention! Gmail's default charset is utf-8 so if any body to test
code please change the file's char-set to ansi
Any body know how use no utf-8 char-set in php6 with no-ascii char ?

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



Re: [PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote:


From: Philip Thompson


During a socket read, why would all the requested number of bytes not
get sent? For example, I request 1000 bytes:

?php
$data = @socket_read ($socket, 2048, PHP_BINARY_READ);
?

This is actually in a loop, so I can get all the data if split up.  
So,

for example, here's how the data split up in 3 iterations (for 1000
bytes):

650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it  
not
pull all 1000 bytes initially in 1 step? Any thoughts on this would  
be

greatly appreciated!


Because that's the way TCP/IP works, by design. TCP is a stream
protocol. It guarantees all of the bytes written to one end of the  
pipe

will come out the other end in the same order, but not necessarily in
the same groupings. There are a number of buffers along the way that
might split them up, as well as limits on packet sizes in the various
networks it passed through. So you get what is available in the last
buffer when a timer expires, no more, and no less.

If you have serialized data that needs to be grouped in specific  
blocks,

your application will need to keep track of those blocks, reassembling
or splitting the streamed data as necessary. You could use UDP which
does guarantee that packets will be kept together, but that protocol
doesn't guarantee delivery.

Bob McConnell


Thank you for your input.

Is it guaranteed that at least 1 byte will be sent each time? For  
example, if I know the data length...


?php
$input = '';

for ($i=0; $i$dataLength; $i++) {
// Read 1 byte at a time
if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !==  
false) {

$input .= $data;
}
}

return $input;
?

Or is this a completely unreasonable and unnecessary way to get the  
data?


Thanks,
~Philip

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



Re: [PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Richard Heyes
Hi,

 time is really what i want more of.

Personally I'd settle for a Ferrari. Or two. It would be hard, but I
think I could just about manage.

-- 
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
Lots of PHP and Javascript code - http://www.phpguru.org
50% reseller discount on licensing now available - ideal for web designers

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



Re: [PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Robert Cummings

Richard Heyes wrote:

Hi,


time is really what i want more of.


Personally I'd settle for a Ferrari. Or two. It would be hard, but I
think I could just about manage.


Might look nice in your driveway...
But without the time to drive it... :|

;)

--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Richard Heyes
Hi,

 time is really what i want more of.

 Personally I'd settle for a Ferrari. Or two. It would be hard, but I
 think I could just about manage.

 Might look nice in your driveway...
 But without the time to drive it... :|

 ;)

I actually don't have a driving license either... :-/

-- 
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
Lots of PHP and Javascript code - http://www.phpguru.org
50% reseller discount on licensing now available - ideal for web designers

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



[PHP]Some body test php6-dev version for mbs?

2009-08-26 Thread hack988 hack988
I'm try php6-dev recently.I found it had so many diffrent with older
versions.I'll discuss with everybody in later:)
now i have a problem in php6-dev

codes follow:(warning:this code include some no-english characters and
it hex string is B2E2 In GBK char-set)
==
echo 测;
==
everything is ok in php5,php4 but a error tigger throw by php6

---
Warning: Illegal or truncated character in input: offset 0, state=0 in
F:\Programming\Web\php\maillist\charset.php on line 2

Parse error: parse error in
F:\Programming\Web\php\maillist\charset.php on line 2
PHP Warning: Illegal or truncated character in input: offset 0,
state=0 in F:\Programming\Web\php\maillist\charset.php on line 2 PHP
Parse error: parse error in
F:\Programming\Web\php\maillist\charset.php on line 2
---

I must change the php file's char-set to utf-8 for codes run successful.
Attention! Gmail's default charset is utf-8 so if any body to test
code please change the file's char-set to ansi
Any body know how use no utf-8 char-set in php6 with no-ascii char ?

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



Re: [PHP] Exclusive File Access

2009-08-26 Thread Bastien Koert
On Wed, Aug 26, 2009 at 12:35 PM, Warren Vailwar...@vailtech.net wrote:
 I have two processes running on the same server, one is creating a file,
 loading it with data, and this process runs real slow.



 The second process processes a directory, finds the new file and begins
 reading the file contents.



 How do I make the reading process detect that the file is still being filled
 with data in PHP?



 Warren Vail

 Vail Systems Technology





lock it with www.php.net/flock

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Re: How to output a NULL field?

2009-08-26 Thread Bastien Koert
On Wed, Aug 26, 2009 at 12:06 PM, Andrew Ballardaball...@gmail.com wrote:
 On Tue, Aug 25, 2009 at 3:22 PM, Shawn McKenzienos...@mckenzies.net wrote:
 First off, if the value is NULL in the database then in PHP it will be
 the string NULL and not a null value as far as I remember.

 I've not seen this happen. I've found, depending on the database and
 the data access library used to interface with it that NULL usually
 comes back as either the PHP NULL value or an empty string.

 Andrew

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



One option then, might be to format the result with SQL using a CASE
WHEN THEN statement or ISNULL / IFNULL to set it to empty string

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Paul M Foster
On Wed, Aug 26, 2009 at 12:48:12PM -0400, David Stoltz wrote:

 Looking on Amazon and other book sites, I can't even find a book for
 PHP and MS SQL...
 
 It's all PHP and MySQL...
 
 Should I avoid developing PHP application with MS SQL databases?

My *opinion* is that you should avoid Microsoft products whenever
possible. BTW, you can also find books on PHP and PostgreSQL, which,
also in my *opinion* is a superior choice over MySQL.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread Paul M Foster
On Wed, Aug 26, 2009 at 09:52:49AM -0700, sono...@fannullone.us wrote:


 On Aug 26, 2009, at 9:28 AM, Paul M Foster wrote:

 and having a great marriage to a woman I can spend hours talking about
 nothing to.

   I'm jealous.  Does she have a sister who's not spoken for?  =;)

She and her sister are about as different as lions and cabbages. ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread hack988 hack988
this post is away from the point :),but everyone's reply is interesting

2009/8/27 Paul M Foster pa...@quillandmouse.com:
 On Wed, Aug 26, 2009 at 09:52:49AM -0700, sono...@fannullone.us wrote:


 On Aug 26, 2009, at 9:28 AM, Paul M Foster wrote:

 and having a great marriage to a woman I can spend hours talking about
 nothing to.

       I'm jealous.  Does she have a sister who's not spoken for?  =;)

 She and her sister are about as different as lions and cabbages. ;-}

 Paul

 --
 Paul M. Foster

 --
 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] Sockets (reading)

2009-08-26 Thread Shawn McKenzie
Bob McConnell wrote:
 From: Philip Thompson
 During a socket read, why would all the requested number of bytes not
 
 get sent? For example, I request 1000 bytes:

 ?php
 $data = @socket_read ($socket, 2048, PHP_BINARY_READ);
 ?

 This is actually in a loop, so I can get all the data if split up. So,
 
 for example, here's how the data split up in 3 iterations (for 1000  
 bytes):

 650 bytes
 200 bytes
 150 bytes

 But if I can accept up to 2048 bytes per socket read, why would it not
 
 pull all 1000 bytes initially in 1 step? Any thoughts on this would be
 
 greatly appreciated!
 
 Because that's the way TCP/IP works, by design. TCP is a stream
 protocol. It guarantees all of the bytes written to one end of the pipe
 will come out the other end in the same order, but not necessarily in
 the same groupings. There are a number of buffers along the way that
 might split them up, as well as limits on packet sizes in the various
 networks it passed through. So you get what is available in the last
 buffer when a timer expires, no more, and no less.
 
 If you have serialized data that needs to be grouped in specific blocks,
 your application will need to keep track of those blocks, reassembling
 or splitting the streamed data as necessary. You could use UDP which
 does guarantee that packets will be kept together, but that protocol
 doesn't guarantee delivery.

I'm not sure this has much to do with the OP's problem, but this part is
backwards.  TCP is connection oriented and tracks segments by sequence
number for each connection.  This enables the stack to pass the data in
order to the higher layers.  UDP is connectionless and has no way to
determine what datagram was sent before the other one, so it is up to
the higher layers to reassemble.  As for IP in general, if packets need
to be fragmented along the way by a router in order to fit the MTU of a
different network, then the IP stack on the receiving end will
reassemble the fragments based upon information that the router injects
into the fragments.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread Paul M Foster
On Thu, Aug 27, 2009 at 02:27:32AM +0800, hack988 hack988 wrote:

 this post is away from the point :),but everyone's reply is interesting
 
 2009/8/27 Paul M Foster pa...@quillandmouse.com:
  On Wed, Aug 26, 2009 at 09:52:49AM -0700, sono...@fannullone.us wrote:
 
 
  On Aug 26, 2009, at 9:28 AM, Paul M Foster wrote:
 
  and having a great marriage to a woman I can spend hours talking about
  nothing to.
 
        I'm jealous.  Does she have a sister who's not spoken for?  =;)
 
  She and her sister are about as different as lions and cabbages. ;-}

Are you seriously claiming that marriage, sisters, lions and cabbages
have *nothing* to do with setting and unsetting variables?! ;-}

Paul

-- 
Paul M. Foster

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



RE: [PHP] Sockets (reading)

2009-08-26 Thread Bob McConnell
From: Shawn McKenzie
 Bob McConnell wrote:
 From: Philip Thompson
 During a socket read, why would all the requested number of bytes
not
 
 get sent? For example, I request 1000 bytes:

 ?php
 $data = @socket_read ($socket, 2048, PHP_BINARY_READ);
 ?

 This is actually in a loop, so I can get all the data if split up.
So,
 
 for example, here's how the data split up in 3 iterations (for 1000

 bytes):

 650 bytes
 200 bytes
 150 bytes

 But if I can accept up to 2048 bytes per socket read, why would it
not
 
 pull all 1000 bytes initially in 1 step? Any thoughts on this would
be
 
 greatly appreciated!
 
 Because that's the way TCP/IP works, by design. TCP is a stream
 protocol. It guarantees all of the bytes written to one end of the
pipe
 will come out the other end in the same order, but not necessarily in
 the same groupings. There are a number of buffers along the way that
 might split them up, as well as limits on packet sizes in the various
 networks it passed through. So you get what is available in the last
 buffer when a timer expires, no more, and no less.
 
 If you have serialized data that needs to be grouped in specific
blocks,
 your application will need to keep track of those blocks,
reassembling
 or splitting the streamed data as necessary. You could use UDP which
 does guarantee that packets will be kept together, but that protocol
 doesn't guarantee delivery.
 
 I'm not sure this has much to do with the OP's problem, but this part
is
 backwards.  TCP is connection oriented and tracks segments by sequence
 number for each connection.  This enables the stack to pass the data
in
 order to the higher layers.  UDP is connectionless and has no way to
 determine what datagram was sent before the other one, so it is up to
 the higher layers to reassemble.  As for IP in general, if packets
need
 to be fragmented along the way by a router in order to fit the MTU of
a
 different network, then the IP stack on the receiving end will
 reassemble the fragments based upon information that the router
injects
 into the fragments.

Shawn,

You're looking at it inside out. Yes, the individual packets are tracked
by the stack, to make sure they arrive in the correct order. But the
size and fragmentation of those packets have no relationship at all to
any data structure the application layer may imply. They simply
implement a communications stream to reliably move octets from one point
to another. If the application needs structure, it has to manage that
for itself.

For UDP, if you write a 32 byte packet, the matching read will get a 32
byte packet, if it arrived at the receiving stack. Missed data detection
and retry requests are left up to the application.

Bob McConnell

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



[PHP] parse_ini_file problem

2009-08-26 Thread Richard H Lee

Hi all,

I think I'm having a problem with parse_ini_file in php. I am using wamp 
on two machines. I'm installing a Digishop e-commerce package.


The blah.ini.php file starts with


?php die ?


[SOMETITLE]
some_setting=Ok, I Have Completed This Step
another_setting=Next
..
..
..


On one machine which uses php 5.2.5 it parses the file fine and installs 
properly


But on another machine which use 5.3.0 i get the error

Warning: parse error in blah.ini.php on line 1 in myparser.php on line 81

On the 5.3.0 if I remove the ?php die ? it works fine. But it still 
does not install the sofware properly.


I get the feeling php on the 5.3.0 marchine is parsing the file 
differently to the 5.2.5. I doubt anything has changed between the 
versions. I also compared the phpinfos between the two setups but could 
not see anything outstanding.


Have any of you guys seen this behaviour before?

Cheers,

Richard

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



RE: [PHP] Sockets (reading)

2009-08-26 Thread Bob McConnell
From: Philip Thompson
 On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote:
 From: Philip Thompson

 During a socket read, why would all the requested number of bytes
not
 get sent? For example, I request 1000 bytes:

 ?php
 $data = @socket_read ($socket, 2048, PHP_BINARY_READ);
 ?

 This is actually in a loop, so I can get all the data if split up.  
 So,
 for example, here's how the data split up in 3 iterations (for 1000
 bytes):

 650 bytes
 200 bytes
 150 bytes

 But if I can accept up to 2048 bytes per socket read, why would it  
 not
 pull all 1000 bytes initially in 1 step? Any thoughts on this would

 be
 greatly appreciated!

 Because that's the way TCP/IP works, by design. TCP is a stream
 protocol. It guarantees all of the bytes written to one end of the  
 pipe
 will come out the other end in the same order, but not necessarily in
 the same groupings. There are a number of buffers along the way that
 might split them up, as well as limits on packet sizes in the various
 networks it passed through. So you get what is available in the last
 buffer when a timer expires, no more, and no less.

 If you have serialized data that needs to be grouped in specific  
 blocks,
 your application will need to keep track of those blocks,
reassembling
 or splitting the streamed data as necessary. You could use UDP which
 does guarantee that packets will be kept together, but that protocol
 doesn't guarantee delivery.
 
 Thank you for your input.
 
 Is it guaranteed that at least 1 byte will be sent each time? For  
 example, if I know the data length...
 
 ?php
 $input = '';
 
 for ($i=0; $i$dataLength; $i++) {
  // Read 1 byte at a time
  if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !==  
 false) {
  $input .= $data;
  }
 }
 
 return $input;
 ?
 
 Or is this a completely unreasonable and unnecessary way to get the  
 data?

While I have written a lot of code to manage sockets over the years, and
coded a UDP/IP stack, I have never done it in PHP. And unfortunately, I
don't have time to experiment right now. My boss is waiting for the next
product release from me.

Getting one byte at a time is somewhat wasteful, as it requires more
system calls than necessary. That's a lot of wasted overhead.

Whether you always get one or more bytes depends on a number of factors,
including whether the calls PHP uses are blocking or non-blocking, plus
there may be ways to switch the socket back and forth.

Have you tried doing a Google search on the group of PHP functions you
expect to use. That should come up with some sample code to look at.

Bob McConnell

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



Re: [PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

On Aug 26, 2009, at 2:47 PM, Bob McConnell wrote:


From: Philip Thompson

On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote:

From: Philip Thompson


During a socket read, why would all the requested number of bytes

not

get sent? For example, I request 1000 bytes:

?php
$data = @socket_read ($socket, 2048, PHP_BINARY_READ);
?

This is actually in a loop, so I can get all the data if split up.
So,
for example, here's how the data split up in 3 iterations (for 1000
bytes):

650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it
not
pull all 1000 bytes initially in 1 step? Any thoughts on this would



be
greatly appreciated!


Because that's the way TCP/IP works, by design. TCP is a stream
protocol. It guarantees all of the bytes written to one end of the
pipe
will come out the other end in the same order, but not necessarily  
in

the same groupings. There are a number of buffers along the way that
might split them up, as well as limits on packet sizes in the  
various

networks it passed through. So you get what is available in the last
buffer when a timer expires, no more, and no less.

If you have serialized data that needs to be grouped in specific
blocks,
your application will need to keep track of those blocks,

reassembling

or splitting the streamed data as necessary. You could use UDP which
does guarantee that packets will be kept together, but that protocol
doesn't guarantee delivery.


Thank you for your input.

Is it guaranteed that at least 1 byte will be sent each time? For
example, if I know the data length...

?php
$input = '';

for ($i=0; $i$dataLength; $i++) {
// Read 1 byte at a time
if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !==
false) {
$input .= $data;
}
}

return $input;
?

Or is this a completely unreasonable and unnecessary way to get the
data?


While I have written a lot of code to manage sockets over the years,  
and
coded a UDP/IP stack, I have never done it in PHP. And  
unfortunately, I
don't have time to experiment right now. My boss is waiting for the  
next

product release from me.

Getting one byte at a time is somewhat wasteful, as it requires more
system calls than necessary. That's a lot of wasted overhead.

Whether you always get one or more bytes depends on a number of  
factors,
including whether the calls PHP uses are blocking or non-blocking,  
plus

there may be ways to switch the socket back and forth.

Have you tried doing a Google search on the group of PHP functions you
expect to use. That should come up with some sample code to look at.

Bob McConnell


I agree that one byte at a time is wasteful. I'm sure others haven't  
implemented something along these lines, but I wrote a much more  
efficient way to make sure I grab all the data of a known length...


?php
function readSocketForDataLength ($socket, $len)
{
$offset = 0;
$socketData = '';

while ($offset  $len) {
if (($data = @socket_read ($socket, $len - $offset,  
PHP_BINARY_READ)) === false) {

return false;
}

$offset += strlen ($data);
$socketData .= $data;
}

return $socketData;
}
?

If not all the data is obtained on a read, it will loop until the  
amount of data is the same as the length requested. This is working  
quite well.


Thanks Bob and the others!

~Philip

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



Re: [PHP] Re: unset() something that doesn't exist

2009-08-26 Thread Stuart
2009/8/26 tedd tedd.sperl...@gmail.com:
 At 2:12 PM +0100 8/26/09, Stuart wrote:

 2009/8/26 tedd tedd.sperl...@gmail.com:

   And, we all need a holiday...

 Apparently a holiday is out of the question, so I've decided to change
 jobs instead. A new environment, that's all I need.

 Loving your view of this list as a hierarchy of idiots btw, I think
 that works as a description for a lot of places.

 -Stuart


 -Stuart:

 I hope your new job still includes this list.

Unfortunately I've already had to cut down a lot on the time I spend
doing stuff like this list in my current job, and that's unlikely to
change when I take up my new role. I dip in when I can, and still try
to have fun with it ;-)

 As for the hierarchy of idiots, but of course -- if we weren't idiots we
 would be doing something that made lot's of money.

 I had a client say to me once If you're so smart, then why aren't you
 rich? I answered quickly What makes you think I'm not? But privately his
 comment cut me to the quick. There was no question that much dumber people
 than me (according to me) were making far more bucks than I was.

 So, who's the smart one? Is it the guy that went to college to get three
 degrees to work his ass off for a moron who pays a a fraction of what he
 makes on the deal? Or is it the moron who sniffs out the deal and gets
 idiots to work for him?

There are some *very* lucky people out there who get away with doing
and/or knowing very little, with minimal intelligence but who manage
to get paid over-the-top amounts for it. In my experience they are the
type of person for whom money is the goal. I hate that attitude and it
says more about society in general than such an individual.

For me money has never been a core driver in my life, mainly because
I've been fortunate to usually have a job that pays well enough to
provide me with everything I need, but so far I've never felt it was
excessive.

IMHO the richest person in the world is the one who would still do
what they get paid for after they've won £100m on the lottery. Having
a job you love so much that you can't imagine not doing it is the holy
grail. I reckon I'm pretty close to that because I love my job (both
current and new) and the only thing I would change if I could would be
to own the company rather than work for it, but that would change
little in my day-to-day activities.

 It appears that the world is made up of morons and idiots -- the problem is
 that idiots do all the work and morons make all the money. The smarter the
 idiot, the more work that's available. The craftier the moron, the more
 money they make and thus the more idiots they hire.

If you ask me you are essentially describing engineers (or doers) as
idiots and salespeople as morons. I won't debate the labels but
unfortunately it's a fact of life that most management types in this
world are ex-sales because they're the ones who know how to use their
skills to further their career which them in a position to favour
sales over engineering when it comes to salary and rewards.

I've worked in a number of organisations where the sales staff were
treated like rock stars and the people who did the actual work were
treated like commodities - easily replaced. I've also worked in (and
now insist on only working for) organisations that recognise that
building stuff is as important, if not more so than being able to sell
it.

When it comes to software, especially since the (and I really hate the
term, but) Web 2.0 label took off it's become increasingly clear that
a good product will sell itself through personal recommendations many
times more successfully than a glossy ad campaign. It's also being
recognised that a fair proportion of the public now object to being
sold something by pretentious, over-confident, pushy salespeople, and
it's fairly likely they'll be put off buying whatever their selling
regardless of what it is. This, I think, is the source of the recent
switch in focus from polished advertising to polished products.

This switch coupled with the low cost of distributing software via the
internet has created the perfect environment for small companies to
create great products and compete effectively with traditional
shrink-wrapped software publishers. And long may it continue. Better
quality software is better for everyone, users and developers alike.

Incidentally, I should say at this point that if PHP has one weakness
in this brave new world its that the barrier to entry is far too low.
It's just too easy to do it wrong and get away with it. Most languages
specifically aimed at web development suffer from the same problem,
but PHP seems to have special skills in this area.

I've been recruiting for my replacement recently (drop me a note if
you're interested in a lead developer role in a financially stable
UK-based company) and as with every time I recruit PHP developers it
scares me the number of people out there commanding decent salaries
when they really don't know what 

Re: [PHP] parse_ini_file problem

2009-08-26 Thread Jim Lucas
Richard H Lee wrote:
 Hi all,
 
 I think I'm having a problem with parse_ini_file in php. I am using wamp
 on two machines. I'm installing a Digishop e-commerce package.
 
 The blah.ini.php file starts with
 
 
 ?php die ?
 
 
 [SOMETITLE]
 some_setting=Ok, I Have Completed This Step
 another_setting=Next
 ..
 ..
 ..
 
 
 On one machine which uses php 5.2.5 it parses the file fine and installs
 properly
 
 But on another machine which use 5.3.0 i get the error
 
 Warning: parse error in blah.ini.php on line 1 in myparser.php on line 81
 
 On the 5.3.0 if I remove the ?php die ? it works fine. But it still
 does not install the sofware properly.
 
 I get the feeling php on the 5.3.0 marchine is parsing the file
 differently to the 5.2.5. I doubt anything has changed between the
 versions. I also compared the phpinfos between the two setups but could
 not see anything outstanding.
 
 Have any of you guys seen this behaviour before?
 
 Cheers,
 
 Richard
 

I would write a little line to your cli like this

php -r 'print_r(parse_ini_file(/path/to/your/ini.file.php));'

see if the output is different.  If it is, then you know that the two
versions are doing something different.

If you find that the output is different and you have more questions
please provide the output from php -v from both machines and we might
be able to help further.




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



Re: [PHP] What if this code is right ? It worked perfectly for years!!

2009-08-26 Thread Ben Dunlap
 ?
  $fName = $_REQUEST['fName'] ;
  $emailid = $_REQUEST['emailid'] ;
    $number = $_REQUEST['number'] ;
  $message = $_REQUEST['message'] ;

  mail( ch...@gmail.com, $number, $message, From: $emailid );
  header( Location: http://www.thankyou.com/thankYouContact.php; );
 ?

This is a bit of a hang-up of mine so forgive me if it's mildly OT,
but if you do figure out what the problem is, and fix it, you may want
to revisit this code in a more extensive way, if what you've pasted
above is exactly the code you use in your live application. Please
ignore if you've simplified the code above for simplicity's sake.

At any rate the code above is most likely vulnerable to SMTP
injection, because it passes the unfiltered value of '$emailid' as
part of the 'additional_headers' argument to mail().

So the form could be used to send spam to arbitrary email addresses.
I'd recommend using filter_input(), with the FILTER_VALIDATE_EMAIL
filter, to get at the 'emailid' parameter:
http://us3.php.net/manual/en/function.filter-input.php

Ben

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



Re: [PHP] How to output a NULL field?

2009-08-26 Thread Phpster





On Aug 26, 2009, at 12:31 PM, David Stoltz dsto...@shh.org wrote:


I'm using COM because I don't know what else to use ;-)

Like I said, I'm new to PHP. Here is another way I communicate with  
the database, let me know if this is a better way (it requires a  
stored procedure):


//Assign the server connection to a variable
$connect = mssql_connect(SERVER,1433', USER, 'PASSWORD');

//Select your database and reference the connection
mssql_select_db('DATABASE', $connect);

// Create a new stored prodecure
$stmt = mssql_init('StoredProcedureName');

// Bind the field names
mssql_bind($stmt, '@category',$cat,SQLINT4,false,false,4);
mssql_bind($stmt, '@userid',$userid,SQLINT4,false,false,4);
mssql_bind($stmt, '@passwordtitle',$pname,SQLVARCHAR,false,false,100);
mssql_bind($stmt, '@password',$encrypted_data,SQLVARCHAR,false,false, 
1000);

mssql_bind($stmt, '@alt',$alt,SQLVARCHAR,false,false,150);
mssql_bind($stmt, '@desc',$desc,SQLVARCHAR,false,false,100);

// Execute
mssql_execute($stmt);


-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com]
Sent: Wednesday, August 26, 2009 12:18 PM
To: Andrew Ballard
Cc: David Stoltz; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

Com function is just for Windows,I don't kown why some body like use  
it.:(


2009/8/27 Andrew Ballard aball...@gmail.com:

On Wed, Aug 26, 2009 at 9:51 AM, David Stoltzdsto...@shh.org wrote:

Sorry - I don't know what you mean by DB class?

I'm using Microsoft SQL 2000with this code:

?php
//create an instance of the  ADO connection object
$conn = new COM (ADODB.Connection)
 or die(Cannot start ADO);
//define connection string, specify database driver
$connStr =  
PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=;

$conn-open($connStr); //Open the connection to the database

$query = SELECT * FROM eval_evaluations WHERE id = .$_POST 
[eval];


$rs = $conn-execute($query);

echo $rs-Fields(22); //this is where that particular field is  
NULL, and produces the error






Because you are using COM, you can't use PHP's empty(), isset(), or
is_null() in your if(...) statement. I've not used COM for much in
PHP, but I think you'll have to do something like this:

switch (variant_get_type($rs-Fields(22)) {
   case VT_EMPTY:
   case VT_NULL:
   $q4 = '';
   break;

   case VT_UI1:



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



MS has developed and released a new version of the mssql drivers for  
php. It might be worth investigating that to see ifthat firs your needs.


Bastien

Sent from my iPod

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



Re: [PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Jason Pruim


On Aug 26, 2009, at 1:23 PM, Tom Worster wrote:


On 8/26/09 10:08 AM, tedd tedd.sperl...@gmail.com wrote:


I had a client say to me once If you're so smart, then why aren't
you rich?


how about: i'm smart enough that i know not to waste my allotted  
time on

this planet amassing riches.

i know plenty of rich people, many of whom earned their wealth. i  
envy the
financial security but little else of that their wealth has done to  
their
lives. time is really what i want more of. some wealthy trust fund  
types

have wealth and time but they have other problems i'm glad i don't.



I know this is a little old, but I've been busy and I wanted to chime  
in on this :)


Wealth is many things to many people... Me personally... I'm poor with  
money, but rich with spirit and other blessings... I have a loving  
wife, and two boys that think I'm the king of the world and I could do  
anything. I'd like to cover my bills a little better, and put  
something away for retirement and there college funds... but that's  
all I need :)




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