php-general Digest 19 Jan 2005 11:08:01 -0000 Issue 3236

2005-01-19 Thread php-general-digest-help

php-general Digest 19 Jan 2005 11:08:01 - Issue 3236

Topics (messages 206719 through 206735):

$_SERVER['HTTP_USER_AGENT'] in html email
206719 by: Graham Anderson
206722 by: Graham Anderson

Re: Recursive Array Iterator
206720 by: Gerard Samuel

Re: searching and sorting
206721 by: Brian A. Anderson
206723 by: Michael Sims

How to access remote files with php?
206724 by: Sephiroth

Re: Writing static file from dynamic PHP page
206725 by: Hugh Danaher

Nested SQL Statements
206726 by: Greg Cullen

Re: Pagination Optimization
206727 by: yangshiqi

debugging
206728 by: William Stokes
206732 by: Justin French
206733 by: William Stokes

my for loop's gone bananas.. has yours?
206729 by: Tim Burgan
206731 by: Binoy AV
206735 by: Ford, Mike

SPL Exceptions
206730 by: Gerard Samuel
206734 by: M. Sokolewicz

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
php-general@lists.php.net


--
---BeginMessage---
is it possible to use $_SERVER['HTTP_USER_AGENT'] in an html email ?
something like:
//What should we download based on user's platform ?
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== FALSE) {
$download  = 'Fonovisa.dmg';
echo 'Mac';
}
else
{
echo 'PC';
$download = '!Fonovisa.exe';
}
---End Message---
---BeginMessage---
What would be the standard/accepted  way to do this?
is it better to spell it out in the html email ?
Download:
Mac PC  Linux ?
many thanks :)
On Jan 18, 2005, at 4:06 PM, [EMAIL PROTECTED] 
wrote:

php is server-side, so no. you might be able to do what you're after
with javascript, but any sensible person has that turned off in
general, and especially for html e-mail.
[remember, there are more operating systems/platforms than pc and mac
(with OS variations within those), so defaulting to download if it's
not mac would not be a nice thing to do. the download should be on the
positive match, not the fall-through.]
-- Original Message --
From: Graham Anderson [EMAIL PROTECTED]
To: php-general@lists.php.net php-general@lists.php.net
php-general@lists.php.net
Date: Tuesday, January 18, 2005 03:08:16 PM -0800
Subject: [PHP] $_SERVER['HTTP_USER_AGENT'] in html email
is it possible to use $_SERVER['HTTP_USER_AGENT'] in an html email ?
something like:
//What should we download based on user's platform ?
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== FALSE) {
$download  = 'Fonovisa.dmg';
echo 'Mac';
}
else
{
echo 'PC';
$download = '!Fonovisa.exe';
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
-- End Original Message --
---End Message---
---BeginMessage---
Gerard Samuel wrote:
Im trying to figure out how to create this.
But Im stuck in the foreach loop.
For some reason, $value in the foreach loop is not an object (Isn't is 
supposed to be?)
Any hints to get me in the right direction.
Thanks

$array = array(1 = array(2 = array(3 = array(4;
class recursiveArrayIterator extends ArrayIterator implements 
RecursiveIterator
{
   function __construct($array)
   {
   parent::__construct( $array );
   }

   function hasChildren()
   {
   }
   function getChildren()
   {
   }
}
$obj = new recursiveArrayIterator( $array );
//reflectionObject::export($obj);
foreach($obj as $value)
{
   var_dump($value);
}

Never mind.  I figured it out...
---End Message---
---BeginMessage---

Quoting: Richard Lynch [EMAIL PROTECTED]




 Unless you KNOW your site will get loads of traffic from the get-go, I'd
 focus more on the SIMPLE solutions that you can maintain as a beginner.

Quoting: Richard Lynch

 Unless you KNOW your site will get loads of traffic from the get-go, I'd
 focus more on the SIMPLE solutions that you can maintain as a beginner.

well, I have implemented a simple solution, and it is working, but I am
thinking in terms of in the coming year or two of developing more
sophisticated strategies.


 Also depending on the size and scale and scope of your data, I'm not sure
 that two separate lists is a Good Idea.

Why not? I have arount 1000 products and many searches bring up more than a
few pages worth of data. I would think that it might be good to present the
links to test files along the side.

Here is a link to the actual site:
http://www.apsistl.com/

 Amazon may need it for, their zillion items they sell, but do you, really?

 I've spent *DAYS* writing special search engines for data-sets that only
 had 100 items in them, and would never grow significantly larger than
 that.  I told my client that was pretty wasteful of their money, but
 that's what they wanted. [shrug]  Pays the bills.  But that doesn't mean
 you want to waste your 

Re: [PHP] debugging

2005-01-19 Thread William Stokes
I'm trying to get the ini_set(error_reporting,E_ALL); work. No matter what 
kind of errors I write I just get blank screen when the script fails. Do I 
need to also echo the errors to screen? Or can the error reporting be 
disabled by the server admin (my adsl operator)? so that no errors are 
printed to screen.

I just set the error reporting at the beginning of the code like:

?php
ini_set(error_reporting,E_ALL);
etc...

thanks
-Will

Justin French [EMAIL PROTECTED] kirjoitti 
viestissä:[EMAIL PROTECTED]
 On 19/01/2005, at 5:36 PM, William Stokes wrote:

 I would like to add some debugging/info code to my pages. In test
 environment of course. Any ideas how to do this? I mean for example to 
 print
 to a web page the line number when the script fails or something like 
 that.
 It's a pain on the **s to hunt typo's by just reading the source over and
 over again.

 William,

 I start by trying to programatically find out if I'm in a development or 
 production environment and setting a constant DEV to true or false.  For 
 me, I development things on my desktop Mac, so the server and client are 
 the same machine, and share the same IP address.  So my check for DEV is 
 if the client IP and server IP match.

 ? define('DEV',($_SERVER['REMOTE_ADDR']==$_SERVER['SERVER_ADDR'])); ?

 So, this then gives a constant DEV to test to decide if I'm in the 
 development or production environment, eg:

 Next, I set-up PHP's built-in error reporting for both environments:

 ?
 if(DEV)
 {
 ini_set(error_reporting,E_ALL);
 ini_set(display_errors,1);
 ini_set(log_errors,0);
 }
 else
 {
 ini_set(error_reporting,E_ALL ^ E_NOTICE);
 ini_set(display_errors,0);
 ini_set(log_errors,1);
 }
 ?

 In short, this logs most errors in production (not notices), and dumps 
 them to the screen if we're in development.  You'll already see that you 
 get quite a lot of information from the errors (line numbers, reason for 
 the error, etc), and I think this is what you're looking for.

 But so far this only caters to PHP errors triggered by built-in functions 
 and source.  Smarter programmers will build in their own debugging lines, 
 custom errors and notices to make the tracking down of bugs and quirks 
 much much easier.  For this, you can use trigger_error() 
 http://au2.php.net/trigger_error.


 That should be more than enough for the average PHP hack, but there is of 
 course the option to write your own custom error handler to customise the 
 look and feel of the error messages, send emails, log things to a 
 database, etc.

 It's all pretty powerful stuff, so read up!


 ---
 Justin French, Indent.com.au
 [EMAIL PROTECTED]
 Web Application Development  Graphic Design 

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



[PHP] Re: SPL Exceptions

2005-01-19 Thread M. Sokolewicz
Gerard Samuel wrote:
Does anyone know when the exception objects listed in
item #6 at http://www.php.net/~helly/php/ext/spl/ will be available
in base php5??
Thanks
when you install the SPL extension :) I don't think it's planned for 
php5-source though

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


RE: [PHP] my for loop's gone bananas.. has yours?

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



 -Original Message-
 From: Tim Burgan [mailto:[EMAIL PROTECTED] 
 Sent: 19 January 2005 06:19
 
 I have a for loop to create a HTML combo box that displays 
 the 10 year 
 values, starting from today's year and incrementing until 10 years it 
 reached.
 
 The output of the loop to the browser is weird.
 If anyone has time, can you please let me know where I screwed up?
 
 
 Here's my loop:
 
echo 'select name=expire_year size=1';
   
$numbOfYears = 10;
for ( $i = 0; $i  $numbOfYears; $i++ )
{
   echo 'option value='. $today_year + $i .'';

. And + have the same precedence, so their order of evaluation is decided by
their associativity; according to the table at
http://php.net/operators#language.operators.precedence, they are left
associative, so the above is interpreted as:

echo (('option value='. $today_year) + $i) .'';

   
   if ( $_SESSION['createStudent_expireYear'] == $today_year + $i )
   {
  echo ' selected=selected';
   }
   
   echo ''. $today_year + $i .'/option';

And this, similarly, will be:

echo ((''. $today_year) + $i) .'/option';

Some ways of dealing with this are:

(1) explicitly parenthesize the addition:

echo 'option value='. ($today_year + $i) .'';

(2) use the multiple parameter feature of echo:

echo 'option value=', $today_year + $i, '';

(3) recast the loop to calculate the end year in advance, which avoids
having to repeatedly do the addition:

 $numbOfYears = 10;
 for ( $y = $today_year, $end_year = $today_year+$numbOfYears;
  $y  $endYear; $y++ )
 {
echo 'option value=', $y, '';

 ... etc.

Cheers!

Mike

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

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



Re: [PHP] Re: Persistent PHP web application?

2005-01-19 Thread Jochem Maas

 A lame Example to illustrate the purpose of Application-Scope
 variables would be the persistant DB connections. Not 100% the same
 but it's for the same purpose

 So if you could have a huge object persistant( Application-Scope
 object ) that does alot of work for you then that object is a PHP
 persistant application which I call Application-Scope var or object !

 Hope that clears it out.
For single-server multi-threaded architectures this is trivial to do,
but it doesn't scale to the multi-server multi-process architecture PHP
uses.
-Rasmus
don't you just love it, the way Rasmus uses the term 'single-server 
multi-threaded architectures' and the word 'trivial' in the same 
sentence - you just know he's on another/higher level :-)



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


Re: [PHP] debugging

2005-01-19 Thread Marek Kilimajer
William Stokes wrote:
I'm trying to get the ini_set(error_reporting,E_ALL); work. No matter what 
kind of errors I write I just get blank screen when the script fails. Do I 
need to also echo the errors to screen? Or can the error reporting be 
disabled by the server admin (my adsl operator)? so that no errors are 
printed to screen.
If the script does not parse it's not executed, so your ini_set() lines 
never change the setting. Change the setting in php.ini on your dev machine.

I just set the error reporting at the beginning of the code like:
?php
ini_set(error_reporting,E_ALL);
etc...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] debugging

2005-01-19 Thread Marek Kilimajer
Justin French wrote:
On 19/01/2005, at 5:36 PM, William Stokes wrote:
I would like to add some debugging/info code to my pages. In test
environment of course. Any ideas how to do this? I mean for example to 
print
to a web page the line number when the script fails or something like 
that.
It's a pain on the **s to hunt typo's by just reading the source over and
over again.

William,
I start by trying to programatically find out if I'm in a development or 
production environment and setting a constant DEV to true or false.  For 
me, I development things on my desktop Mac, so the server and client are 
the same machine, and share the same IP address.  So my check for DEV is 
if the client IP and server IP match.

? define('DEV',($_SERVER['REMOTE_ADDR']==$_SERVER['SERVER_ADDR'])); ?
Interesting. So I just need to use the same hosting server as you do and 
your scripts will tell me interesting facts ;)

I use simple define('DEBUG', true'); in the main config file where also 
database login info is stored.

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


[PHP] Dates, times, timezones...

2005-01-19 Thread Bruno B B Magalhães
Hi everybody,
How do you save the date and time in the database? Time stamp or date 
and time? GMT timezone or the server timezone, or maybe the configs 
timezone? And when displaying apply user timezone to the GMT date?

I think it's easier to save in timestamp format, so it's easy to 
convert to any format and to do math with dates Is this the way?

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


[PHP] Name of CRON visualiser script

2005-01-19 Thread Erwin Kerk
Hi All,
I've seen a script somewhere which accepts a crontab file for input, and 
then displays all jobs in a calendar-like screen. However, I forgot the 
name. Searching Google didn't help me either.

Does anyone know the name (and if possible, an url) of this script?
Thanks in advance,
Erwin Kerk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] debugging

2005-01-19 Thread Justin French
On 19/01/2005, at 10:51 PM, Marek Kilimajer wrote:
Justin French wrote:
On 19/01/2005, at 5:36 PM, William Stokes wrote:
I would like to add some debugging/info code to my pages. In test
environment of course. Any ideas how to do this? I mean for example 
to print
to a web page the line number when the script fails or something 
like that.
It's a pain on the **s to hunt typo's by just reading the source 
over and
over again.
William,
I start by trying to programatically find out if I'm in a development 
or production environment and setting a constant DEV to true or 
false.  For me, I development things on my desktop Mac, so the server 
and client are the same machine, and share the same IP address.  So 
my check for DEV is if the client IP and server IP match.
? define('DEV',($_SERVER['REMOTE_ADDR']==$_SERVER['SERVER_ADDR'])); 
?
Interesting. So I just need to use the same hosting server as you do 
and your scripts will tell me interesting facts ;)
That's a good point... Not that by debugging lines have anything 
dangerous in them, but it's still not right... Thanks... I think I'll 
revisit that line of code before anything goes live :)

I use simple define('DEBUG', true'); in the main config file where 
also database login info is stored.
I like to use exactly the same files for both development and live 
servers... it makes it much easier to mirror the site via FTP, commit 
via SVN, etc.

---
Justin French, Indent.com.au
[EMAIL PROTECTED]
Web Application Development  Graphic Design
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Need best way to determine if cronjob or external browser called my script

2005-01-19 Thread Al
I'm working on a script that can be initiated by a cronjob or from a browser.
I want the script to act differently depending on which one called it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Nested SQL Statements

2005-01-19 Thread Jay Blanchard
[snip]
Relatively new to PHP.  Having an issue trying to nest sql statements. 
Basically I am trying to pull a variable from SQL1, Pass it as a 
Variable/Bind or Parm to SQL2 and then Go back to SQL1 and pull the next

value and pass to SQL2 again for processing.

$result1 = mysql_query('show tables',$dbc);
   if ($myrow1 = mysql_fetch_array($result1))
{
  // display list if there are records to display
  $tmptablename = sprintf(describe {$myrow1[0]});
 do {
  $result2 = mysql_query($tmptablename,$dbc);
  echo Table: {$myrow1[0]};
[/snip]

You are not looping through $result1, so you will only get the first
return. Try this for your queries(using error checking)

if(!($result1 = mysql_query(SHOW TABLES, $dbc))){
echo mysql_error() . \n;
exit();
}

while($myrow = mysql_fetch_array($result1)){
if(isset($myrow)){ //checks that the row is not empty
$tmptablename = sprintf(describe $myrow[0]\n);
echo Table:  . $myrow[0] . \n;
$result2 = mysql_query($tmptablename, $dbc); //bad, no
error checking
while($mycolumnarray = mysql_fetch_array($result2)){
echo \t . $mycolumnarray[0] . \n;
}
}
}
This returns the following from a test database--

Table: maxTest
id
theData
Table: maxTest1
id
theData
Table: table1
ID
condition
Table: table2
ID
ID_table1
value
Table: tblSOALocalMockup
aid
orderID
orderDate
dueDate
custName
custType
orderStatus
curOwner
comments
checkedOut





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



RE: [PHP] Need best way to determine if cronjob or external browser calledmy script

2005-01-19 Thread Jay Blanchard
[snip]
I'm working on a script that can be initiated by a cronjob or from a
browser.

I want the script to act differently depending on which one called it.
[/snip]

COOL!

I am suspecting that there is a question here, and I suspect the
question is how do I do this? To see if the browser called it you can
check the $_SERVER array http://us2.php.net/reserved.variables or you
could pass an arguement from the browser that identifies the browser. If
that argument exists the browser has called it, if not, the CRON job has
called it. You could also pass an arguement from the CRON command as
well.

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



[PHP] Storing a reference to an object in another object

2005-01-19 Thread Rory McKinley
Hi All
This is probably just a case of me being Mr Thicky, but maybe someone 
can point out the error mf my ways:

I have two classes, call them admin and module. Admin stores login 
details as well as a pointer to the DB connection. Module will run 
various queries. To do that it needs access to the DB connection 
maintained by Admin. Because I don't want to have to keep on passing the 
reference to the admin instance, I thought I would store the reference 
to the admin instance within the module instance when the object is created:

class Module
{
private $admin_instance;
function __construct($admin_instance)
{
$this-admin_instance = $admin_instance;
}
public function checkConnection()
{
return $this-admin_instance-checkConnection()
}
}
I am using PHP 5 so the reference should be passed and stored in the 
relevant object attribute, not so?

Yet, if i call checkConnection it tells me that I am calling a method on 
a non-object.print_r() of the module instance  makes things even more 
confusing: print_r returns:

 [admin_instance:private] = [class_name] = blah [admin_instance] = 
Admin Object

which is followed by the various attributes of the admin object 
suggesting that the reference to the admin object is indeed within the 
module instance.

I hope someone can help with this..
Oh, and before anybody asks I am still busy RTFM, STFW, STFA but with no 
joy so far.

--
Rory McKinley
Nebula Solutions
+27 21 555 3227 - office
+27 21 551 0676 - fax
+27 82 857 2391 - mobile
www.nebula.co.za

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


[PHP] Re: How to access remote files with php?

2005-01-19 Thread Jason Barnett
Sephiroth wrote:
Hi all,
How to access remote files with php?
For ex:
$sFile = http://www.php.net/123.txt;;
if (file_exists($sFile)) {
  $hFile = fopen($sFile);
  ...
  fclose($hFile);
}
Regards,
Sephiroth
You can use the file functions with URLs so long as you have 
allow_url_fopen set to TRUE in your php.ini.

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Help with encryption

2005-01-19 Thread Brian Dunning
Here is a class that uses mcrypt that might be helpful:
Tom - this class is awesome. Took 5 seconds to add to my site and 
worked like a charm on the first try. THANKS!!  :)

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


[PHP] Re: Windows CLI and task scheduler

2005-01-19 Thread Dominic Schanen
I changed the scheduled task to use php.exe instead of php-win.exe and 
that cleared up the errors with unloading the profile that were 
appearing in the application log. Could this possibly be a bug with 
php-win.exe and not cleaning up properly?

Thanks,
Dominic
Dominic Schanen wrote:
I've written several command line scripts to run as scheduled tasks on a 
Windows 2000 Server machine. They run fine, no problems. However, the 
application log is filling up with errors stating that windows was 
unable to unload my registry profile. I know the PHP scripts are at 
fault because the errors are being recorded at the same intervals as my 
scheduled tasks.

I installed UPHClean to cleanup the unloaded profiles but that simply 
doubles the number of log entries created.

I was wondering if anyone else has run into this problem? Is this a task 
scheduler problem or a PHP problem? If it is a task scheduler problem, 
is there something I can do by exiting or closing differently in PHP?

I have PHP 5.0.3 and am using php-win.exe
Thanks,
Dominic
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: SPL Exceptions

2005-01-19 Thread Gerard Samuel
M. Sokolewicz wrote:
Gerard Samuel wrote:
Does anyone know when the exception objects listed in
item #6 at http://www.php.net/~helly/php/ext/spl/ will be available
in base php5??
Thanks
when you install the SPL extension :) I don't think it's planned for 
php5-source though

Correct me if Im wrong.  But isn't the SPL extension already part (as in 
by default)
of php5??
Currently, Im running php 5.0.3 installed via freebsd's ports,
and the SPL extension is enabled, and according to phpinfo, and 
get_declared_classes(),
I dont have those exception objects.

SPL support = enabled
Interfaces = RecursiveIterator, SeekableIterator
Classes = ArrayObject, ArrayIterator, CachingIterator, 
CachingRecursiveIterator, DirectoryIterator, FilterIterator, 
LimitIterator, ParentIterator, RecursiveDirectoryIterator, 
RecursiveIteratorIterator

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


Re: [PHP] debugging

2005-01-19 Thread Bret Hughes
On Wed, 2005-01-19 at 05:51, Marek Kilimajer wrote:
 Justin French wrote:
  On 19/01/2005, at 5:36 PM, William Stokes wrote:
  
  I would like to add some debugging/info code to my pages. In test
  environment of course. Any ideas how to do this? I mean for example to 
  print
  to a web page the line number when the script fails or something like 
  that.
  It's a pain on the **s to hunt typo's by just reading the source over and
  over again.
  
  
  William,
  
  I start by trying to programatically find out if I'm in a development or 
  production environment and setting a constant DEV to true or false.  For 
  me, I development things on my desktop Mac, so the server and client are 
  the same machine, and share the same IP address.  So my check for DEV is 
  if the client IP and server IP match.
  
  ? define('DEV',($_SERVER['REMOTE_ADDR']==$_SERVER['SERVER_ADDR'])); ?
 
 Interesting. So I just need to use the same hosting server as you do and 
 your scripts will tell me interesting facts ;)
 
 I use simple define('DEBUG', true'); in the main config file where also 
 database login info is stored.
 

for complicated stuff I will usually place if $(DEBUG N ){echo stuff}
lines in the code so I can easily print interesting stuff in various
parts of the script then if I hit a problem place a $DEBUG=1; or
whatever level I want at the top of the script;  This way I can turn it
off and on without making code changes other than setting $DEBUG = 0;
when moving to production.  This causes some additional work in
production but I suppose if I had that many ifs in there I could write a
script to remove the $DEBUG { } blocks from the code during the move to
production.

Since we are on the topic, does anyone have such an animal? If I write
one, would anyone be interested in it?

Bret

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



[PHP] Re: Windows CLI and task scheduler

2005-01-19 Thread Jason Barnett
Dominic Schanen wrote:
I changed the scheduled task to use php.exe instead of php-win.exe and 
that cleared up the errors with unloading the profile that were 
appearing in the application log. Could this possibly be a bug with 
php-win.exe and not cleaning up properly?

Thanks,
Dominic
Honestly, I don't know why you would choose php-win.exe over php.exe.  I 
use php.exe for command line scripting as well as scheduled tasks and it 
has always functioned like I expected it to.  Does anyone else have 
input here on why to choose php-win over php?

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Writing static file from dynamic PHP page

2005-01-19 Thread John Hicks
Chris Bruce wrote:
Hi,
I am looking for a way to write to a file what the browser would see 
(raw html) when viewing a dynamic PHP page. I have numerous include 
files, MySQL db queries, loops etc. and I want to generate the static 
result of that file and save it as an html page. I have toyed a little 
with output buffering to no avail.

Is there an easy way to do this?
Thanks,
Chris
Here's a great article on the subject from the Zend website:
http://www.zend.com/zend/art/scriptcaching.php
It's a little more complex than you would hope but is well thought out.
--Separate directories is set up to hold the php source and the cached html.
--The cached html directory is initially empty.
--An Apache ErrorDocument directive is used to intercept the 404 
document not found error when someone is requesting a page and to 
redirect it to a single caching script.
--This caching script uses fopen() to open and then read the php script 
and to write the output to the cached html directory.

Hats off to Zend for publishing this. It competes with their Zend Cache 
product. From the article:

If your site contains a few small scripts, you may not need to bother 
with caching at all. On the other hand, if you rely on complex scripts 
and fresh data, you should use a much more sophisticated solution, such 
as the Zend Cache http://www.zend.com/store/products/zend-cache.php. 
But if you are somewhere in between, I hope this article will be of help 
to you. If you have any comments, please feel free to email me.

(Sorry to take so long to post this. I had remembered reading the 
article but couldn't find it. Finally thought to do a Google for 404 
php cache.)

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


Re: [PHP] searching and sorting

2005-01-19 Thread John Hicks
Michael Sims wrote:
Richard Lynch wrote:
 

Brian A. Anderson wrote:
   

[...]
 

I am thinking of incrementally adding the resultant hits into two
associative arrays with the link to the data and a calculated
relevance value, and sorting this array by these relevences.
 

[...]
 

One Axiom: Keep as much of the scoring/sorting in your SQL as
possible -- That's what SQL engines are best at.
   

I suggest the original poster look into some of the full text indexing
capabilities of his SQL server.  A lot of these (for PostgreSQL and MySQL
anyway) will automatically return a relevance value and handle sorting based
on that.  As you said, that'll be a heck of a lot more efficient and easier
to implement that doing it in PHP.
 

Agreed. I use MySQL's full-text indexing and sort by the relevance 
score, and it works well.

If you do a search for a business at this (now retired) site: 
http://lwcc.gulfbridge.com , you'll see the relevance scores in 
parentheses next to each result. One trick I use to limit the display to 
the most relevant items is to look for a significant drop in this score 
from one item to the next. I stop listing when the score drops by 40% or 
so from the last item displayed.

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


[PHP] Anyone attending PHP Tropics?

2005-01-19 Thread Jeremiah Johnson
Hi All,

I'm wondering if anyone is planning on attending PHP Tropics
(www.phparch.com/tropics), and if so whether anyone would be
interested in splitting a room with a non-smoker.

Thanks,


Jeremiah

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



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

2005-01-19 Thread Xuefer Tinys
i have a big array with 20k elements, i have no problem building it,
because the elements is recv from socket, i can socket_select() on 1k
clients, read from them.
i plan to unset the whole array every 1hour
this is a not big problem when for a few times, it takes me 0.02 seconds
but after many hours of running, unset will sometime takes 10 seconds.
this is big problem because it's 1 unset() statement, and all incoming
connection is blocked, the client may get connection time out

summary:
1. one process, no fork (just has to be)
2. socket_select(), process each client's data simultaneously. some
data will be put into array
3. each element value is /true/, and key is numeric(ip2long)
$array[ip2long($ip)] = true;
4. fast to unset, but slow to unset after a few hours, with similar
amount of elements

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



Re: [PHP] Need best way to determine if cronjob or external browser called my script

2005-01-19 Thread Bret Hughes
On Wed, 2005-01-19 at 07:47, Al wrote:
 I'm working on a script that can be initiated by a cronjob or from a browser.
 
 I want the script to act differently depending on which one called it.
 
 -- 

I do not know what the definitive answer is but there are a bunch of
environment differences.  Here is one taken from 

http://us2.php.net/features.commandline

[EMAIL PROTECTED] elevatetest]$ cat testbrowser.php
?php
if ($_SERVER['SERVER_PORT']) { echo SERVER MODE\n; } 
else { echo CLI MODE\n; } 
?


results from wget:

[EMAIL PROTECTED] elevatetest]$ wget -q --output-document=-
https://localhost/elevatetest/testbrowser.php 
SERVER MODE
[EMAIL PROTECTED] elevatetest]$ 

results from cli 

[EMAIL PROTECTED] elevatetest]$ php testbrowser.php 
Content-type: text/html
X-Powered-By: PHP/4.3.6

CLI MODE
[EMAIL PROTECTED] elevatetest]$ 

mozilla returns 

SERVER MODE

HTH

Bret

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



[PHP] Best way to encode?

2005-01-19 Thread Brian Dunning
I have a form where people input some text, which is then incorporated 
into an HTML snippet which appears in a textarea for them to copy  
paste into a web page.

People will be entering foreign language stuff as well as special 
characters like copyright, so I have to be sure this is handled 
properly.

I tried rawurlencode() but that results in HTML which displays the 
encoding when they paste it into their web page. I tried htmlentities 
but that gives different characters than what they typed when displayed 
in the textarea. I also tried no encoding, which worked well, except 
that it gets messed up when I try to write it to the database and I 
have the same problem again when retrieving it.

Cañon © is a good example.
htmlentities('Cañon ©') - Cañon © in the textarea, displays on their 
web page as Cañon ©, but reads/writes OK from the database.
rawurlencode('Cañon ©') - Ca%C3%B1on%20%C2%A9 in the textarea, 
displays on their web page as Ca%C3%B1on%20%C2%A9, but reads/writes OK 
from the database.
No encoding gives Cañon © in the textarea and displays on their web 
page as Cañon ©, but appears in the database as Cañon ©

How can I handle this so that what ultimately displays on their web 
page, after copying the HTML out of the textarea, matches what they 
typed in the form, and yet can be read  written from the database 
properly?

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


[PHP] select-option link list

2005-01-19 Thread William Stokes
Hello,

Hope someone can give some directions...

I'm trying to create a list box of links to other pages. I just can't figure 
out how to move to the other page whe user selects one of the options in the 
list box.

here's the code...

$sql=SELECT team_name FROM teams;
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
print form name=\form1\ method=\post\ action=\select_team.php\;
print select name=\select_team\ size=\1\  ;
while ($num = $cur) {
$row = mysql_fetch_array($result);
$team_name = $row[team_name ];
print option$team_name /option;
$cur++;
}
print /select;
print input type=\submit\ value=\Go!\;
print /form;

This propably can be don without the Go button. But i Don't know how...

Thank a lot
-Will
BTW thanks for the debugging stuff earlier. Got that workin... 

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



Re: [PHP] Re: get user attributes php/ldap/win2k active directory

2005-01-19 Thread Redmond Militante
Date: Fri, 14 Jan 2005 15:32:15 -0600
From: Redmond Militante [EMAIL PROTECTED]
To: php-general@lists.php.net
Subject: Re: [PHP] Re: get user attributes php/ldap/win2k active directory
Reply-To: Redmond Militante [EMAIL PROTECTED]
In-Reply-To: [EMAIL PROTECTED]
User-Agent: Mutt/1.4.2.1i
X-Sender: [EMAIL PROTECTED]
X-URL: http://darkpossum.medill.northwestern.edu/gnupg.php
X-PGP-Fingerprint: 2AA2 E78E A6FC 9144 3534  39A2 EE0F 8D26 5FDF 481D

hi

this solution, along with ldap browser, worked for me.
however, now i want to change my search string and i'm having problems...

i'm using
$sr = ldap_search($ldapconn,CN=Users,DC=companyname,DC=com, 'CN='.$username);

to search through the ldap directory for the username.  this works fine.

but if i try
$sr = ldap_search($ldapconn,CN=staff,CN=Users,DC=companyname,DC=com, 
'CN='.$username);
to try to find a match for the username in the group 'staff' (which is a subset 
of the 'User' group), then it finds no matches.

if anyone can give some suggestions as to why this change turns up an empty 
result set, i'd appreciate hearing from you.

thanks
redmond


[Thu, Oct 23, 2003 at 01:02:58PM -0700]
This one time, at band camp, Justin Patrin said:

 I've been getting entries from an Active Directory server through LDAP 
 for a while now. Here's some example code:
 
 //connect and bind
 //$ds should be the handle returned from ldap_connect
 
 //Search LDAP for all users
 // note, your OU entries may differ
 $sr = ldap_search($ds,
 'OU=Employees,OU=Active Accounts,DC=whatever,DC=com', 'CN=*');
 
 // Put the returned data into an array
 $info = ldap_get_entries($ds, $sr);
 
 //loop through all the users and display their name
 for($i = 0; $i  $info['count']; $i++) {
   echo $info[$i]['cn'][0].\n;
 }
 
 
 If you need an LDAP Browser, I suggest Softerra LDAP Browser. It's very 
 nice for finding OU's and such.
 
 Justin Patrin
 
 
 Redmond Militante wrote:
 hi all
 
 my first email to the list re: php/ldap/win2k AD garnered no responses.  
 i've got most of the problem solved, however i can't get attributes from 
 the ldap server.
 
 i have a login script that authenticates against our win2k active 
 directory domain controller.  i'm able to open a connection/bind/verify a 
 password/and close the connection.  i'm really having trouble returning a 
 user's attributes (i'm mainly concerned with firstname and last name - cn 
 and givenname).
 
 i've been trying for several days to return attributes.  has anyone 
 accomplished this with php?  i can't find much relevant info for this 
 particular problem on the internet.  if you have any pointers, i'd 
 appreciate hearing them.
 
 i'd post relevant code, but nothing i've tried works, and i'm not sure if 
 the code i've tried is even valid...
 
 thanks
 
 redmond
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
Redmond Militante
Software Engineer / Medill School of Journalism
FreeBSD 5.2.1-RELEASE-p10 #0: Wed Sep 29 17:17:49 CDT 2004 i386
 3:15PM  up 2 days,  1:16, 2 users, load averages: 0.01, 0.31, 0.55



- End forwarded message -

-- 
Redmond Militante
Software Engineer / Medill School of Journalism
FreeBSD 5.2.1-RELEASE-p10 #0: Wed Sep 29 17:17:49 CDT 2004 i386
 1:00PM  up 6 days, 23:01, 2 users, load averages: 0.06, 0.06, 0.22


pgppWt4EN69rs.pgp
Description: PGP signature


[PHP] PHP|Cruise

2005-01-19 Thread Jason Barnett
Jeremiah Johnson wrote:
Hi All,
I'm wondering if anyone is planning on attending PHP Tropics
(www.phparch.com/tropics), and if so whether anyone would be
interested in splitting a room with a non-smoker.
Thanks,
Jeremiah
I feel really, really nerdy saying this but... I think this sounds like 
a lot of fun!  Alas, I can not go this year.  I just don't have the 
vacation time saved up for it!

Did anyone on this list go to the PHP|Cruise they had last year?  I'm 
just curious on your opinions of the trip and if it was worth the time / 
money.


--
Newbies: learn how to phish!
Ask smart questions   http://www.catb.org/~esr/faqs/smart-questions.html
php-general archives  http://marc.theaimsgroup.com/?l=php-generalw=2
PHP Manualhttp://www.php.net/manual/en/index.php
Googlehttp://www.google.com/search?q=php
Feeling lazy? 
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins

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


Re: [PHP] my for loop's gone bananas.. has yours?

2005-01-19 Thread Richard Lynch
Tim Burgan wrote:
 I have a for loop to create a HTML combo box that displays the 10 year
 values, starting from today's year and incrementing until 10 years it
 reached.

 The output of the loop to the browser is weird.
 If anyone has time, can you please let me know where I screwed up?

Order Of Operations:
. and + have equal precedence.

So they are evaluated left-to-right, in the order they appear.

So this line:

   echo 'option value='. $today_year + $i .'';

turns into:

echo (('option value=' . $today_year) + $i . '');

which turns into (using $i = 2 as an example):
echo ('option value=2005' + '2');

which then PHP needs to add two things, neither of which really look like
numbers, but it does the best it can by looking at the front part of your
string, and yields:

echo 0 + 2;

   00/option
   1 selected=selected1/option
   22/option

So all you need to change to keep most of your existing code is
parentheses around: ($today_year + $i)

However, you would have much cleaner code if you just did:

for ($year = $today_year; $year  ($today_year + 10); $year++){
}

At that point, all your  + $i stuff just goes away, and life gets real
simple.

For your penance, re-read this page :-)
http://us2.php.net/manual/en/language.operators.php

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

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



Re: [PHP] debugging

2005-01-19 Thread Richard Lynch
William Stokes wrote:
 I would like to add some debugging/info code to my pages. In test
 environment of course. Any ideas how to do this? I mean for example to
 print
 to a web page the line number when the script fails or something like
 that.
 It's a pain on the **s to hunt typo's by just reading the source over and
 over again.

http://php.net/set_error_handler

is what you need.

Also use http://php.net/error_log to send all errors to a log file
(default, the Apache log file) so you do *NOT* display them on the
production server, even if somebody screws up php.ini, or installs a new
PHP which expects php.ini in a different place, or...

Note that your set_error_handler is given the filename and line number as
arguments.  Use them in your output.

Finally, start using http://php.net/trigger_error insead of 'die' in your
scripts, and add as MUCH error-checking of return values as you can.

EVERY function that can return an error code, or set an error message
should be checked EVERY time you call it.

You cannot imagine how much simpler your debugging life will be when you
do this, and it's not any tougher than typing or die() all the time, and
not really that hard to write a couple extra lines of boiler-plate code
after every function call.

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

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



Re: [PHP] Nested SQL Statements

2005-01-19 Thread Richard Lynch
Greg Cullen wrote:
 Relatively new to PHP.  Having an issue trying to nest sql statements.
 Basically I am trying to pull a variable from SQL1, Pass it as a
 Variable/Bind or Parm to SQL2 and then Go back to SQL1 and pull the next
 value and pass to SQL2 again for processing.

 It seems like the SQL2 is getting stuck on the first value passed by SQL1.
 Like SQL2 does not rebuild with the new variable.

 In my example I am testing reading all my tables and reporting their
 definitions.  I have other uses for this technique if PHP and MySQL
 support.

They do support this, though it might be easier to use the built-in
functions for gathering this kind of meta-data...

 ?
 require_once ('mysql_connect.php');
$result1 = mysql_query('show tables',$dbc);

Don't you want to loop through ALL the tables?

Why then are you doing an 'if' here to test *ONE* result, instead of:

while (list($tablename) = mysql_fetch_row($result1))

if ($myrow1 = mysql_fetch_array($result1))
{
   // display list if there are records to display
   $tmptablename = sprintf(describe {$myrow1[0]});

The sprintf here is pretty bogus.  You're not using anything except the
first string argument, so basically you're just confusing readers with the
sprintf() bit.

Of course, by tearing apart the result's row in my while loop above, this
also gets simplified:

$tmptablename = describe $tablename;

do {
   $result2 = mysql_query($tmptablename,$dbc);
   echo Table: {$myrow1[0]};
 // Create page headers

echo table border=\1\ cellspacing=\1\ width=\80%\
 id=\{$myrow1[0]}\;
echo tr;
echo td width=\20%\ bgcolor=\#006600\bfont
 color=\#FF\Field/td;
echo td width=\20%\ bgcolor=\#006600\bfont
 color=\#FF\Type/td;
echo td width=\5%\ bgcolor=\#006600\bfont
 color=\#FF\Null/td;
echo td width=\10%\ bgcolor=\#006600\bfont
 color=\#FF\Key/td;
echo td width=\20%\ bgcolor=\#006600\bfont
 color=\#FF\Default/td;
echo td width=\25%\ bgcolor=\#006600\bfont
 color=\#FF\Extra/td;
echo /tr;

Dude, just break out of PHP and back in again, and you can forget all
those silly s.
?

tr
td width=20% bgcolor=#006600brfont
color=#FFField/font/b/td
.
.
.
/tr

Though now I know why the whole if/do-while mess...

It's much easier to either:
A) Use http://php.net/mysql_num_rows to decide to print table headers, or
B) Go ahead and print them, but if there are NO rows, use:
   TRTD colspan=5No Tables/TD/TR

if ($myrow2 = mysql_fetch_array($result2))
{
   // display list if there are records to display
do {
   echo tr;
   echo td width=\20%\;
if ({$myrow2['Field']}==null)
{
 echo nbsp;
}
else
{
 echo {$myrow2['Field']};
}

   echo /td\n;

   echo td width=\20%\;
if ({$myrow2['Type']}==null)
{
 echo nbsp;
}
else
{
 echo {$myrow2['Type']};
}

   echo /td\n;


   echo td width=\5%\;
if ({$myrow2['Null']}==null)
{
 echo nbsp;
}
else
{
 echo {$myrow2['Null']};
}

   echo /td\n;

   echo td width=\10%\;

if ({$myrow2['Key']}==null)
{
 echo nbsp;
}
else
{
 echo {$myrow2['Key']};
}

   echo /td\n;

   echo td width=\20%\;

if ({$myrow2['Default']}==null)
{
 echo nbsp;
}
else
{
 echo {$myrow2['Default']};
}

   echo /td\n;

   echo td width=\25%\;
if ({$myrow2['Extra']}==null)
{
 echo nbsp;
}
else
{
 echo {$myrow2['Extra']};
}
   echo /td\n;
   echo /td\n;
   echo /tr\n;

} while ($myrow2 = mysql_fetch_array($result2));

  echo /table;
  echo br;

  $myrow2 = Null;

   mysql_free_result(result2);

   } else {

// no records to display

 echo Sorry, no records were found!;}

 } while ($myrow1 = mysql_fetch_array($result1));

The REAL problem you are having is that *WAY* up at the beginning of this
loop, you set $temptablename (or whatever it was) *OUTSIDE* this loop.

So the describe ... never changes, and you keep describing the first
table, even though you are looping through all the tables in the do-while.

  }

  else {

echo No Tables;

   }
 mysql_close();

 include ('footer.php');
 ?

Synopsis of Tips:
1. Reserve do-while for the rare case when it's REALLY needed and cleaner.
2. Get out of PHP mode for large chunks of HTML
3. Use list() to tear apart your rows into well-named variables

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

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



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

2005-01-19 Thread Richard Lynch
Sephiroth wrote:
 Hi all,

 How to access remote files with php?
 For ex:
 $sFile = http://www.php.net/123.txt;;
 if (file_exists($sFile)) {
   $hFile = fopen($sFile);
   ...
   fclose($hFile);
 }

At the risk of being accused of copying whatshisname...

Yes.

:-)

You're pretty much written the code in its most simple form the way it
should be, and it should work as-is.

You'd want to add in some error-checking code so your application does
something reasonable when the file isn't found, or the network connection
flakes out, or...

PS file_exists() may only work for URLs in recent versions of PHP...  Read
the manual to find out which versions.

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

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



Re: [PHP] $_SERVER['HTTP_USER_AGENT'] in html email

2005-01-19 Thread Richard Lynch
Graham Anderson wrote:
 What would be the standard/accepted  way to do this?

 is it better to spell it out in the html email ?
 Download:
 Mac   PC  Linux ?

YES!

The software I want may not be used on the machine where I read email.

In fact, odds are really good it's *NOT* for the machine/platform I use to
read email.

Now all you have to do is get rid of the html enhanced (cough, cough)
email format, and use plain-text, and I might even see your offer.  If
it's html enhanced, it goes right in the trash -- and more spam filters
will trash it too.

Example:

Mac: http://example.com/yourware.dmg
PC: http://example.com/yourware.exe
Linux: http://example.com/yourware.tar.gz

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

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



Re: [PHP] searching and sorting

2005-01-19 Thread Richard Lynch
 I agree. That is a wise statement, and I have tried to do this with
 regular
 expressions but this doesn't deal with relevance at all, or is there
 something that I am missing? I suppose I could do multiple searches on my
 data to look for sports cars first, cars second, and sports last.
 Then
 I could deal with the separate issue of the text files.

Your database may provide a full text search system you can use, which
would be Good in terms of performance, but probably Bad in terms of
portability.

If you need portability, something like this:

?php
  $words = split('/\\s/', $_POST['search']);

  //Ignore multiple inputs of same word:
  $words = array_flip(array_flip($words));

  $query =  select fields, you, need, ;
  //This is for real:
  $query .=  (description like '%$search%') ;
  reset($words);
  while (list(, $word) = each($words)){
$query .=  + (description like '%$word%') ;
  }
  $query .=  as score, ;
  //This is just for debugging, so you can see where points are garnered:
  $query .=  (description like '%$search%') as perfect, ;
  reset($words);
  while (list(, $word) = each($words)){
$query .=  (description like '%$word%') as 'word_$word', ;
  }
  $query .=  'filler' ; // Just for the extra comma at the end of the loop
  $query .=  from whatever ;
  $query .=  order by score desc ;

  $matches = mysql_query($query) or trigger_error(mysql_error() . 
$query, E_USER_ERROR);
  while ($row = mysql_fetch_array($matches)){
list($fields, $you, $want, $score) = $row;
//For debugging only:
echo Scoringbr /\n;
echo Perfect: $row[perfect]br /\n;
reset($row);
for ($i = 0; $i  4; $i++) each($row); //Ignore stuff we already printed
for ($i = 4; $i  count($row); $i++){
  list($word, $points) = each($row);
  echo Word match ($word): $pointsbr /\n;
}
  }
?

You'll need to convince MySQL to convert boolean to 0/1.

You can also apply scaling factors so that a perfect match gets, say, 10
points, intead of just 1:
$query .=  10 * (description like '%$search%') as perfect ;

This is crude, but effective, and can easily be ported to any SQL engine
-- Except, of course, for the data-type conversion from a boolean result
to int, which you need to tweak, but that should be fairly easy to work
out a hack for all SQL engines, perhaps by using a variable function name:

$query .=  10 * $sql_bool_to_int(description like '%$search%') as perfect ;

You then define $sql_bool_to_int for each SQL engine you need, and Bob's
your uncle.

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

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



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

2005-01-19 Thread Richard Lynch
Marek Kilimajer wrote:
 Jason Barnett wrote:
 Valter Toffolo wrote:

 ok i have one server with a single domain, each user have it's home
 with a public_html so i get mydomain.com/~user1/ and
 mydomain.com/~user2/ and so on. but each user might like to use
 sessions so how can i make it work so that sessions would have each
 one it's own variables and all...??

 thanks, valter.


 What is the problem?  If you have session support set in PHP then each
 user should be able to session_start etc.  The default session handler
 that comes with PHP will allow each user to have their own session
 variables (technically they're indices in the $_SESSION superglobal
 array).

 Please check the PHP manual to see how to set up session support if
 that's what you're confused about.


 The problem is with cookies being common for all user directories.

You'll have to be more specific than this.

Are you worried about:
1) Cookie filename collision, so two users criss-cross cookies?
2) Cookie security, so user1 can read user2's cookie files
3) Malicous user2 filling up everybody's /tmp dir with zillion cookie files

#1 is a non-problem, almost for sure.  I don't think the OS+PHP will
*ever* let your cookie files share a common name

#2 separating them into different directories is not a whole lot of
help...  If I know his cookie files are in ~/user2 and follow the same
naming conventions as the ones in my ~/user1 directory, I can still read
them.

#3 also separting the cookies is no help -- A full drive is a full drive. 
Unless you are doing a low-level partition separate for each user.

 Each user should use session_set_cookie_params() to set the cookie path
 to its own directory. And use of session_regenerate_id() is a must, else
 user1 can set the cookie path to /~user2/ with lifetime till 2038 and...

And what?

Until we know what it is you think you're trying to solve we can't
advise you.

So far, all we've got is a stated desire to segregate cookie files for no
apparent reason.

I'm sure it's perfectly clear to you why you want this, but nobody else is
getting it.

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

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



Re: [PHP] Windows CLI and task scheduler

2005-01-19 Thread Richard Lynch
Dominic Schanen wrote:
 I've written several command line scripts to run as scheduled tasks on a
 Windows 2000 Server machine. They run fine, no problems. However, the
 application log is filling up with errors stating that windows was
 unable to unload my registry profile. I know the PHP scripts are at

Wha...???

I don't think PHP does anything to load a registry profile

This probably is down at the level of the OS and the Task Scheduler layer,
rather than in PHP itself.

You may want to try opening up an MS-DOS window and running your cron jobs
by hand in that to see what output you get, if any.

 fault because the errors are being recorded at the same intervals as my
 scheduled tasks.

 I installed UPHClean to cleanup the unloaded profiles but that simply
 doubles the number of log entries created.

 I was wondering if anyone else has run into this problem? Is this a task
 scheduler problem or a PHP problem? If it is a task scheduler problem,
 is there something I can do by exiting or closing differently in PHP?

I really doubt that your PHP code will change -- Probably a setting in
Windows or Task Scheduler, or the way you launch PHP...

H.  Did you have it set up to open an MS-DOS window and then KEEP it
open?  Maybe then the Task Scheduler can't close those windows, and that's
what is keeping the Registry Profile open, whatever that is.

 I have PHP 5.0.3 and am using php-win.exe

You may have better luck on the php-windows list...

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

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



[PHP] Re: select-option link list

2005-01-19 Thread Ricky Morley
Like this. Here's the html code. I'm sure you can convert to the  
appropriate PHP

html
body
form
select size=1 name=site onChange=window.location=this.value
option value=http://www.google.com;Google/option
option value=http://www.yahoo.com;Yahoo/option
option value=http://www.microsoft.com;MS/option
/select
/form
/body
/html

On Wed, 19 Jan 2005 20:10:25 +0200, William Stokes [EMAIL PROTECTED]  
wrote:

Hello,
Hope someone can give some directions...
I'm trying to create a list box of links to other pages. I just can't  
figure
out how to move to the other page whe user selects one of the options in  
the
list box.

here's the code...
$sql=SELECT team_name FROM teams;
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
print form name=\form1\ method=\post\ action=\select_team.php\;
print select name=\select_team\ size=\1\  ;
while ($num = $cur) {
$row = mysql_fetch_array($result);
$team_name = $row[team_name ];
print option$team_name /option;
$cur++;
}
print /select;
print input type=\submit\ value=\Go!\;
print /form;
This propably can be don without the Go button. But i Don't know how...
Thank a lot
-Will
BTW thanks for the debugging stuff earlier. Got that workin...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Windows CLI and task scheduler

2005-01-19 Thread Jason Barnett
Richard Lynch wrote:
Dominic Schanen wrote:
I've written several command line scripts to run as scheduled tasks on a
Windows 2000 Server machine. They run fine, no problems. However, the
application log is filling up with errors stating that windows was
unable to unload my registry profile. I know the PHP scripts are at
...
H.  Did you have it set up to open an MS-DOS window and then KEEP it
open?  Maybe then the Task Scheduler can't close those windows, and that's
what is keeping the Registry Profile open, whatever that is.
I just wanted to add: I recently posted on this topic in either this 
group (or maybe it was php-windows).  Search the archives for how I do 
command line PHP in Windows.

--
Newbies: learn how to phish!
Ask smart questions   http://www.catb.org/~esr/faqs/smart-questions.html
php-general archives  http://marc.theaimsgroup.com/?l=php-generalw=2
PHP Manualhttp://www.php.net/manual/en/index.php
Googlehttp://www.google.com/search?q=php
Feeling lazy? 
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins

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


[PHP] Mssql Connection

2005-01-19 Thread Pablo D Marotta
Hi there..
I´m connecting to a Ms Sql Server 2000, with the system administrator´s name,
and its password.
It always works fine, but... I know it´s not the safest way of connecting, so I
want to use some ordinary user names and passwords.

The problem is that I just can´t make it work, it always throws username
errors.

How should I configure this, in order to connect to mssql with ordinary
usernames and passwords from php code?

Here is my function code:

function conectar ()
{
  $conexion = mssql_connect(localhost,sa,apr);
  if (!$conexion)
  {
?
DIV align=center
  FONT face=Arial color=FF size=3
B# Can´t establish connection with database server pc./B
  /FONT
/DIV
?php
exit (0);
  }
  if (!mssql_select_db(GES_WEB))
  {
?
DIV align=center
  FONT face=Arial color=FF size=3
B# Can´t establish connection with the specified database./B
  /FONT
/DIV
?php
exit (0);
  }
  return $conexion;
}

Thanks!!

Pablo



American Express made the following
 annotations on 01/19/05 13:57:56
--
**

 This message and any attachments are solely for the intended recipient 
and may contain confidential or privileged information. If you are not the 
intended recipient, any disclosure, copying, use, or distribution of the 
information included in this message and any attachments is prohibited.  If you 
have received this communication in error, please notify us by reply e-mail and 
immediately and permanently delete this message and any attachments.  Thank 
you.

**

==

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



Re: [PHP] Re: select-option link list

2005-01-19 Thread Jochem Maas
Ricky Morley wrote:
Like this. Here's the html code. I'm sure you can convert to the  
appropriate PHP

this is totally not PHP but...
html
body
form
select size=1 name=site onChange=window.location=this.value
shouldn't that be something like:
select size=1
name=site   
onChange=if
(this.options[this.selectedIndex].value) {
window.location=this.options[this.selectedIndex].value;
}
which is evil and crude, but does 2 things: uses the selectedIndex to 
get the value of the selection options and only sets the window location 
is the value if not empty.


option value=http://www.google.com;Google/option
option value=http://www.yahoo.com;Yahoo/option
option value=http://www.microsoft.com;MS/option
/select
/form
/body
/html

On Wed, 19 Jan 2005 20:10:25 +0200, William Stokes 
[EMAIL PROTECTED]  wrote:

Hello,
Hope someone can give some directions...
I'm trying to create a list box of links to other pages. I just can't  
figure
out how to move to the other page whe user selects one of the options 
in  the
list box.

here's the code...
$sql=SELECT team_name FROM teams;
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
print form name=\form1\ method=\post\ action=\select_team.php\;
print select name=\select_team\ size=\1\  ;
while ($num = $cur) {
$row = mysql_fetch_array($result);
$team_name = $row[team_name ];
print option$team_name /option;
$cur++;
}
print /select;
print input type=\submit\ value=\Go!\;
print /form;
This propably can be don without the Go button. But i Don't know how...
Thank a lot
-Will
BTW thanks for the debugging stuff earlier. Got that workin...

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


Re: [PHP] Re: select-option link list

2005-01-19 Thread Richard Morley
This should work
html
body
form
select size=1 name=site onChange=if(this.value !=  
'')window.location=this.value
option value=Please select a site to visit/option
option value=http://www.google.com;Google/option
option value=http://www.yahoo.com;Yahoo/option
option value=http://www.microsoft.com;MS/option
/select
/form
/body
/html

On Wed, 19 Jan 2005 22:23:52 +0100, Jochem Maas [EMAIL PROTECTED]  
wrote:

Ricky Morley wrote:
Like this. Here's the html code. I'm sure you can convert to the   
appropriate PHP

this is totally not PHP but...
html
body
form
select size=1 name=site onChange=window.location=this.value
shouldn't that be something like:
select size=1
name=site   
onChange=if
(this.options[this.selectedIndex].value) {
window.location=this.options[this.selectedIndex].value;
}
which is evil and crude, but does 2 things: uses the selectedIndex to  
get the value of the selection options and only sets the window location  
is the value if not empty.


option value=http://www.google.com;Google/option
option value=http://www.yahoo.com;Yahoo/option
option value=http://www.microsoft.com;MS/option
/select
/form
/body
/html
On Wed, 19 Jan 2005 20:10:25 +0200, William Stokes  
[EMAIL PROTECTED]  wrote:

Hello,
Hope someone can give some directions...
I'm trying to create a list box of links to other pages. I just can't   
figure
out how to move to the other page whe user selects one of the options  
in  the
list box.

here's the code...
$sql=SELECT team_name FROM teams;
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$cur = 1;
print form name=\form1\ method=\post\  
action=\select_team.php\;
print select name=\select_team\ size=\1\  ;
while ($num = $cur) {
$row = mysql_fetch_array($result);
$team_name = $row[team_name ];
print option$team_name /option;
$cur++;
}
print /select;
print input type=\submit\ value=\Go!\;
print /form;

This propably can be don without the Go button. But i Don't know  
how...

Thank a lot
-Will
BTW thanks for the debugging stuff earlier. Got that workin...


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Mssql Connection

2005-01-19 Thread Jochem Maas
Pablo D Marotta wrote:
Hi there..
I´m connecting to a Ms Sql Server 2000, with the system administrator´s name,
and its password.
It always works fine, but... I know it´s not the safest way of connecting, so I
want to use some ordinary user names and passwords.
The problem is that I just can´t make it work, it always throws username
errors.
How should I configure this, in order to connect to mssql with ordinary
usernames and passwords from php code?
Here is my function code:
function conectar ()
{
  $conexion = mssql_connect(localhost,sa,apr);
  if (!$conexion)
  {
?
DIV align=center
  FONT face=Arial color=FF size=3
B# Can´t establish connection with database server pc./B
  /FONT
FONT face=Arial color=FF size=3font/FONT
FONT face=Arial color=FF size=3tags/FONT
FONT face=Arial color=FF size=3suck/FONT
I know nothing about MSSQL - thankgod (sorry I really can't help you 
there) - but I can recommend eradicating all font tags... everywhere... 
take no prisoners... death to frontpage (oh sorry got carried away :-). 
try this instead:

p style=color: #f00; font: large Arial; text-align: center;
# Can´t establish connection with database server pc.
/p
rgds,
Jochem
/DIV
?php
exit (0);
  }
  if (!mssql_select_db(GES_WEB))
  {
?
DIV align=center
  FONT face=Arial color=FF size=3
B# Can´t establish connection with the specified database./B
  /FONT
/DIV
?php
exit (0);
  }
  return $conexion;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Best way to encode?

2005-01-19 Thread Michiel van der Blonk
Hi,

use base64_encode() and base64_decode
actually, base32_encode or hexencode would be better, but oh my, php doesn't
have these built in.

If you're using PEAR there is a DataObject_Filter class somewhere that's
handy for encoding decoding on the fly.

Kind regards,
Michiel
*
Michiel van der Blonk
CaribMedia Marketing  Consultancy N.V.
Oranjestad, Aruba
Tel: (297) 583-4144 Fax: (297) 582-6102
http://www.caribmedia.com
 
Website Design, Web Application Development,
Web Hosting, Internet Marketing
 
Operators of:
Visit Aruba - http://www.VisitAruba.com
Aruba Links - http://www.ArubaLinks.com
Aruba Business Directory - http://www.visitaruba.com/business/
Aruba Real Estate Locator - http://www.arubarealestate.com
Aruba Bulletin Board - http://bb.visitaruba.com/
Aruba Trip Reports - http://tripreports.visitaruba.com
Aruba Chat - http://chat.visitaruba.com
The VisitAruba Plus SAVINGS CARD - http://www.visitaruba.com/plus/
Contents of this communication are confidential and legally privileged. This
document is intended solely for use of the individual(s) or entity/entities
to whom it is addr
Brian Dunning [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I have a form where people input some text, which is then incorporated
into an HTML snippet which appears in a textarea for them to copy 
paste into a web page.

People will be entering foreign language stuff as well as special
characters like copyright, so I have to be sure this is handled
properly.

I tried rawurlencode() but that results in HTML which displays the
encoding when they paste it into their web page. I tried htmlentities
but that gives different characters than what they typed when displayed
in the textarea. I also tried no encoding, which worked well, except
that it gets messed up when I try to write it to the database and I
have the same problem again when retrieving it.

Cañon © is a good example.
htmlentities('Cañon ©') - Cañon © in the textarea, displays on their
web page as Cañon ©, but reads/writes OK from the database.
rawurlencode('Cañon ©') - Ca%C3%B1on%20%C2%A9 in the textarea,
displays on their web page as Ca%C3%B1on%20%C2%A9, but reads/writes OK
from the database.
No encoding gives Cañon © in the textarea and displays on their web
page as Cañon ©, but appears in the database as Cañon ©

How can I handle this so that what ultimately displays on their web
page, after copying the HTML out of the textarea, matches what they
typed in the form, and yet can be read  written from the database
properly?

- Brian

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



Re: [PHP] debugging

2005-01-19 Thread Jochem Maas
Justin French wrote:
On 19/01/2005, at 10:51 PM, Marek Kilimajer wrote:
...

I use simple define('DEBUG', true'); in the main config file where 
also database login info is stored.

I like to use exactly the same files for both development and live 
servers... it makes it much easier to mirror the site via FTP, commit 
via SVN, etc.
I solved that little problem by letting the global include file try to 
include debug.php which if not found causes the code to define DEBUG to 
false (because DEBUG is not defined). debug.php simply defines DEBUG to 
true - debug.php is not in CVS :-) nevermore a production site in DEBUG 
mode! its a little safeguard, really this should be taken care of by 
propering tagging, release schedules, QC etc. not that have much 
experience in hardcore cvs/svn management (not really the right list 
either :-)
---
Justin French, Indent.com.au
[EMAIL PROTECTED]
Web Application Development  Graphic Design
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Storing a reference to an object in another object

2005-01-19 Thread Jochem Maas
Rory McKinley wrote:
Hi All
This is probably just a case of me being Mr Thicky, but maybe someone 
can point out the error mf my ways:

I have two classes, call them admin and module. Admin stores login 
details as well as a pointer to the DB connection. Module will run 
various queries. To do that it needs access to the DB connection 
maintained by Admin. Because I don't want to have to keep on passing the 
reference to the admin instance, I thought I would store the reference 
to the admin instance within the module instance when the object is 
created:

class Module
{
private $admin_instance;
function __construct($admin_instance)
{
$this-admin_instance = $admin_instance;
}
public function checkConnection()
{
return $this-admin_instance-checkConnection()
}
}
I assume this is not your actual code (by the manner in which you wrote 
above - '...,call them admin and...'). are you absolutely sure there is 
not a typo somewhere? like 'adnin_instance' or 'admin_imstance'

you better off posting actual code snippets and removing sensitive data 
(assuming your allowed.)

I am using PHP 5 so the reference should be passed and stored in the 
relevant object attribute, not so?

correct :-) no. 1 benefit in php5 - proper objects.
Yet, if i call checkConnection it tells me that I am calling a method on
can you call the checkConnection() method in the __construct() of Module?
a non-object.print_r() of the module instance  makes things even more 
confusing: print_r returns:

 [admin_instance:private] = [class_name] = blah [admin_instance] = 
Admin Object

which is followed by the various attributes of the admin object 
suggesting that the reference to the admin object is indeed within the 
module instance.

I hope someone can help with this..
I do this kind of thing the whole time (references to parent, 
application and subobjects - circular references not being a problem), I 
can't see that your doing anything wrong. though there is not much code 
to go on.

Oh, and before anybody asks I am still busy RTFM, STFW, STFA but with no 
good for you :-)
joy so far.
bummer. post some more code ;-)

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


Re: [PHP] Mssql Connection

2005-01-19 Thread Richard Lynch
Jochem Maas wrote:
 FONT face=Arial color=FF size=3font/FONT
 FONT face=Arial color=FF size=3tags/FONT
 FONT face=Arial color=FF size=3suck/FONT

 I know nothing about MSSQL - thankgod (sorry I really can't help you
 there) - but I can recommend eradicating all font tags... everywhere...
 take no prisoners... death to frontpage (oh sorry got carried away :-).
 try this instead:

 p style=color: #f00; font: large Arial; text-align: center;
 # Can´t establish connection with database server pc.
 /p

Unless, of course, your user base includes the very poor who are (still)
using ancient browsers (because they have ancient hardware) that don't
support CSS, and you want to use font tags which actually work on *ALL*
browsers...

I can't count the number of CSS sites I've skipped because their links
don't work (in my browser) due to CSS.  Buh-bye.

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

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



[PHP] SQL - INSERT INTO booleans

2005-01-19 Thread Tim Burgan
Hello,
I'm trying to insert a new row using the following SQL:
$db_sql = INSERT INTO tblStudents (name, username, password, expiry, 
permissions, website, displayUser) VALUES ('Joe', 
'joejoe','pw4joe','20-Jan-05','staff','true','false');;

In using MS Access via COM, the data types for each column (in order) 
is: string, string, string, date, string, boolean, boolean.

I am continually getting a data type mismatch error (relating to the 
boolean columns) when trying to execute this code.

I've tried removing the single quotes, but that returns a syntax error.
What do I do? Any assistance would be greatly appreciated.
Tim
PS: For those that are unclear of who COM works, this is my code to 
connect to the database with a DNS-less connection.

/* Open the connection to the database */
$db_connection = new COM(ADODB.Connection) or die(Cannot start ADO);
$db_connstr= DRIVER={Microsoft Access Driver (*.mdb)};DBQ=.
realpath(../data2004/contentdb01.mdb) .;DefaultDir=.
realpath(../data2004);
$db_connection-open($db_connstr);
/* Set the SQL */
$db_sql = INSERT INTO tblStudents (name, username, password, expiry, 
permissions, website, displayUser) VALUES ('Joe', 
'joejoe','pw4joe','20-Jan-05','staff','true','false');;

/* Execute SQL */
$rs = $db_connection-execute($db_sql);
/* Close the database connection */
$db_connection-Close();
$rs = null;
$db_connection = null;
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2005-01-19 Thread Richard Lynch
Xuefer Tinys wrote:
 i have a big array with 20k elements, i have no problem building it,
 because the elements is recv from socket, i can socket_select() on 1k
 clients, read from them.
 i plan to unset the whole array every 1hour
 this is a not big problem when for a few times, it takes me 0.02 seconds
 but after many hours of running, unset will sometime takes 10 seconds.
 this is big problem because it's 1 unset() statement, and all incoming
 connection is blocked, the client may get connection time out

 summary:
 1. one process, no fork (just has to be)
 2. socket_select(), process each client's data simultaneously. some
 data will be put into array
 3. each element value is /true/, and key is numeric(ip2long)
 $array[ip2long($ip)] = true;
 4. fast to unset, but slow to unset after a few hours, with similar
 amount of elements

Just some ideas from a naive reader:

1. unset() more often
2. unset() only a portion of the elements of the array

You may even want to store a TIME element, and only unset() the old
items or something.

You may also want to, perhaps, put the unset() of older data inside your
socket listening/reading loop, so that you are unset-ing the really old
stuff as you read the new stuff, to always keep your array small in
size.

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

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



Re: [PHP] Mssql Connection

2005-01-19 Thread Jochem Maas
Richard Lynch wrote:
Jochem Maas wrote:
FONT face=Arial color=FF size=3font/FONT
FONT face=Arial color=FF size=3tags/FONT
FONT face=Arial color=FF size=3suck/FONT
I know nothing about MSSQL - thankgod (sorry I really can't help you
there) - but I can recommend eradicating all font tags... everywhere...
take no prisoners... death to frontpage (oh sorry got carried away :-).
try this instead:
p style=color: #f00; font: large Arial; text-align: center;
# Can´t establish connection with database server pc.
/p

Unless, of course, your user base includes the very poor who are (still)
using ancient browsers (because they have ancient hardware) that don't
support CSS, and you want to use font tags which actually work on *ALL*
browsers...
you have a point - but even Netscape4 and IE4 support rudimentary CSS 
AFAICR. I dont think his userbase is too poor though, considering he 
works for American Express :-)

having said that any HTML in production envs should degrade nicely for 
older browsers. it doesn't have to look the same but it should be 
accessible.

I can't count the number of CSS sites I've skipped because their links
don't work (in my browser) due to CSS.  Buh-bye.
exactly what browser do you use? and how does CSS break links? (let me 
guess you disable background images?) besides you can turn off 
stylesheets completely if you want.

CSS is a good thing. semantic mark and decoupling of style is a good 
ting too.

its a bit weird if you consider that you seem to be willing to view an 
all image page with loads of nested tables for positioning and tons of 
font tags. but the same page written in a 10th of the HTML with a nifty 
stylesheet which references a number of bg images is told to bugger off.



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


RE: [PHP] SQL - INSERT INTO booleans

2005-01-19 Thread Mikey
 $db_sql = INSERT INTO tblStudents (name, username, password, expiry,
 permissions, website, displayUser) VALUES ('Joe',
 'joejoe','pw4joe','20-Jan-05','staff','true','false');;
 
 In using MS Access via COM, the data types for each column (in order)
 is: string, string, string, date, string, boolean, boolean.
 
 I am continually getting a data type mismatch error (relating to the
 boolean columns) when trying to execute this code.
 
 I've tried removing the single quotes, but that returns a syntax error.

Have you tried 1 for true and 0 for false?

Just a guess...

Mikey

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



Re: [PHP] Re: Windows CLI and task scheduler

2005-01-19 Thread Richard Lynch




Jason Barnett wrote:
 Dominic Schanen wrote:
 I changed the scheduled task to use php.exe instead of php-win.exe and
 that cleared up the errors with unloading the profile that were
 appearing in the application log. Could this possibly be a bug with
 php-win.exe and not cleaning up properly?

 Thanks,
 Dominic


 Honestly, I don't know why you would choose php-win.exe over php.exe.  I
 use php.exe for command line scripting as well as scheduled tasks and it
 has always functioned like I expected it to.  Does anyone else have
 input here on why to choose php-win over php?

For debugging, it's useful to have the MS-DOS window stay open, with any
error output, and I *think* that's what php-win.exe does.

So, use php-win.exe for debugging, and switch to php.exe for production.

I personally always just opened up an MS-DOS window to start the php.exe
though, and found that easy enough to use for both.

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

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



Re: [PHP] Re: Windows CLI and task scheduler

2005-01-19 Thread Richard Lynch
Dominic Schanen wrote:
 I changed the scheduled task to use php.exe instead of php-win.exe and
 that cleared up the errors with unloading the profile that were
 appearing in the application log. Could this possibly be a bug with
 php-win.exe and not cleaning up properly?

I think it's just the way it is, not a bug.

Windows can't close that window, so it complains.

You could try searching/adding it to http://bugs.php.net though, if you
think it really is a bug.

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

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



Re: [PHP] Storing a reference to an object in another object

2005-01-19 Thread Richard Lynch
Rory McKinley wrote:
   public function checkConnection()
   {
   return $this-admin_instance-checkConnection()

WILD GUESS!!!

In early days of PHP objects, you sometimes couldn't use two arrow
operators with, errr, references???

So an easy way to maybe fix this and move on with your life:

$admin = $this-admin_instance;
return $admin-checkConnectino();

Seems kinda bogus to me, but...

Hey, you're missing a ';' at the end of that line there...  Hopefully not
in the real code...  Or maybe it's not needed before the } in this
construct.

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

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



Re: [PHP] Need best way to determine if cronjob or external browser called my script

2005-01-19 Thread Richard Lynch
Al wrote:
 I'm working on a script that can be initiated by a cronjob or from a
 browser.

 I want the script to act differently depending on which one called it.

Another solution:
http://us2.php.net/php-sapi-name

I personally think this is the cleanest and most maintainable solution
posted so far, but YMMV.

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

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



Re: [PHP] SQL - INSERT INTO booleans

2005-01-19 Thread Richard Lynch
Tim Burgan wrote:
 I am continually getting a data type mismatch error (relating to the
 boolean columns) when trying to execute this code.

 I've tried removing the single quotes, but that returns a syntax error.

I've forgotten the rules for MS-Access, but...

Perhaps try 1 and 0 as your bool, with no apostprophes.

I really would have expected the true/false with no apostrophes to work
myself...

You could try to build a sample query in Access itself, using that damn
GUI thingie they have, which always just confused me personally, to see
what Microsoft thinks is proper SQL -- Not that it really *IS* proper SQL,
but at least it will work with Access, hopefully.

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

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



[PHP] Problem with hidden form input values

2005-01-19 Thread Ben Edwards (lists)
I know this is not strictly speaking a PHP question but it is to do with
a PHP app.

I have a form with a number of hidden values in it.  After the post
print_r( $_POST ) shows all the values except these (this is copied from
'Show Source' in the browser.

input type=hidden name=keyField[mb_memberships][0] value=mb_e_id
input type=hidden name=keyValue[mb_memberships][0] value=10
input type=hidden name=keyField[mb_memberships][1] value=mb_id
input type=hidden name=keyValue[mb_memberships][1] value=1

Any idea why they wont post?

Ben
-- 
Ben Edwards - Poole, UK, England
If you have a problem sending me email use this link
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)



signature.asc
Description: This is a digitally signed message part


Re: [PHP] Re: Windows CLI and task scheduler

2005-01-19 Thread Jason Barnett
Richard Lynch wrote:
Dominic Schanen wrote:
I changed the scheduled task to use php.exe instead of php-win.exe and
that cleared up the errors with unloading the profile that were
appearing in the application log. Could this possibly be a bug with
php-win.exe and not cleaning up properly?

I think it's just the way it is, not a bug.
Windows can't close that window, so it complains.
That makes some sense.
You could try searching/adding it to http://bugs.php.net though, if you
think it really is a bug.
It will likely end up being labeled bogus (just my opinion of course). 
From what you say of php-win.exe it sounds like it's just a call to the 
comspec and then invoking php.  If that's all that php-win does then 
it's seriously not needed; you can just add a file association for .php 
files that will run:

C:\WINNT\SYSTEM32\CMD.EXE /K C:\PHP\php.exe -f %1
 path/to/comspec  /K /path/to/php.exe -f %1
Right click, run php script in an MS-DOS box.  Presto!  Simple as that.
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | 
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins

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


Re: [PHP] Problem with hidden form input values

2005-01-19 Thread Richard Lynch
Ben Edwards (lists) wrote:
 I know this is not strictly speaking a PHP question but it is to do with
 a PHP app.

 I have a form with a number of hidden values in it.  After the post
 print_r( $_POST ) shows all the values except these (this is copied from
 'Show Source' in the browser.

 input type=hidden name=keyField[mb_memberships][0] value=mb_e_id
 input type=hidden name=keyValue[mb_memberships][0] value=10
 input type=hidden name=keyField[mb_memberships][1] value=mb_id
 input type=hidden name=keyValue[mb_memberships][1] value=1

 Any idea why they wont post?

The *do* POST, but PHP only handles one level of array references in NAME=xxx

You can do something like:
?php
  while (list($keys, $value) = each($_POST['keyField'])){
$keys = explode('][', $keys);
list($key1, $key2) = $keys;
$realKeyField[$key1][$key2] = $value;
  }
?

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

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



Re: [PHP] Mssql Connection

2005-01-19 Thread Richard Lynch
 having said that any HTML in production envs should degrade nicely for
 older browsers. it doesn't have to look the same but it should be
 accessible.

It won't be if you use CSS.

 I can't count the number of CSS sites I've skipped because their links
 don't work (in my browser) due to CSS.  Buh-bye.

 exactly what browser do you use? and how does CSS break links? (let me
 guess you disable background images?) besides you can turn off
 stylesheets completely if you want.

Until the hard drive crashed a few months ago, I was using a Mac PPC
9100/100 with OS 8.6, the most stable OS for that hardware.

I was using IE 4.01 (?) the most stable browser for that OS -- Though even
that meant at least one crash a day :-(

But nobody was buying me a new computer, so there it stayed.

Randomly selected links would simply NOT WORK in HTML that was perfectly
valid, if that HTML used CSS extensively.

If I really wanted the content, I'd view the source and copy/paste the
link.  But if I was just surfing?  I'd just go on to a different site.

 CSS is a good thing. semantic mark and decoupling of style is a good
 ting too.

Sure, up to a point.

But since I generally use PHP to de-couple my business logic from my
output, enough to make it easy to alter the look-and-feel any time I want,
I don't see the need to use CSS to do the same thing, and then not be
degrading nicely on ancient browsers.

I've also seen a TON of man-hours wasted separating interface logic from
interface, which seems kind of silly to me...

I mean, if your interface elements change, your interface logic is going
to HAVE to change, if you're going to have any decent scrubbing/validation
at all, or any kind of nice layout that isn't all generic looking.  Not
that I'm a good enough designer to actually achieve that :-)

I guess I've always seen the separation more along the lines of:

Interface Elements (HTML) and Input/Output to Interface Elements
-- layer ---
Business Logic
-- layer ---
Underlying Libraries of common code
-- layer ---
.
.
.
-- layer ---
Operating System

I know I'm a heretic to leave the I/O to Interface with the actual
interface, but I've never yet seen a case where separating them in the
real world caused anything but wastage.  YMMV.

 its a bit weird if you consider that you seem to be willing to view an
 all image page with loads of nested tables for positioning and tons of
 font tags. but the same page written in a 10th of the HTML with a nifty
 stylesheet which references a number of bg images is told to bugger off.

I don't know about the all image page, as they tend to be awfully slow
sometimes, but I've never had a problem with tables -- writing them or
having them work, and since my font tags all come from a single PHP
function, it's not like a big hairy deal to do the exact same thing you'd
do with CSS -- I change the font in one place for the whole site, and I'm
done.

And the CSS positioning in older browsers invariably ends up being
completely whack.  You get some image floating right on top of, and
obscuring, the text content I want to read, and I'm not a happy surfer.

So I achieve the same goals as CSS, only it actually degrades nicely on
those older browsers.  [shrug]

Yes, CSS sites look much nicer, and have cleaner-looking text, and that
image placement with text wrapping around it is really pretty...

But I'm simply not (yet) willing to abandon that .01% == hundreds of
thousands of users who can't view CSS sites.

Maybe in a year or so, and already for sites where I have prior knowledge
of the userbase/browser not being *that* old.

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

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



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

2005-01-19 Thread kjohnson
 Xuefer Tinys wrote:
  i have a big array with 20k elements, i have no problem building it,
  because the elements is recv from socket, i can socket_select() on 1k
  clients, read from them.
  i plan to unset the whole array every 1hour
  this is a not big problem when for a few times, it takes me 0.02 
seconds
  but after many hours of running, unset will sometime takes 10 seconds.
  this is big problem because it's 1 unset() statement, and all incoming
  connection is blocked, the client may get connection time out
 
  summary:
  1. one process, no fork (just has to be)
  2. socket_select(), process each client's data simultaneously. some
  data will be put into array
  3. each element value is /true/, and key is numeric(ip2long)
  $array[ip2long($ip)] = true;
  4. fast to unset, but slow to unset after a few hours, with similar
  amount of elements

A question from another naive reader. 

Have you tried re-setting the array to an empty one, using array(), 
instead of using unset()?

Kirk

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



Re: [PHP] Problem with hidden form input values

2005-01-19 Thread Jason Wong
On Thursday 20 January 2005 07:07, Ben Edwards (lists) wrote:
 I know this is not strictly speaking a PHP question but it is to do with
 a PHP app.

 I have a form with a number of hidden values in it.  After the post
 print_r( $_POST ) shows all the values except these (this is copied from
 'Show Source' in the browser.

 input type=hidden name=keyField[mb_memberships][0] value=mb_e_id
 input type=hidden name=keyValue[mb_memberships][0] value=10
 input type=hidden name=keyField[mb_memberships][1] value=mb_id
 input type=hidden name=keyValue[mb_memberships][1] value=1

 Any idea why they wont post?

It *should* work. Maybe you're using a crappy browser (or a strictly standards 
only browser) in which case you ought to (and you should do this anyway) be 
using proper HTML ie:

input type=hidden name=keyField[mb_memberships][0] value=mb_e_id

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Problem with hidden form input values

2005-01-19 Thread Jochem Maas
Ben Edwards (lists) wrote:
I know this is not strictly speaking a PHP question but it is to do with
a PHP app.
I have a form with a number of hidden values in it.  After the post
print_r( $_POST ) shows all the values except these (this is copied from
'Show Source' in the browser.
input type=hidden name=keyField[mb_memberships][0] value=mb_e_id
input type=hidden name=keyValue[mb_memberships][0] value=10
input type=hidden name=keyField[mb_memberships][1] value=mb_id
input type=hidden name=keyValue[mb_memberships][1] value=1
long shot: try quoting all your attribs:
input type=hidden name=keyValue[mb_memberships][1] value=1 /
Any idea why they wont post?
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Problem with hidden form input values

2005-01-19 Thread Jochem Maas
Richard Lynch wrote:
Ben Edwards (lists) wrote:
I know this is not strictly speaking a PHP question but it is to do with
a PHP app.
I have a form with a number of hidden values in it.  After the post
print_r( $_POST ) shows all the values except these (this is copied from
'Show Source' in the browser.
input type=hidden name=keyField[mb_memberships][0] value=mb_e_id
input type=hidden name=keyValue[mb_memberships][0] value=10
input type=hidden name=keyField[mb_memberships][1] value=mb_id
input type=hidden name=keyValue[mb_memberships][1] value=1
Any idea why they wont post?

The *do* POST, but PHP only handles one level of array references in NAME=xxx
not true (he does mention that print_r() does not show these values, 
given that he has run print_r() on $_POST its fair to assume that he 
would have noticed if his var were only 'half there' so to speak),

here's a url format I use in a generic CMS thingy:
?a=512e[n]=xxxe[f][kf][MY_ID]=1e[f][kf][YOUR_ID]=2e[f][n]=xyze[f][kf][CHILD_ID]=3
the only problem I have is that I can max out the number of bytes 
excepted in a GET request, I don't destiguish between POST/GET and it 
works just as well via a post form.

arbitrary $_POST dump (simple):
Array
(
[a] = 512
[e] = Array
(
[n] = compoundpart
)
[PART_ID] =
You can do something like:
?php
  while (list($keys, $value) = each($_POST['keyField'])){
$keys = explode('][', $keys);
list($key1, $key2) = $keys;
$realKeyField[$key1][$key2] = $value;
  }
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] NT domain info

2005-01-19 Thread Mikey
Hi NG!

Does anyone here know of a way of getting at the user account information
from a windows domain controller from a Linux box, specifically in PHP?

I was thinking of writing a COM object for the windows box running a simple
socket service for updates, but that seems like an awful lot of coding (not
to mention having to write COM garbage).  Has anyone else here had to tackle
a similar problem, or does anyone know enough about Windows and domain
accounts to be able to point me in the right direction?

TIA,

Mikey

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



[PHP] Serving WML

2005-01-19 Thread Mikey
Hi again - thought it best to keep the two topics separately...

I have just leased a virtual hosting package and want to provide GPRS access
to my email server using WML.

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

I have read a little about gateways and from what I have read it seems that
it would be my phone company that was responsible for providing that.

Any ideas?

Mikey

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



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

2005-01-19 Thread Sephiroth

Jason Barnett [EMAIL PROTECTED] ?
news:[EMAIL PROTECTED]

 You can use the file functions with URLs so long as you have
 allow_url_fopen set to TRUE in your php.ini.


Doesn't works even
allow_url_fopen is true

PHP 4.3.10
Apache 1.3.27
Platform Windows 98

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



Re: [PHP] NT domain info

2005-01-19 Thread Bruce Douglas
mikey...

i'm not a guru... but this sounds like something that someone should have 
already done (or thought about) in perl. you might find that there's already a 
perl app/solution that gets you close to what you need, that would allow you to 
either use the perl solution, or rewrite what it does in php...

good luck!!

bruce


-Original Message-
From: Mikey [EMAIL PROTECTED]
Sent: Jan 19, 2005 4:13 PM
To: '[php] PHP General List' php-general@lists.php.net
Subject: [PHP] NT domain info

Hi NG!

Does anyone here know of a way of getting at the user account information
from a windows domain controller from a Linux box, specifically in PHP?

I was thinking of writing a COM object for the windows box running a simple
socket service for updates, but that seems like an awful lot of coding (not
to mention having to write COM garbage).  Has anyone else here had to tackle
a similar problem, or does anyone know enough about Windows and domain
accounts to be able to point me in the right direction?

TIA,

Mikey

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

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



RE: [PHP] NT domain info

2005-01-19 Thread Mikey
Well, I went to CPAN and found:

http://www.cpan.org/modules/by-category/22_Microsoft_Windows_Modules/Win32/W
in32-AD-User-0.01.readme

Looks like that will have what I need, and from what I remember socks are
dead simple in Perl - time to read up again!

Mikey

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



[PHP] Re: NT domain info

2005-01-19 Thread Manuel Lemos
Hello,
on 01/19/2005 10:13 PM Mikey said the following:
Hi NG!
Does anyone here know of a way of getting at the user account information
from a windows domain controller from a Linux box, specifically in PHP?
I was thinking of writing a COM object for the windows box running a simple
socket service for updates, but that seems like an awful lot of coding (not
to mention having to write COM garbage).  Has anyone else here had to tackle
a similar problem, or does anyone know enough about Windows and domain
accounts to be able to point me in the right direction?
If you want to just authenticate the user logged in a Windows domain, 
use Apache mod_ntlm.

--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: NT domain info

2005-01-19 Thread Mikey
 If you want to just authenticate the user logged in a Windows domain,
 use Apache mod_ntlm.

Nah, I need to be able to syphon off a whole list of users and their account
details (but not their password).  Thanks anyway!

Mikey

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



Re: [PHP] NT domain info

2005-01-19 Thread Jordi Canals
On Thu, 20 Jan 2005 00:13:35 -, Mikey [EMAIL PROTECTED] wrote:
 Hi NG!
 
 Does anyone here know of a way of getting at the user account information
 from a windows domain controller from a Linux box, specifically in PHP?
 

The Windows domain controllers run LDAP. So, you can use the PHP LDAP
functions to retrieve information from it.

Looking for it, I've found an example at
http://asia.cnet.com/builder/architect/system/0,39009336,39105862,00.htm

I think this sample could give you an overview to start playing.

Best regards,
Jordi.

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



Re: [PHP] NT domain info

2005-01-19 Thread Leif Gregory
Hello Bruce,

Wednesday, January 19, 2005, 6:06:28 PM, you wrote:
BD i'm not a guru... but this sounds like something that someone
BD should have already done (or thought about) in perl. you might
BD find that there's already a perl app/solution that gets you close
BD to what you need, that would allow you to either use the perl
BD solution, or rewrite what it does in php...

They have in PHP...

I learned a lot from this:

http://www.phpldapadmin.com/product_info.php/products_id/29

Free to home users.



Cheers,
Leif Gregory 

-- 
TB Lists Moderator (and fellow registered end-user)
PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
Web Site http://www.PCWize.com




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



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

2005-01-19 Thread Jason Wong
On Thursday 20 January 2005 09:17, Sephiroth wrote:
 Jason Barnett [EMAIL PROTECTED] ?
 news:[EMAIL PROTECTED]

  You can use the file functions with URLs so long as you have
  allow_url_fopen set to TRUE in your php.ini.

 Doesn't works even

HOW does it not work? Did you RTFM on the limitations of opening remote files?

 allow_url_fopen is true

 PHP 4.3.10
 Apache 1.3.27
 Platform Windows 98

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



[PHP] class structure.

2005-01-19 Thread Dustin Krysak
Hi there, I am pretty new to writing classes (and pretty new to PHP 
itself), but I was wondering what was the best format for constructing 
classes. Now for example, i have written 2 versions of a class that 
accomplish the exact same thing. And I was just wondering if there are 
any advantages to either, or even if one was formatted more so to 
standards. Just wanting to learn it the proper way from the get go. My 
classes are formatted for use in flash remoting (hence the methodTable 
stuff - you can ignore it). I guess my question refers more towards the 
declaration of properties, etc.

[ VERSION 1 ]
?php
class Sql {
// Set properties
//DB info
var $hostname_local = localhost;
var $database_local = mydb;
var $username_local = root;
var $password_local = password;
var $local;
var $query_rs_biz;
var $rs_biz;
function Sql() {
$this-methodTable = array(
getRecords = array(
description = return a SQL record,
access = remote,
arguments = array()
)
);
}
//SQL
//Create method to retreive records
function getRecords() {
$this-local = mysql_pconnect($this-hostname_local, 
$this-username_local, $this-password_local) or 
trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($this-database_local, $this-local);
$this-query_rs_biz = SELECT * FROM directory ORDER BY Business ASC;
$this-rs_biz = mysql_query($this-query_rs_biz, $this-local) or 
die(mysql_error());

//return $this-row_rs_biz;
return $this-rs_biz;
}
}
?
[ VERSION 2 ]
?php
class Sql2 {
// Set properties
//DB info
var $hostname_local = localhost;
var $database_local = Blisting;
var $username_local = root;
var $password_local = URAredneck;
function Sql2() {
$this-methodTable = array(
getRecords = array(
description = return a SQL record,
access = remote,
arguments = array(),
returns = sql records
),
getRecCount = array(
description = return the row count from the 
getRecords method,
access = remote,
arguments = array(),
returns = sql row count
)
);
}
//SQL
//Create method to retreive records
function getRecords() {
$local = mysql_pconnect($this-hostname_local, $this-username_local, 
$this-password_local) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($this-database_local, $local);
$query_rs_biz = SELECT * FROM directory ORDER BY pID ASC;
$rs_biz = mysql_query($query_rs_biz, $local) or die(mysql_error());

//return results;
return $rs_biz;
}
}
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Best way to encode?

2005-01-19 Thread Ligaya Turmelle
Are you talking about page encoding?  if so try utf8 on the pae with the 
form.  (meta http-equiv=Content-Type content=text/html;charset= 
utf-8 /) it handles just about any language for input.  and as long as 
you  don't want to do a search on the input it can go right into the 
database (table character_set = utf8) for later extraction and display 
on a utf8 page.

if you're talking about encoding to hide the data - use base64_encode 
and base64_decode.

Respectfully,
Ligaya Turmelle
Brian Dunning wrote:
I have a form where people input some text, which is then incorporated 
into an HTML snippet which appears in a textarea for them to copy  
paste into a web page.

People will be entering foreign language stuff as well as special 
characters like copyright, so I have to be sure this is handled properly.

I tried rawurlencode() but that results in HTML which displays the 
encoding when they paste it into their web page. I tried htmlentities 
but that gives different characters than what they typed when displayed 
in the textarea. I also tried no encoding, which worked well, except 
that it gets messed up when I try to write it to the database and I have 
the same problem again when retrieving it.

Cañon © is a good example.
htmlentities('Cañon ©') - Cañon © in the textarea, displays on their 
web page as Cañon ©
rawurlencode('Cañon ©') - Ca%C3%B1on%20%C2%A9 in the textarea, displays 
on their web page as Ca%C3%B1on%20%C2%A9from the database.
No encoding gives Cañon © in the textarea and displays on their web page 
as Cañon ©, but appears in the database as Cañon ©

How can I handle this so that what ultimately displays on their web 
page, after copying the HTML out of the textarea, matches what they 
typed in the form, and yet can be read  written from the database 
properly?

- Brian

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

[PHP] Re: corrected

2005-01-19 Thread chuck
Requested file.


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

[PHP] Shell Redirection in safe_mode

2005-01-19 Thread Mirko Heise
Since i enabled safe_mode in PHP, commands like exec(mysqldump 
/tmp/123.sql) dont work any longer. So is redirection  disabled in
safe_mode ?
mysqldump is executable from my safe_bin dir an i got write permission
on the specified directory.
Thanks in advance.

With regards
Mirko Heise

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



[PHP] Re: 404 custom handler on a cgi-wrap PHP - No input specified error

2005-01-19 Thread PHPDiscuss - PHP Newsgroups and mailing lists
Luke Barker wrote:

 I have made a 404 custom error handler, using .htaccess in a directory
 - it is usppoed to route all unfound pages to error.php, and works as
 expected for .htm and .html pages as well as gifs etc. But ofr .php
 scripts, e.g /path/to/wrongurl.php it doesnt show my page -
 instead it shows No Input file specified.. After some Googling I have
 only found people witht eh similar problem without solutions.

 Can any one help me on this? I should say that in IE it just gets the
 default 404 ( I think this is windows own one responding to the
 particular http response header) - in firefox you get the 'No input ' 
 error

 thanks for any advice

 Luke


Hey Luke,

I had the exact same problem on one of my sites and was able to come up
with a solution using mod_rewrite:

http://jenseng.com/archives/35.html

Hope that's of some use.

Jon

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