Re: [PHP] Open New URL window

2007-09-20 Thread Don Read
On Thu, 20 Sep 2007 02:52:19 -0400 Andrew Prostko said:


Ok, so I started using the header code that was suggested:

And I get this error: 

Parse error: parse error, unexpected '{' in
/home/char-lee/public_html/beta/1.php on line 3

This is the code:
---
?php
if ($_POST['pw'] != burgers
{
header(Location: password.php);
}
else
{
header(Location: sept-coupon07.html);
}
?
---

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


Close your parenthesis, daggummit!

if ($_POST['pw'] != burgers )
   ^^^

-- 
Don Read  [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Close all open tags in HTML text

2004-12-13 Thread Don Read

On 09-Dec-2004 Marek Kilimajer wrote:
snipage
 
 not really, but it removes script and /script so javascript is
 not 
 interpreted.

$txt = preg_replace('|script[^]*?.*?/script|si', '', $txt);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Re: PHP Coding Standards

2004-06-01 Thread Don Read

On 31-May-2004 Travis Low wrote:
 I have to say I like everything about the PEAR coding standards
 except for the 
 KR bracing style.  I much prefer:
 
if( foo )
{
   blah;
}
 

Icky.

So ... Vee-Eye or Eighty Megs and Constantly Swapping ?
 ;-



-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] mySQL table output...

2004-05-25 Thread Don Read

On 23-May-2004 Russell P Jones wrote:
 I just want to print out a table from mySQL. Thats it. into an html
 table.
 
 Column 1 |  Col 2 | Col 3
 -
 Val 1|  val 2 | val 3
 Val 4|  val 5 | val 6
 
 
 any ideas on how to do this?
 

if ($res = mysql_query($qry)) {
echo 'table';
while ($row = mysql_fetch_array($res) 
echo 'trtd' .implode('/tdtd', $row) .'/td/tr';
echo '/table';
} 


Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] How to insert, change and remove fields like Enum

2004-05-23 Thread Don Read

On 21-May-2004 Andre wrote:
 
 Hello...
 Someone now or have script's about   insert, change and remove fields
 like Enum in one table.
 Thanks .
 

For sets (Emum should be similar) :

function getsetvalues($tbl, $fld) {
global $dbconn;

$search=array('set(', ')', ');

$qry=SHOW COLUMNS FROM $tbl LIKE '$fld';
$r = $dbconn-Execute($qry);
if ($row = $r-FetchRow()) {
if (! empty($row['Default']))
$cv['__Default__'] = stripslashes($row['Default']);
$s=str_replace($search, '', stripslashes($row['Type']));
$l=explode(',', $s);
foreach($l as $v) 
$cv[$v] = 1;
}
return($cv);
}

// add to set:
$cv[$new] = 1;
$dflt = $cv['__Default__']; unset($cv['__Default__']);
$s = implode(',', array_keys($cv));
$qry = ALTER TABLE $tbl CHANGE COLUMN 
  $fld $fld SET('$s') NOT NULL DEFAULT '$dflt';

// I'm sure you can figure out the rest

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Constant questions

2004-05-19 Thread Don Read

On 12-May-2004 René Fournier wrote:
 Hi,
 
 I have two questions involving Constants.
 
 1. I want to refer to a refer to a Constant by its value (which is 
 unique), and return its name. E.g.,:
 
   define (SEND_DS,1);
   define (SEND_DS_ACK,2);
   define (RESEND_DS,3);
   define (STARTUP_DS,12);
 
 For example, if I receive 3, I would like to echo RESEND_DS--the 
 name of the constant. Is there a simply way to do this? Or am I
 better 
 using an Associative Array (which is what I was thinking)? Then I
 could 
 such refer to an element by its key or value (both of which are 
 unique). 

Both.

get_defined_constants()
array_flip()

Regards,

-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Best way to do Last 3 Items Viewed

2004-05-19 Thread Don Read

On 14-May-2004 Chuck Barnett wrote:
 Anyone have any code snippits that would allow me to do a Last 3
 Items
 Viewed like on ebay?
 

array_unshift($items, $new);
$items = array_slice($items, 0, 3));

Regards,

-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] create if table not exists

2004-05-19 Thread Don Read

On 17-May-2004 John Taylor-Johnston wrote:
 How can I check if a table exists in a mysql db.

function tableexists($tbl) {
$res = @mysql_query(SELECT COUNT(*) FROM $tbl);
return ($res ? true : false);
}

Regards,

-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Multiple Update from one form

2004-05-19 Thread Don Read

On 18-May-2004 Miles Thompson wrote:
 
 This is close to your situation, but I only needed a one dimensional
 array 
 for a bulk delete. So the form part has this line:
  print( 'input type=checkbox name=chkdelete[] value=' . 
 $myrow['sub_key'] . '');
 There's no need for a subscript in the form - there are presently a 
 potential of 963 elements in this array. When we check for bulk
 delete it's 
 never contiguous, we skip down the list, so array is v. sparse.
 
 And the processing part uses this loop:
 
  foreach ($chkdelete as $value){
  $sql = delete from subscriber where sub_key =
 '$value';
  $result = mysql_query($sql);
  }
 
 This way I'm in no danger of hitting a missing subscript as I might
 if I 
 used $chkdelete[ $i ], incrementing $i
 

Since it's a checkbox and you'll only get checked values in the 
$_POST header; you just might as well use the subscript and skip the
loop entirely:
...

if (count($_POST['chkdelete'])) {
$lst = implode(',',array_keys($_POST['chkdelete']));
$qry = DELETE FROM subscriber WHERE sub_key IN ('$lst');
mysql_query($qry);
}

...

Regards,

-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] slow upload with http post

2004-04-21 Thread Don Read

On 21-Apr-2004 Yavuz Maºlak wrote:
 full duplex

What's the output of:

mount and sysctl -a | grep '^hw' ?


-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Array Problem

2004-04-18 Thread Don Read

On 16-Apr-2004 Flavio Fontana wrote:
 Hi
 
 I have i Problem i got a variable a=2351 now i need to create an
 array out of this variable 
 a[0]=1
 a[1]=3
 a[2]=5
 a[3]=1
 
 I have an idea to use the modulo function an do some Math but im sure
 there is a nicer way of solving my prob
 

$a = preg_split('||', $a, -1, PREG_SPLIT_NO_EMPTY);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] alternating row color--newbie help

2004-04-16 Thread Don Read

On 15-Apr-2004 Chris W. Parker wrote:
snip
 for($i = 0; $i  $numofrows; $i++)
 {
   ...
   $row_color = ($i % 2 == 0) ? yellow : white ;

$row_color = $row_color == yellow ? white : yellow ;

 
   echo tr bgcolor=\$row_color\\n;
   ...

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] After calling a Function the Script aborts without any error :-\

2004-04-12 Thread Don Read

On 12-Apr-2004 William Lovaton wrote:
 Hi,
 
 El lun, 12-04-2004 a las 09:27, John W. Holmes escribió:
 From: Ben [EMAIL PROTECTED]
 
  i got a big problem. I have a script which includes some other
  script i
  tried include, require and require once. The problem is, if i do a
  function call to a function in one of these included files, the
  script
  aborts but without any error. The strange thing is, normally
  require
  should give an error if it can't include any file. But the files
  are
  accessible, error reporting is E_ALL. Some functions are callable
  but
  others not and still no error. the only way how i came to this was
  putting some die()s to see where 
 
 Do you have display_errors turned on?
 
 Sometimes I have this problems too, no matter if that setting is on.
 

If the error occurs within a table element on a web page, Mozilla won't
display because it's waiting for the '/tr/table' to begin figuring
out the display properties.

Use 'View Source' if/when this happens.

Regards,

-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] timestamp to readabe date and time ?

2004-04-11 Thread Don Read

On 11-Apr-2004 Ryan A wrote:
 
snipage

 If you are using timestamp(14), here is how i do it: (after
the
 select)
 
 if(($row = mysql_fetch_row($result))=1)
 {
   $d_year = substr($row[4],0,4);
   $d_month = substr($row[4],4,2);
   $d_day = substr($row[4],6,2);
   $d_hours = substr($row[4],8,2);
   $d_mins = substr($row[4],10,2);
   $d_secs = substr($row[4],12,2);
 }

Ugh!

list($y, $m, $d, $h, $i, $s) = split('[-:/. ]', $row[x]);



-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] writing a class in php to print form elements

2004-04-10 Thread Don Read

On 07-Apr-2004 Andy B wrote:
 hi...
 
 is it totally usefull/reasonable to write a class in php that prints
 different different form elements in html...
 
 i.e. inputs, buttons, drop downs, multi selects and son? that way (at
 least
 i think) then it would be easier to change the element attributes
 dynamically...
 

I think just about everybody re-invents that wheel ...

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] (new question on this) http referer

2004-04-10 Thread Don Read

On 08-Apr-2004 John Nichel wrote:
 Joe Szilagyi wrote:
 Just a follow up on this one--I've seen where consistently that
 $HTTP_REFERER will only show local referers, but not stuff from
 other
 sites/hostnames. This is on mod_php... any workaround for that?
 
 Regards,
 Joe
 
 The referrer is sent by the referring machine.  If that machine isn't
 setting it, you can't get it.  If memory serves, I think I remember 
 someone claiming that this could also be blocked at a
 firewall...don't 
 know if that's true or not though.

Not a firewall. The 'Referer' is in the headers, that would mean the FW
would have to edit the stream (~shudder~).

A 'proxy' server on the other hand will re-write headers :

mysql select url from urls where url not like 'http%' limit 5;
+--+
| url  |
+--+
| 1.0 TECH002  |
| 1.1 wall:800 (squid/2.5.STABLE2) |
| 1.0 px2nr (NetCache NetApp/5.5D1)|
| 1.0 arnink[D4BB2507] (Traffic-Server/5.2.1-58896 [uSc ]) |
| 1.1 ffm2-t6-1.mcbone.net:3228 (Squid/2.1.PATCH1) |
+--+
5 rows in set (0.00 sec)

FYI: 

mysql select count(*) from urls;
+--+
| count(*) |
+--+
|   261511 |
+--+
1 row in set (0.00 sec)

mysql select count(*) from urls where url not like 'http%';
+--+
| count(*) |
+--+
|69594 |
+--+
1 row in set (0.38 sec)

mysql select 69594/ 261511;
+---+
| 69594/ 261511 |
+---+
|  0.27 |
+---+
1 row in set (0.00 sec)

So 27% of my hits are by proxy (for this site/month anyhow).

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] control panel--graphic question

2004-04-02 Thread Don Read

On 02-Apr-2004 Leonard B Burton wrote:
 Greetings,
 
 This is more of a graphic question
 
 For a program I am writting I need to have a control panel to display
 anything that may be wrong.  I would like to use something like a
 stoplight so that it would be easily understood by a lay person. 
 Does anyone have any comments as to what they have used?  Also does
 anyone have a function/graphic that would be a stop light and
 changing the var would make it either show red, green, or yellow?

 
function stoplight($val) {

$light = array(
  'ok'= 'images/green.jpg',
  'iffy'  = 'images/yellow.jpg',
  'bad'   = 'images/red.jpg'
);

echo 'img src=' .$light[$val] .' height=xxx width=xxx';
}

 ...

stoplight( $foo  10 ? 'ok' : $foo  25 ? 'bad' : 'iffy' );


Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Re: Local sysadmin DFW needed

2004-03-27 Thread Don Read

On 26-Mar-2004 Roger Spears wrote:
 
 I'm going to guess DFW is just south of BFE
 

It just seems like it.
;-

-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Re: date() funtion language

2004-02-12 Thread Don Read

On 12-Feb-2004 André Cerqueira wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 i had problems with locale
 i think its safer to make a dayname and monthname array, and use
 getdate(), than build the string yourself
 

snip

 
 //the follow should, but doesnt seem to work
 //setlocale(LC_ALL, 'pt_BR');
 //echo date('l, j de F de Y');
 ?

date() doesn't format according to locale but strftime() does:

setlocale(LC_ALL, 'pt_BR.ISO8859-1');
echo strftime('%A, %B %e %Y');

// output 'Quinta Feira, Fevereiro 12 2004'



-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] FreeBSD to Linux -- PHP Issues

2004-02-07 Thread Don Read

On 03-Feb-2004 Daryl Meese wrote:
 Hello all,
 
 I am considering changing hosting providers and moving from FreeBSD
 to
 Linux.
 
 My question is are there any PHP related issues to moving (functions
 that
 don't work on Linux but do on FreeBSD, etc)?
 
 I doubt there are but have to cover the bases.
 

All functions, assuming they were configured, work the same. The only
thing that isn't a one-for-one swap (that I've seen) is locale names:

[Linux]
nat221.dread$ ls | grep es_
es_AR
es_ES

[FreeBSD]
localhost.dread$ ls | grep es_
es_ES.DIS_8859-15
es_ES.ISO8859-1
es_ES.ISO8859-15
es_ES.ISO_8859-1
es_ES.ISO_8859-15

So if you're part of the 99.9% that don't mess with locales, you should
be OK.


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Checking if database has been setup

2004-02-07 Thread Don Read

On 07-Feb-2004 Ryan A wrote:

snip

 but how do i check if the database/tables have
 been setup?
 

SHOW DATABASES LIKE 'mydb';
SHOW TABLES FROM mydb LIKE 'mytable';

Check if a table exists:

SELECT 1 FROM mydb.mytable LIMIT 1;

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] finding news stories in a selection of months

2004-02-04 Thread Don Read

On 02-Feb-2004 Michael Hill wrote:

 Hi everyone,
snip
 heres the code i have:
  
  $strSQL = SELECT date from .$tbl_prefix.news  where live=1 order
 by
 date asc limit 0,1;
  $result = mysql_query($strSQL,$dbconn);
  $firstresult = mysql_fetch_array($result);
  $firstdate = $firstresult['date'];
  $firstmonth = substr($firstdate, 4, 6);
  $firstyear = substr($firstdate, 0, 4);
  
  
  
  
  $strSQL = SELECT date from .$tbl_prefix.news  where live=1 order
 by
 date desc limit 0,1;

snip

$qry=SELECT MIN(date) AS first, MAX(date) as last FROM ...;
$res=mysql_query($qry);

if (mysql_numrows($res) ) {
   $row=mysql_fetch_array($res);
   list($fy, $fm, $fd) = explode('-', $row['first']);
   list($ly, $lm, $ld) = explode('-', $row['last']);
} else {
   echo 'Not found', 'P';
}

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Help for code to 'sort list' please

2004-02-04 Thread Don Read

On 02-Feb-2004 EastLothianDirectory wrote:
 Was just reading your previous reply and my months are indeed in text
 and therein 
 lies the problem.

snip 

Look at the MySQL functions FIELD() and/or FIND_IN_SET().

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] file separator...

2004-02-01 Thread Don Read

On 30-Jan-2004 Dan Joseph wrote:
 Hi Everyone,
 
   Hoping someone can shed a light on this.  I have to send a file
 separator
 in a string that I piece together to a remote system.  I've been told
 this
 is x'1C' ASCII or x'22' HEX.  I have no idea what to really send. 
 I've
 tried several things.  Can someone tell me what it is they're looking
 for?
 

The FS escape is 0x1C or 28 in decimal.

$fs=chr(28);

$files='myfile1.dat' .chr(28);
$files .='myfile2.dat' .chr(28);
$files .='myfile3.dat';

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] naming a directory after a user-submitted string

2004-01-28 Thread Don Read

On 28-Jan-2004 Joey Manley wrote:
 Here's another question, possibly easier.  Possibly even bone-headed.
 
 What kind of checking/filtering/changing do I need to do on a
 user-submitted
 string before I can feel comfortable using it to name a new directory
 in the
 web root on Linux/Apache?  Anybody have a quick Regular Expression
 they can
 toss at me?  If so, I'd be muchly appreciative.  Or is this just a
 Terrible
 Idea That Should Never Be Contemplated?
 

1. Please don't hijack threads.

2. Make everything dodgy into a directory delimiter and get the last bit
of the path (untested code ahead) :

// cleanup
$unsafe=preg_replace('[^\w]', '/', $unsafe);

// get trailing dirname (explode and pop would work also)
$dir = substr(strrchr($unsafe, /), 1);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] stepping through alphabet

2003-11-19 Thread Don Read

On 19-Nov-2003 Steve Buehler wrote:
 
 Amazing what I learned today. :)  I love this list and its people.
 

How about one more? (ver 4.1.0):

foreach(range('A', 'Z') as $letter) {
echo $letter, \n;
}

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] How to remove new line character?

2003-11-03 Thread Don Read

On 02-Nov-2003 Koala Yeung wrote:
 Thanks a lot
 
 I'd like to remove newline only.
 Is there any simple way?
 

rtrim($str, \r\n);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] German Date - GMDATE Function

2003-10-23 Thread Don Read

On 22-Oct-2003 Steve Vernon wrote:
 Hello,
 
 When I use the gmdate function, I get the English date, e.g. October. Is
 it
 possible to get the date in German or another language? I really need the
 server setting up so that it can handle different languages.
 

$locale='de_CH.ISO_8859-1'; // Alternate: 'de_DE.ISO_8859-1' 

setlocale(LC_TIME, $locale);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Email Body

2003-10-23 Thread Don Read

On 22-Oct-2003 micro brew wrote:
 I am sending an email using mail() and it works fine. 
 But the formatting of the body of the email is wrong. 
 I want to format part of it in columns sort of like
 this:
 Name   Quantity  Price
 
 Can this be done neatly without using an html email?
 

sprintf(%-25 %2d %9.2f\n, 
  $name, $qty, $price);

 Also what is the trick to making line returns display
 properly in the email client?  I've tried using \r\n
 with no luck.  I also tried \n.  The characters show
 in the email but no line breaks.  Any suggestions?
 

double-quotes around your string?

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] How do I do this PERL in PHP?

2003-09-17 Thread Don Read

On 16-Sep-2003 Susan Ator wrote:
 I have a text file with the following format:
 
 TO name
 SUBJECT stuff
 MESSAGE
 message text
 message text
 message text
 

snip

If you're sure the format is exactly that, then ...

$pat=array(
  'SUBJECT',
  'MESSAGE',
);

$marker='FOO';

$data=file_get_contents('dafile.txt');

$msgblks=explode('TO', $data);

foreach($msgblks as $blk) {
  list($to, $subj, $msg) = 
explode($marker,preg_replace($pat, $marker, $blk));
  ...
  do__your_stuff($to, $subj, $msg);
  ...
}


Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] a generic getsql() function

2003-06-25 Thread Don Read

On 25-Jun-2003 Thomas Hochstetter wrote:
 Hi guys,
  
 I wrote a generic getsql() function for my project's class. However, I
 only manage to retrieve a single row. What it should really do is:
 Read all rows into the array (with multiple results).
 The code is below:
  
 function getsql($sql,$conn,$dbase,$arr)
 {
 if($conn)
 {
 mysql_select_db($dbase,$conn);
 $result = mysql_query($sql,$conn);
 
 while ($arr = mysql_fetch_assoc($result))
 {
 return $arr;
 // Something has to happen here!!!

  Nothing will happen here!!!
  You've already returned from the function.

 }
snipage

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Reg Exp help needed

2003-06-24 Thread Don Read

On 24-Jun-2003 Sparky Kopetzky wrote:
 I'm translating (hacking) code from Perl to PHP and have two reg exp
 expressions I can't figure out what they do.
 
 1st: $goodbadnum =~ tr/0-9//cd; I think this one removes any chars that
 are not numbers.
 

Nope. That removes digits '0-9'
$goodbadnum= preg_replace('!\d+!', '', $goodbadnum);

 2nd: $goodbadnum =~ tr/0-9/x/; I think this one replaces and numbers with
 an 'x'.
 

Yep. that replaces every digit with an 'x'.
$goodbadnum= preg_replace('!\d!', 'x', $goodbadnum);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] execute a command

2003-06-22 Thread Don Read

On 22-Jun-2003 Mattia wrote:
 How to execute a command capturing the stanndard error, in addition to 
 standard output? example:
 
 echo system('/bin/rm ...');
 
 I need to know when this command fails, and when it fails, i need to 
 know why. Any hints?
 
 _Mattia_
 

$cmd='/bin/rm foo';

exec($cmd 21, $output);

 -- or --

exec($cmd, $output, $errno);
echo posix_strerror($errno);

 -- or -- 

proc_open(...) and read from pipe[2]

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



Re: [PHP] How do I get the exit code of an external program?

2003-06-22 Thread Don Read

On 23-Jun-2003 Daevid Vincent wrote:
 I wish to use Ping to test if some IP addresses are up... Now I could run
 the command and parse to find various string components like this:
 

snip
 
 So it seems to me there needs to be another PHP function like exec(),
 shell(), etc. that is the equivillent of the php exit() function but for
 external programs. One that simply returns the integer exit code of an
 executed shell program...
 
 

exec(), system(),  popen()/pclose() will return exit code.

The manual is your friend.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



Re: [PHP] Seating chart registration system?

2003-06-21 Thread Don Read

On 21-Jun-2003 Jay Fitzgerald wrote:
 I am writing a php event registration system for lanparties and I believe
 I have everything written that I need except for a seating selection
 chart.

snip
 
 As a person goes through the event registration system, they will come to
 a 
 page that displays 8 rows of 30 seats (240 seats total)...but in the
 future 
 I would like to have admin capability to increase or decrease this
 amount. 

snip


 Then when the next person decides to register, when they get to that
 page, one less seat will be available. I would like to have as much
 control as  possible and I do know a minor bit of php and mysql.
 
 Any help or guidance is appreciated.
 

programmer doodle

Couple of thoughts ...

Each 'event' is unique to time and place. 
So you'll need a 'event' table with datetime, interval, name,
description and a place (or 'forum' --see next paragraph).

table event (
  id int unsigned auto_inc primary key,
  idforum int unsigned,
  ebeg datetime not null, // begins
  eend datetime not null default '0', // ends
  emin int unsignd default 0, // how long in minutes 
  name varchar(64),
  descript text,
  index idx_b (ebeg),  // might be handy ...
  index idx_f (idforum)
)
 
Each place is (usually) limited to hosting one 'event' at any interval.
But some places can have several events at the same time. Consider a major
hotel and all the conference rooms --or a sports stadium with all the
owner, boxholder's, home-team,  visting-team parties ...

So 'place' is a poor term. I'll suggest using 'forum' as the locale to be
to attend a particular event.

Also you'll have to think about assigned seating and/or general admission
seating. 

Example:

At the downtown Hilton, the local Lions club might reserve the Omega room
w/ 5 seats per 4 tables, general admission. 
But a dinner with President Bush in the Omega room is gonna run like 6
seats @ 40 tables. And definitely assigned seating.

Same room name but clearly a different 'forum'.

It's a toss-up if this should be a field in the 'event' or in the
'forum' table. I go with forum.

So there's another table:

table forum (
  id int unsigned auto_inc primary,
  name varchar(16),
  descript text,
  ftype enum('A', 'G'), // assigned or general seating
  m_block int unsigned not null,// max # of seating blocks
  m_seats int unsigned not null,// seats per block
  block_type enum('row','table','section') not null default 'row',
 // what does m_block encompass?
  seat_limit int unsigned not null default 0,
 // maximum seats (m_block * m_seats where ftype='A')
  unique index (name)
)

Then there is seating. 

When each event/forum is scheduled your app adds m_block * m_seats to 
a seating table.

For general admission add block=x, seat=1 - seat_limit.

 --- 

The 'seating' table is where it gets tricky --and where it gets solved.

table seating (
  idforum int unsigned not null,  // link to forum description.
  block int unsigned not null,// a dinner table or stadium row
  seat int unsigned not null, // d'oh
  guest int unsigned not null default 0, // who has this seat ? 
  primary key (idforum, block, seat),
  INDEX idx_g (guest) // handy stuff.
)

Assigned seating:

As each guest reserves a [optional] seat:
UPDATE seating SET guest='$idguest' 
  WHERE idforum='$idforum' AND block='$idblock' [AND seat='$idseat']
  AND guest=0

General admission:

UPDATE seating SET guest='$idguest' 
  WHERE idforum='$idforum' AND block='$idblock'
  AND guest=0

/programmer doodle

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Small problem with date and location information?

2003-06-21 Thread Don Read

On 22-Jun-2003 Philip J. Newman wrote:
 I run a website from New Zealand.  The problem is when ?php echo date(F
 j, Y, g:i a); ? it shows the time of the server, that just happens to
 be located in Dallas USA. Is there a way that I can change the time so it
 matchs New Zealand Time?
?php
echo date('F j, Y, g:i a'), 'br';
putenv('TZ=PST8PDT');
echo date('F j, Y, g:i a'), 'br';
putenv('TZ=CHAST');
echo date('F j, Y, g:i a'), 'br';
?

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



Re: [PHP] strange crypt() problem

2003-06-20 Thread Don Read

On 19-Jun-2003 Huzz wrote:
 I have this bit of code to crypt user password in user registration as
 shown
 below.
 
  $cryptpass=crypt($makepass);
 which generated crypted password like eg 37Q9fppLHc4fQ with php 4.0
 
 And am using the codes below to check for valid login..
 // $pass -  from login page
 // $dbpass - from the database
  $pass=crypt($pass,substr($dbpass,0,2));
 }
 if (strcmp($dbpass,$pass)) {
 return(0);
 }
 
 
 Recently i have moved the same file to a new server with php 4.3.1 the
 problem is the same piece of codes above generates completely differen
 crypted  value eg.$1$RjZHv7qx$h/L9ZUNT48rilHB6fGoMP/  .. hence the login
 codes above does not work... :(
 

The '$1$' means it's a md5 password.

Don't chop-up the encryped passwd.
Use the whole string for the seed and let crypt() handle it:

$epass=crypt($pass, $dbpass);

if (strcmp($dbpass,$epass)) {
  ...

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



Re: [PHP] Cookies- peanut butter or chocolate??

2003-06-20 Thread Don Read

On 19-Jun-2003 Steve Keller wrote:
 At 6/19/2003 02:10 PM, Sparky Kopetzky wrote:
 
   2. How do you put 2 items that you want to save in the cookie and 
 retrieve??
 
 Smuch 'em together into a single variable with a delimiter you're sure 
 won't show up in either value, something like #@@#, between them. Then,
 when you read the cookie value in, just explode it by your delimiter.
 

setcookie (twovar, serialize(array($var1, $var2)), ...);

...

list($var1, $var2) = unserialize($_COOKIE['twovar']);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



Re: [PHP] updateable database- please help- only displaying first word from field

2003-06-20 Thread Don Read

On 20-Jun-2003 Matt Hedges wrote:
snip

However, the text boxes
 only display the first word of the field from the database.  

Quote your values.

snipagain 

tdinput type=text name=Name value=$Name/td\n

 tdinput type=text name=Name value=$Name/td

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
  


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



Re: [PHP] updateable database 2nd question

2003-06-20 Thread Don Read

On 20-Jun-2003 Matt Hedges wrote:
 Thanks for the help.  I now have the wine information displaying in text
 boxes (below is the code that displays all the wines).
 
 Now I want anyone to be able to change the data in text box/s and hit
 update and it change that field/s.
 
 Would it be something like
 $sql = UPDATE wines SET
 Bodega='$Bodega',Name='$Name',Grape='$Grape',Year='$Year',Region='$Region'
 ,S
 ubRegion='$SubRegion' WHERE id='$id';  ?
 
 How do I set it up with the submit, etc?
 

//refetch the old row ...

$qry=SELECT * FROM tbl WHERE id=' .$_POST['id'] .';
$r=mysql_query($qry);
$row=mysql_fetch_array($r);

// build list of just the changes

unset($chgflds);
foreach($row as $fld = $val) {
   if (isset($_POST[$fld])  ($_POST[$fld] != $val)) {
  $chgflds[] = $fld=' .$_POST[$fld] .';
   }
}
 
// doit.
$update='UPDATE tbl SET ' .implode(', ', $chgflds)
 .WHERE id=' .$_POST['id'] .';

echo '!--Debug :', $update, '--';
mysql_query($update);

...

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] unique random id

2003-06-19 Thread Don Read

On 19-Jun-2003 Awlad Hussain wrote:
 How do i generate a unique random number? 
 

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

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.


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



Re: [PHP] REGEX Question

2003-06-18 Thread Don Read

On 17-Jun-2003 Ron Dyck wrote:
 I need to match text between two html comment tags.
 
 I'm using: preg_match(/!--start_tag--(.*)!--end_tag--/, $data,
 $Match)
 
 Which work fine until I have carriage returns. The following doesn't
 match:
 

Use the m (multiline) modifier:

preg_match(/!--start_tag--(.*)!--end_tag--/m, ...

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
   

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



Re: [PHP] User's Screen Resolution Size

2003-06-18 Thread Don Read

On 19-Jun-2003 John W. Holmes wrote:
snip 
 
 Are you crying? ARE YOU CRYING? There's no crying, there's no crying in 
 PHP!! Rasmus Lerdorf was my manager, and he called me a talking pile of 
 pigs***!

snipagain

 ---John Holmes...
 
 PS: #7 at 
 http://sportsillustrated.cnn.com/features/2003/movies/news/2003/03/26/sens
 ational_scenes/
 
:)

Oh. OK, Good. 
Did you and Rasmus do a basketball scene in The Great Santini ?

-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] mysql_errno codes

2003-06-17 Thread Don Read

On 16-Jun-2003 Thomas Hochstetter wrote:
 Hi.
 
 [3rd try] ... where can i get mysql_error codes from? The ones that
 mysql_errno returns.
 

You can get all the OS and MySQL  error codes with:
$ perror `jot 1500` | grep -v 'Unknown error'

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



Re: [PHP] Creating Images

2003-06-15 Thread Don Read

On 09-Jun-2003 Chris Blake wrote:
snip

 
 Any ideas on how to make it so that the error I specified comes up and
 not the The image http://xxx.xxx.xxx.xxx.x blah blah part.
 
 Here`s the code :
 ---
 ?php
   Header('Content-type: image/png');


A little too early for that. Wait 'til the image is properly created ...

snip

 

//here:

Header('Content-type: image/png');

   ImagePng($image);
   }
ImageDestroy($image);
?

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Re: fetch then put record?

2003-06-15 Thread Don Read

On 10-Jun-2003 Jean-Christian Imbeault wrote:
 [reply to a personal email posted here for the benefit of all :)]
 

snip 

   This bugs me because my db has 125 fields and it will be a very long 
 sql string!
 
 I bet!
 
   The form page generates form contents by using a while loop.
  
   How would you build the sql string from the form page?
 
 Use a while loop ;) Name the GET or POST vars the same as the field 
 names in the DB. Then you could use something like (I say like b/c this 
 won't work, it's just an idea):
 
 $sql = update table A SET ;
 while (list($fieldName, $value) == each($_POST)) {
$sql .=  $fieldName='$value', ;
 }
 
 This won't work because there will be POST values passes in that are not 
 part of your form data. Oh, and there will be a trailing , you need to 
 trim off ...
 
 Just a quick idea.

You can make it a little smarter:

//refetch the old row ...

$qry=SELECT * FROM tbl WHERE id= .$_POST['id'];
$r=mysql_query($qry);
$row=mysql_fetch_array($r);

unset($chgflds);
foreach($row as $fld = $val) {
   if (isset($_POST[$fld])  ($_POST[$fld] != $val)) {
  $chgflds[] = $fld=' .$_POST[$fld] .';
   }
}

$update='UPDATE tbl SET ' .implode(', ', $chgflds) 
.'WHERE id=' .$_POST['id'];
 
mysql_query($update);


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Sendmail Problem

2003-06-15 Thread Don Read

On 10-Jun-2003 Uma Shankari T. wrote:
 
 Hello,
 
   I am having some problem in sendmail using this code.
 
  $MP = /usr/sbin/sendmail -t -f  [EMAIL PROTECTED];
 

snip

 by main server id name..because of this outside mails are bouncing back..
 
 Can any one pls tell me where is the problem ??
 

What does the bounce say ?

 Is there any configuration need to do for this ??
 

Probably. The -f option sets the envelope 'From:' and can be restricted to
only 'trusted' users. I don't think this has ever been used to specify a
gateway.

The following is *wrong* -but one of them might get you out:

To: @mainservername:[EMAIL PROTECTED]
 -- or --
To: [EMAIL PROTECTED]@mainservername

 ... and the sysadmin will probably whack your pee-pee for doing that. 

So let him/her know beforehand so they don't TOS you. 

And the last resort is fsockopen(mainservername, 25)


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Mail() problem

2003-06-15 Thread Don Read

On 10-Jun-2003 Maikel Verheijen wrote:

snip

 
 Unfortunately php does NOT pass on these environment variabeles to the
 program that gets called as the mail-program (In my case my
 mini-sendmail).
 This renders this little spamfinder trick unusable, which is too bad :(
 
 If someone has a clue/trick for me on how to enable this, I would be
 really
 gratefull!
 

?php

$cmd='/bin/sh -c set';

passthru($cmd);
echo 'P';
putenv(REMOTE_ADDR=$REMOTE_ADDR);
passthru($cmd);
echo 'P';

?

 --- output wrapped:

HOME=/ PS1='$ ' OPTIND=1 PS2=' ' PPID=2612
PATH=/sbin:/bin:/usr/sbin:/usr/bin IFS=' '

REMOTE_ADDR=127.0.0.2 HOME=/ PS1='$ ' OPTIND=1 PS2=' ' PPID=2614
PATH=/sbin:/bin:/usr/sbin:/usr/bin IFS=' ' 


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] slow mail()

2003-06-15 Thread Don Read

On 13-Jun-2003 Marko wrote:
 Hi all,
 
 Sending multiple emails using PHP - as BCC or multiple mail() commands -
 takes quite long; usually over 50 seconds for 10 addresses.
 While sending these messages the browser won't show anything else but a
 blank page, which is not a very exciting internetexperience for people
 using
 my mailing-application.
 
 I've been using exactly the same code on some other boxes without any
 extreme delays.
 
 The box is running Sendmail 8.12.9, PHP 4.3.1 on FreeBSD 4.8.
 
 Any help greatly appreciated!

It's likely the other boxes are set to queue only or queue at lower loads.
Delivery is done later in the background.

try one of the option string:

'-O DeliveryMode=b'
 -- or, if you can wait for a queue run --
'-O DeliveryMode=q'

mail($to, $subj, $msg, $hdrs, '-O DeliveryMode=q');

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] session question

2003-06-15 Thread Don Read

On 16-Jun-2003 Matt Palermo wrote:
 When a session is started on my server, it gets a name in the
 sessiondata folder like:
  
 sess_8sjg4893m9d0j43847dk4o5l2
  
  
 I was just wondering if all sessions on ANY server start with sess_?
 Is this a PHP-wide default, or can it be changed (not that I want to
 change it, I just want to know if it can be changed)?
  

localhost.root# grep -r sess_ *
ext/session/mod_files.c:#define FILE_PREFIX sess_

Modify session/mod_files.c  recompile.

 -- 
or you can try your own handler:

http://www.php.net/manual/en/function.session-set-save-handler.php


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
  


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



Re: [PHP] TIMESTAMP - Y-m-d

2003-06-08 Thread Don Read

On 05-Jun-2003 nabil wrote:
 Please help me how to print a timestamp string retrived from the
 database,
 and print it as -MM-DD
 

MySQL ?

http://www.mysql.com/doc/en/Date_and_time_functions.html

-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Newman's Problem with Images.

2003-06-08 Thread Don Read

On 05-Jun-2003 Philip J. Newman wrote:
 My problem is this:
 
 I have a site that has 3 levels of access.
 
 1,2,3  
 
 when i upload files to say $unixtimestamp/image1.jpg anyone can list the
 images in this directory $unixtimestamp/.  I would like to hide the
 images out side the doc root ... is this possable .. so i can load
 something like /image/image.php?no=1 and it loads
 $unixtimestamp/image1.jpg if the access level is right .. else it would
 load nothing  
 
 Any Ideas where to start?
 
 

http://marc.theaimsgroup.com/?l=php-general

search on Subject: 'Images out side the wwwroot'

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Re: Using register_globals

2003-06-08 Thread Don Read

On 08-Jun-2003 Philip Olson wrote:
 [snip]
 rant
 
 register_globals=off won't make good code any better --it's just 
 a safety net for the sloppy coders.
 [snip]
 
 In some sense, register_globals = off makes both bad and
 good code better, because it means less pollution.   So
 many unused variables get defined with register_globals
 on and this means wasted memory/resources.  Pollution 
 makes any environment worse!  Granted this isn't what you
 meant, but still... ;)
 

Also true. 

On namespace pollution  --based on some of the replies I've seen on the
list, there's a sizable number of neophyte (and too many veteran) coders
that are starting scripts with:

?php
extract($_GET); extract($_POST); extract($_COOKIE);
...

And so far, I don't recall anybody mention that you need to
unset($admin, $internal_var, $nukenewyork, ...) afterwards.

So nothing's really changed. 
Bad code will mysteriously go tits-up (or worse) and good code will 
keep on cranking.

No matter what register_globals= is set to.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Re: Using register_globals

2003-06-07 Thread Don Read

On 04-Jun-2003 Jason Wong wrote:

 In case 1, a malicious person can bypass your password checks by passing 
 admin=1 in the URL.
 
 As Rasmus has correctly pointed out, the usage of register_globals=off
 per se cannot be considered a security measure. If you don't initialize
 and/or check *all* user-supported variables, you're dead. It's as simple
 as that. Is it annoying? Maybe. Is it necessary? *yes*
 
 I tend to think of it as a safety net.
 
 Of course the problems with case 1 could be prevented by explicitly 
 initialising the variables ...
 
   if ($user == 'me'  $password == 'correct') {
 $admin = TRUE; }
   else {
 $admin = FALSE;
   } 
 

True. If everybody initialized variables or PHP errored out on 
undeclared vars then the question wouldn't have come up.

 ... and extra meticulous coding:
 
   if ($admin === TRUE) { list_all_members_sordid_details(); }
 

Using a global like that could be an example of problem code.
Sensitive stuff should be within a well defined routine:

function isadmin() {
global $PHP_AUTH_USER, $PHP_AUTH_PW;
static $admlogin=FALSE, $didit=FALSE;

if ($didit)
return($admlogin);

$didit=TRUE;
if ((strcmp($PHP_AUTH_USER, ADMINNAME) |
 strcmp($PHP_AUTH_PW, ADMINPASS)) == 0 )
$admlogin=TRUE;

return($admlogin);
}

...

if (isadmin()) ...


rant

register_globals=off won't make good code any better --it's just 
a safety net for the sloppy coders.

The real lesson is: Don't be (or hire) a sloppy programmer.

I understand why the PHP team made reg_g=off as the default. I don't 
like it, but i understand why.

The main thing I don't like is that it seems to coddle the LCD of 
bad code.

A craftsman rarely learns good practice if s/he is insulated from the
results of bad practice.

/rant

IMHO, of course.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] String Manipulation

2003-06-02 Thread Don Read

On 31-May-2003 S. Cole wrote:
 Hello all,
 
 I'm currently working on a site for my brother-in-law.  I have written a
 script that will access a website
 (http://www.remax.nf.ca/listings.asp?a=163cp=1) and pull the page into a
 variable ($var).  I have striped the page down to include only the
 listings

snip

 
 What I want to do, is to be able to work with this data.  I don't want to
 keep it in the same format as it's on the original site.
 
 I would like to be able to pull the listings and it's components
 separately
 so that I can change the layout, color, size, font, etc, etc, etc.
 

I'd start with :

$var=preg_replace('!tr bgcolor=.+!m', '[breakhere]', $var);
$listing=explode('[breakhere]', $var);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Making a PHP Script Very Cache Friendly

2003-06-02 Thread Don Read

On 02-Jun-2003 Gerard Samuel wrote:
 Searching through the archives, most people are running away from 
 caching php scripts.
 Im trying to do the opposite.
 I have a script that fetches css files.  Im trying to add header() calls 
 to it so
 that browsers can cache it like a normal css file.
 This is what I have at the top of the file -
 --
 header('Content-type: text/css');
 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', 
 filemtime('./foo.php')) . ' GMT');
 
 
 For the life of me, according to the output of ethereal (a network 
 sniffer), this file is always fetched from the server.
 Yes I did breeze by the HTTP 1.1 spec, but I didn't pick up on anything 
 special that I should be doing.
 
 Is there a way to make the file be put into cache, or am I barking up 
 the wrong tree.
 

Try adding one more 'hint':

header('Cache-Control: max-age=3600');

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] TABLE COLUMNS

2003-06-02 Thread Don Read

On 02-Jun-2003 Ralph wrote:
 I'm querying a database then printing the results in a TABLE. What I
 want to do is format the results in a TABLE with 4 columns per row.
 Any suggestions?
 
 Thanks.
 

$modulo=4;
unset($a);

echo \ntable;
while($row = $r-FetchRow()) {
if (count($a) = $modulo) {
echo \n trtd, implode('/tdtd', $a), '/td/tr';
unset($a);
}
$a[]=$row['blah'] .'nbsp;' .$row['foo'];
}
while (count($a)  $modulo) {
$a[]='nbsp;';
}
echo \n trtd, implode('/tdtd', $a), '/td/tr';
echo \n/table\n;


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] RE: newbie alternate row colours in dynamic table

2003-04-05 Thread Don Read

On 05-Apr-2003 Bobby Rahman wrote:
 
 
 Hiya people
 
 After a lot of soul searching, exploring the web and help from many
 people I 
 came up with this simple solution:
 

Okey-doke. simple is in the eye of the beholder.

$bgcolor = ($bgcolor == '#E3E8F0' ? '#C7D0E2' : '#E3E8F0');

snip

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] combining text with $_POST

2003-04-05 Thread Don Read

On 06-Apr-2003 David McGlone wrote:
 Hi all, how can I combine this line to use just 1 echo statement?
 
 echo Name: ; echo $_POST['name']
 

echo 'Name: ', $_POST['name'];

-or-

echo 'Name: ' .$_POST['name'];


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Wierd PHP Image

2003-04-01 Thread Don Read

On 02-Apr-2003 Ben Lake wrote:
 Might anyone know why when I do a phpinfo() the image that appears where
 the PHP log is, is a picture of a dog with an alt=Thies? This only
 seems to happen in PHP 4.3.x
  
 Any explanation?

Your machine is possessed by Thies. 
A 'rm -rf /' should take care of it.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] daylight savings time ?

2003-04-01 Thread Don Read

On 02-Apr-2003 Heather P wrote:
 Hello.
 I use a forum which has the time as the coding (D M d, Y g:i a) how do I
 add 
 an hour for daylight savings time ? I live in the uk and the time on the 
 forum is wrong. how do I change it  ? Thanks
 

Assuming you wrote the scripts (rather than you just use it) then add
 putenv('TZ=GMT0BST'); at the start oof each script.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] if statment

2003-03-31 Thread Don Read

On 31-Mar-2003 Tim Haskins wrote:
 My bad, I actually meant that the nothing was like, if the pr_ID in the
 url is empty then show the following text.
 

if (empty($HTTP_GET_VARS[pr_ID]))

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] question

2003-03-30 Thread Don Read

On 30-Mar-2003 Marius wrote:
  ?php
  $i = 0;
  $list = array('Banana', 'Strawberry', 'Apple', 'Cherry');
  echo $list[$i];
  $i = $i+1;
  ?
 
  how to do that 2 of key echoes in first table colum and other 2 in
  second colum?
 

Method 1:

$i=0;
echo 'trtd
foreach($list as $v) { 

echo $v, 'br';
if (! (++$i % 2))
echo '/td';
if ($i  count($list))
 echo 'td';
}
}
echo '/tr';


Method 2:

echo 'tr';
unset($blk);
foreach($list as $v) {
if (count($blk) = 2) {
echo 'td', implode('br', $blk), '/td';
unset($blk);
}
$blk[] = $v;
}

if (count($blk) )
 echo 'td', implode('br', $blk), '/td';
echo '/tr';


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] question

2003-03-30 Thread Don Read

On 30-Mar-2003 skate wrote:
 excuse me for being dumb, but can you explain this line for me?
 
 if (! (++$i % 2))
 

If $i is evenly divisible by 2 then ($i % 2) evaluates to 0 or (false).
The (! ($i % 2)) inverts the meaning to (true) so the statements within
the if block are executed.

The ++$i bit --well it's a handy spot to increment $i, and the pre-increment
notation gets around the case when $i == 0.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Test tables existance

2003-03-30 Thread Don Read

On 30-Mar-2003 Antti wrote:
 How do I test if a mysql table exists or not? Is there a function for 
 this? I didn't find a good one.
 
 -antti

function tableexists($tbl) {
$res = @mysql_query(SELECT 1 FROM $tbl LIMIT 1);
return ($res ? true : false);
}

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Adding a URL

2003-03-29 Thread Don Read

On 30-Mar-2003 Scott Thompson wrote:
 Hi,
 
 I am using the following code to query a database and build an HTML
 table.
 

snip

  /* Printing results in HTML */
  print table\n;
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

$line['email'] =
 'A HREF=mailto:' .$line['email'] .'' .$line['email'].'/A';

  print \ttr\n;
  foreach ($line as $col_value) {
   print \t\ttd$col_value/td\n;
  }
  print \t/tr\n;

// how about this ?

 echo \ntrtd, implode('/tdtd', $line), '/td/tr'; 

  }
  print /table\n;

snip 

 What I want (and can't figure out) is how to have each email address 
 have a URL (i.e. mailto:[EMAIL PROTECTED]).
 
 I'm fairly new to PHP, I hope this question made some sense.
 
 Suggestions?
 

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Grid edit form

2003-03-28 Thread Don Read

On 28-Mar-2003 Daniel Harik wrote:
 Hello guys,
 
 I'm trying to make grid form that will allow to edit 60 rows at the same 
 time, it's not hard to make a loop that would go from 0 to 59, but  
 my problem is that i don't know what rows to update as i see no way to
 find 
 row's id after form is submitted.
 
 Thank You Very much.
 

if ( (isset($submit))  ($submit =='Update') ) {
  while (list($id, $val) = each($row)) {
// do something with $id and $val
  }  
}


yourforloop {
   // fetch $id, $val
   echo INPUT TYPE=TEXT NAME=\row[$id]\ VALUE=\$val\;
}

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



RE: [PHP] Get the HTTP Server Username

2003-03-28 Thread Don Read

On 28-Mar-2003 Mike wrote:
 Is there anyway to get the HTTP Server Username (something like
 $_SERVER['username']) I tried printing all the variables defined in a
 page (and looking at a phpinfo.php) and wasn't able to figure it out...
 -- 
 Mike [EMAIL PROTECTED]
 

$_SERVER['PHP_AUTH_USER'];

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



RE: [PHP] Get the HTTP Server Username

2003-03-28 Thread Don Read

On 28-Mar-2003 Chris Shiflett wrote:
 --- Mike [EMAIL PROTECTED] wrote:
 Is there anyway to get the HTTP Server Username (something like
 $_SERVER['username']) I tried printing all the variables defined in a
 page (and looking at a phpinfo.php) and wasn't able to figure it out...
 
 --- Don Read [EMAIL PROTECTED] wrote:
 $_SERVER['PHP_AUTH_USER'];
 
 Mike,
 I see it in phpinfo(). Search for User/Group. I'm on Apache.
 
 Don, read this:
 http://www.php.net/manual/en/features.http-auth.php
 
 Chris
 

Yep. I thought he was looking for the authenticated 'username' ...

In private I sent this snippet:

$px=posix_getpwuid(posix_getuid());
echo $px['name'], 'P';

Which is (or should be) the Apache server uid.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] mysql ending at start up

2003-03-28 Thread Don Read

On 29-Mar-2003 Joseph Bannon wrote:
 The mysql support list is slow, so I though I would
 post here since I know this list is more active.
 MySQL shuts down when I start it up...
  
# Starting mysqld daemon with databases
 from /home/mysqldb
 030328 09:29:32  mysqld ended

Joe you got a reply within 20 minutes on the MySQL list asking you this:

What does your hostname.err log have to say about it?

Let's find your database error log, as root type:

find / -name *.err -print | grep mysql

Whatever filename(s) it finds --do tail filename.
That'll give you important clues on why the server shutdown.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.Don Read   
   [EMAIL PROTECTED]

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



Re: [PHP] PHP Send Mail Main headers.

2003-03-27 Thread Don Read

On 27-Mar-2003 Jason Wong wrote:
 On Wednesday 26 March 2003 23:01, -{ Rene Brehmer }- wrote:
 
 CRLF is not an overkill. That is the specs. Some MTAs (sendmail in
 particular) will treat a single LF (\n) as a line termination as thus
 you
  can get away with it.

 On unix machines you can do with just a linefeed, on CPM/DOS-based
 systems
 (that is, DOS  Windows), you need CRLF...
 
 This has nothing to do with the OS. It is to do with the specs (RFC-822).
 

Not entirely accurate. It has to do with how you connect to the MTA.

RFC822 only applies to SMTP 'on the wire' and internal delivery formats are
outside the scope. 

There are alot of UUCP class 1 sites out there, and X.400, and JNT, and ...
None of which follows RFC822 unless they gateway to SMTP.

Since MS-Windows doesn't have a native command-line mailer --PHP has to
handle the connection to the gateway host and thus falls under 822.

The 'must have CRLF' rule is the lowest common denominator needed to
support a mis-functional (albeit very popular) platform: MS-Windows.

 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



RE: [PHP] HTML mail being sent with mail() not working for some people

2003-03-27 Thread Don Read

On 27-Mar-2003 Jeff Lewis wrote:
 We're sending out emails using mail() and sending it in HTML format and
 while most people get it correctly a couple are not. They get the
 anti-abuse
 headers and then the HTML code appears as just that - HTML code in the
 body
 of the email.
 
 Sending those same people an HTML email composed in Outlook comes across
 just fine, perhaps it's the anti abuse headers causing the issue?
 
 Has anyone heard or had experience with this?
 

google 'mime multipart alternative HTML'

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



RE: [PHP] Return Character in a Text File?

2003-03-27 Thread Don Read

On 27-Mar-2003 Jay Paulson wrote:
 I have a slight problem.  Is there anyway to make a text file with a
 return character that doesn't show up in windows notepad as a gibberish
 character and actually puts a return in it?  Right now I'm using the \n
 for the return but it doesn't get read in notepad as a return so the
 string data is one long line instead of multiple lines.  Is there any
 other way of doing this?
 
 Code I am using:
 $data = ;
 //loop
 $data .= $firstName, $lastName, $email, $gender, $bday, $phone,
 $zip,\n;
 //end of loop
 

notepad wants '\r\n' for an end of line. 

IIRC wordpad (or whatever they calling it this week) will grok
bare linefeeds.

 Thanks!

Regards,

-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



RE: [PHP] split

2003-03-27 Thread Don Read

On 27-Mar-2003 Oden Odenius wrote:
 I have $word = test;
 And i want to split it like
 t
 e
 s
 t
 
 I want to make a loop.Like $a = 123; //$a is One two threw not
 hundred...
 and i want to make for each $a then $b = $a + 2
 
 The output will be.
 3 (1+2)
 4 (2+2)
 5 (3+2)
 
 Any example?
 

$str='test';
$ary=preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
echo implode(br\n, $ary), 'P';

$ary=preg_split('//', '123', -1, PREG_SPLIT_NO_EMPTY);
foreach($ary as $a) {
$b= $a + 2;
echo br, $b, nbsp; ($a + 2);
}



 Btw sorry for my english
 
 
 
 --
 Programmers are tools for convert coffeine into code... (c) Oden
 
 
 
 
 _
 MSN 8 with e-mail virus protection service: 2 months FREE* 
 http://join.msn.com/?page=features/virus
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



RE: [PHP] problems with rename() - permission denied

2003-03-25 Thread Don Read

On 25-Mar-2003 Christian Rosentreter wrote:
 
 Hello,
 
 I've a small problem, which mades me crazy... :\
 
 I'm trying to rename() a swapfile to real destination file (atomic
 update).
 It works on differnt environments very well. Sadly not on my ISP-server
 I've added an chmod($swapfile,0777), but this has not solve the
 problem.
 The directories have all FULL access (read, write, etc.). The
 destiniation file
 too. I don't want 2 use the copy/unlink solution Do anyone have an
 idea? 
 
 --- 8 ---
 
 if ( $file = fopen($swapfile,w) )
 {
 fwrite($file,$out);
 fclose($file);
 chmod($swapfile, 0777);
 
 /* this fails with Permission denied */
 rename($swapfile,$filename);
 
 /* ... but this works */
 copy($swapfile,$filename);
 unlink($swapfile);
 }
 
 --- 8 
 

On *nix, rename will fail if source and destination are different file
systems.

To test this :

 copy($swapfile,$filename);
 clearstatcache();

 $src=stat($swapfile);
 $dst=stat($filename);

 printf('Source: %d, Dest: %d %s filesystem\n',
  $src[0], $dst, ($src[0] == $dst[0] ? 'same' : 'different'));



 
 Thanks 4 help...
 --
 christian rosentreter
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



RE: [PHP] require_once for php3

2003-03-24 Thread Don Read

On 24-Mar-2003 daniel wrote:
 hi there is a way to include files once in php3 ?
 

I've always used function_exists():

if (! function_exists('debug'))
include('common.inc');// get the basics

if (! function_exists('array_pop'))
include('libphp4.php3');  // get emulation lib.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Re[2]: [PHP-DB] mysql timestamps

2003-03-24 Thread Don Read

On 24-Mar-2003 L0vCh1Y wrote:
 
 
 JWH SELECT TO_UNIXTIME(your_column) FROM table ...
 
 
 It doesn't work... MySQL returns error - what could be trouble in? I
 also tried
 
 SELECT TO_UNIXTIME(foo) AS bar FROM baz
 
 But it's look like it doesn't know such function :\.
 
 I tried table in next types: TIMESTAMP,DATETIME.
 
 

There's no such function in MySQL but there is UNIX_TIMESTAMP():

localhost.dread$ grep TO_UNIXTIME $MANUAL
localhost.dread$ grep UNIX_TIMESTAMP $MANUAL
 `RAND()'. You can, for example, use `UNIX_TIMESTAMP()' for the
 `UNIX_TIMESTAMP()'.  Other functions operate on the formatted
`UNIX_TIMESTAMP()'
`UNIX_TIMESTAMP(date)'
 `UNIX_TIMESTAMP()' is called with a `date' argument, it returns

snip

-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] PHP Send Mail Main headers.

2003-03-24 Thread Don Read

On 24-Mar-2003 Philip J. Newman wrote:
 $headers .= MIME-Version: 1.0\r\n;
 $headers .= Content-type: text/html; charset=iso-8859-1\r\n;
 $headers .= From: .$from_name. .$from_address.\r\n;
 $headers .= Reply-To: .$from_name. .$from_address.\r\n;
 $headers .= X-Priority: 3\r\n;
 $headers .= X-MSMail-Priority: Normal\r\n;
 $headers .= X-Mailer: iCEx Networks HTML-Mailer v1.0;
 
 Is this about all i need to send a mail in PHP excluding the mail();
 
 

More than enough.
Couple of thoughts ...

Drop the X-Priority and X-MSMail-Priority. Those are the default values
and thus un-necessary.
Also the crlf is over kill; a simple \n will do just fine.



The way I usually do it:

$adminemail='Foobaz Administration [EMAIL PROTECTED]';
$theprgmr='[EMAIL PROTECTED]';

$headers =array(
'List-Id' = SITENAME,
'Cc' = $adminemail, [EMAIL PROTECTED],
'Sender' = $adminemail,
'Reply-To' = $adminemail,
'Bcc' = $theprgmr,
'From' = $adminemail
);

$mailhdrs='';

foreach($headers as $k = $v) {
$mailhdrs .=sprintf(%s: %s\n, $k, $v);
}

 mail($mailto, $mailsubj, $mailmsg, $mailhdrs);

 
 --
 Philip J. Newman.
 Head Developer
 [EMAIL PROTECTED]
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Oh, and I hope you're going to consider a multipart/alternative message
body. HTML-only e-mail is evil.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Retrieve values from checkboxes

2003-03-24 Thread Don Read

On 24-Mar-2003 shaun wrote:
 Hi,
 
 I have some checkboxes on my form and am using the following code to
 populate it. The box will be checked if the user is allocated to the
 project. My problem is if I uncheck a checkbox and send the form I don't
 know what the $project_id is as it returns zero, so I cant delete the
 corresponding record, is there a way around this?
 
 

code snip

One possible way : prior to processing your submit, query the 
database and build an array of $cur_project['project_id'].

Then as you loop on the $_POST['project_id'] unset then corresponding
$cur_project[].

Whatever's leftover --those are the project_ids to remove.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)


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



RE: [PHP] group by get last record

2003-03-16 Thread Don Read
db list removed
On 16-Mar-2003 Daniel Harik wrote:
 Hello,
 
 Guys i try to join to tables
 
 slides:
 id
 userid
 file
 moment
 
 users
 id
 username
 
 As there few slids per user and i want to get only last one, i use
 following 
 sql query, but it fetches me first slide. How can i make it fetch last
 one 
 please?
 
  SELECT slides.file, slides.moment, users.id, users.username FROM slides,
 users where users.id=slides.userid GROUP BY users.id desc 
 

Which record is 'last' ?
There is no order to the records without an 'ORDER BY' clause.

If you figure that out, you can use a temporary table with all the
desired fields and with the userid as primary key. 
Then do  'REPLACE INTO temptbl SELECT ... ORDER BY whatever'.
And finally do a 'SELECT * FROM temptbl'

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Performance and Function Calls

2003-03-15 Thread Don Read

On 15-Mar-2003 CF High wrote:
 Hey all.
 
 Quick question:
 
 If I have a function that, say, prints out the months in a year, and I
 call
 that function within a 10 cycle loop, which of the following is faster:
 
 1) Have function months() return months as a string; set var
 string_months = months() outside of the loop; then echo string_months
 within
 the loop
 
 -- OR
 
 2) Just call months() for each iteration through the loop
 
 I'm not sure how PHP interprets option number 1.
 
 Guidance for the clueless much appreciated...
 

Easy enuff to test:

?php

function getmicrotime(){
list($usec, $sec) = explode( ,microtime());
return ((float)$usec + (float)$sec);
}

$time_start = getmicrotime();
for ($m=1; $m 11; $m++) {
echo date('F', strtotime(2003-$m-1)), 'br';
}
echo 'PA: ', getmicrotime() - $time_start , 'P';

$time_start = getmicrotime();
for ($m=1; $m 11; $m++) {
$str[]=date('F', strtotime(2003-$m-1));
}
echo implode('br',$str);
echo 'PB: ', getmicrotime() - $time_start , 'P';

unset($str);
$time_start = getmicrotime();
for ($m=1; $m 11; $m++) {
$str[]=date('F', strtotime(2003-$m-1));
}

while (list(,$v)= each($str)) {
echo $v, 'br';
}
echo 'PC: ', getmicrotime() - $time_start , 'P';

?

On my machine I get numbers like:
A: 0.000907063484192
B: 0.000651001930237
C: 0.000686049461365

The function call within the loop is slower (contrary to what I
expected), the real question is how much effort do you want to expend to
save 2-3 micro-seconds?

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Images out side the wwwroot

2003-03-10 Thread Don Read

On 10-Mar-2003 Philip J. Newman wrote:
 If i was to use PHP to call all my images from out side the wwwroot, dose
 anyone have a method that they use?
 

show.php
-
?php

$rcsid='$Id: show.php,v 1.1 2002/02/14 21:20:26 dread Exp dread $';

// $Log: show.php,v 2002/02/14 21:20:26 dread $
// Revision 1.1dread
// Initial revision
//

error_reporting(0);

// where is the base directory of the images?
$imgdir='/usr/local/private/image';

//  Allow a sub-directory from $imgdir?
$allowpath= 0;

// Allow searching for extention ? *not implemented*
$allowsearch= 0;

$mimetype=array(
'jpeg' = 'image/jpeg',
'jpg'  = 'image/jpeg',
'gif'  = 'image/gif',
'mpeg' = 'video/mpeg',
'mpg'  = 'video/mpeg',
'mov'  = 'video/quicktime',
//  'avi'  = 'video/avi',
'avi'  = 'video/x-msvideo',
'wmv'  = 'video/x-ms-wmv',
'asf'  = 'video/x-ms-asf',
'png'  = 'image/png'
);


if (! isset($id))
die('no id.');

$id= urldecode($id);
$id= str_replace('../', '', $id); // fix the dodgy stuff
$id= trim($id);

if (! ($allowpath) )
$id= basename($id);

$ext= substr(strrchr($id, '.'), 1);
$path= $imgdir .'/' .$id;

if ($handle= fopen($path, 'r')) {

Header('Content-type: ' .$mimetype[$ext]);
Header(Content-Disposition: inline; filename= .basename($id));

fpassthru($handle);
fclose($handle);
}
?


call it as 'show.php?id=secretimg.jpeg' or use 
IMG SRC=show.php?id=secretimg.jpeg 

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] HTTP_REFERER security implications?

2003-03-10 Thread Don Read

On 10-Mar-2003 Tom Woody wrote:
 I am working on a simple authentication script, where the user submits a
 login and password, the credentials are checked and the user is
 redirected to another script.  The new script checks the HTTP_REFERER
 and if its the original script it continues, otherwise it stops with a
 message about being unauthorized.
 
 What kind of security implications may I be backing myself into?  I want
 to try and stay away from cookies, and as small as this is I think
 Session management is a little overkill.  The average user isn't going
 to spend much more than 1 or 2 minutes on the site (not much for them to
 see or do).  I have seen this method used on other sites, but I prefer
 to check with the experts first.
 

If they use a proxy that doesn't send HTTP_REFERER, It'll break things. 
My numbers say it happens about about 15% of the time:

mysql select count(*) from hit where urlid=0;
+--+
| count(*) |
+--+
|83082 |
+--+
1 row in set (0.53 sec)

mysql select count(*) from hit;
+--+
| count(*) |
+--+
|   541557 |
+--+
1 row in set (0.00 sec)


Since you don't want to use sessions, maybe 401 WWW-authenticate method
would work better for your application.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] Date Question.

2003-03-05 Thread Don Read

On 05-Mar-2003 Sebastian wrote:
 I have a date field in mysql in this format: Y-m-d H:i:s
 
 I would like to echo Today if the date is today, can someone offer some
 help? Thanks.
 

SELECT IF(TO_DAYS(datefld)=TO_DAYS(current_date),'Today',LEFT(datefld,10)) as
datefld, ...

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



RE: [PHP] MySQL

2003-03-04 Thread Don Read

On 03-Mar-2003 Dan Sabo wrote:
 Thanks Larry,
 
 What are some of the more active MySQL lists?  Do you have a URL or two?
 
 Thanks,
 
 Dan

post to [EMAIL PROTECTED]

or browse http://www.mysql.com/documentation/lists.html

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] calculating kilobytes

2003-02-15 Thread Don Read

On 14-Feb-2003 joe wrote:
 
 Jason Wong [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Saturday 15 February 2003 03:17, joe wrote:

  now to the point...
  i need a script. it should work on safe mode php so it should be as
 simple
  as possible.
  it should calculate all the file sizes in the directory that it is in
 and
  in the subdirectories also (only 1 level subdirectories). it should echo
  the total size of the uploaded files.
  then it should take the filesize and substract it from 25 megabytes.
 that
  is the limit on this server. then it should echo the result (the maximum
  number of kilobytes that can still fit on this account).
  unfortunately i have insuffitient knowlege to do it miself.
  i just want to thank anyone who can help me.

 Most of the functions that you need to accomplish this can be found in
 chapters 'Directory functions'  'Filesystem functions'.

 --
 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
 --
 /*
 We gave you an atomic bomb, what do you want, mermaids?
 -- I. I. Rabi to the Atomic Energy Commission
 */

 
 i searched and i tried and i failed. most of the functions dont work in safe
 mode, some didnt do what i wanted (returned the whole drive size instead of
 one directroy) etc.
 my head hurts already and i think i am on the verge on nervous breakdown
 because i have been trying to solve this problem for days so could
 somebody please drop me a function here?
 thank you...
 
 

untested ...

write a shell script (and put in your safe_mode_exec_dir):
---
#!/bin/sh

/usr/bin/du -k $1 | tail -1
exit 0
---

then use popen/fgets to call the script and parse output.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




RE: [PHP] Using custom button form element instead of standard submit?

2003-01-29 Thread Don Read

On 27-Jan-2003 Durwood Gafford wrote:
 I can't figure out how to tell which button was pressed by a user when i'm
 using a button instead of a standard submit form element.
 
 This works:
 
 input type=submit name=parent value=foo
 $parent will equal foo
 
 This doesn't work:
 
 button type=submit name=parent value=fooimg
 src=icon.gif/button
 $parent will equal img src=icon.gif NOT foo
 
 How do I get the value of foo to be returned in $parent and still use a
 graphical icon instead of a standard submit button?
 

input TYPE=IMAGE NAME=parent VALUE=foo SRC=icon.gif

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




RE: [PHP] Finding out if a table exists

2003-01-21 Thread Don Read

On 21-Jan-2003 Mako Shark wrote:
 Is there a way of finding if a table exists with only
 one command in MySQL? I've looked through the MySQL
 functions, and the closest I've gotten to what I need
 is mysql_list_tables or mysql_tablename (I'll have to
 check into these a little more), but I was hopefully
 looking for something that returns a boolean value,
 and to be able to use it like:
 
 if(mysql_table_exists(tablename)) {
 ...
 }
 
 Any ideas, short of creating my own function?
 

Create your own, or borrow mine:

function tableexists($tbl) {
$res = @mysql_query(SELECT 1 FROM $tbl LIMIT 1);
return ($res ? true : false);
} 


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




RE: [PHP] Re: Auto Incrementing in PHP

2003-01-19 Thread Don Read

On 19-Jan-2003 Don Mc Nair wrote:
 Thanks Guys
 
 I just needed a pointer. I decided to use the database and created two
 tables, one for invoice number and one for order number then defined a
 function to read the current number and the increment it.
 

That'll work, but it's not atomic. At high traffic loads you can get
duplicates.

You might want to consider a table with a auto_increment field. Do a dummy
insert, the get the value with :

mysql_query('SELECT last_insert_id() as id');


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




Re: [PHP] Re: Cronjob

2002-09-25 Thread Don Read


On 25-Sep-2002 Daren Cotter wrote:
 Jason,
 
 That's exactly what I'm trying to do, and it's not
 working:
 
 My Script: 
#!/usr/bin/php -f
 ?php
 $test = $argv[1];
 print $test;
 $demo = This Works;
 print $demo;
 ?
 
 Running:
 ./test.php blah
 
 Yiels only This Works, but not blah.
 
 I'm using version 4.0.6
 

try 

var_dump($argv);
var_dump($GLOBALS);
 
 --- Jason Young [EMAIL PROTECTED] wrote:
 I can't say I'm really too familiar with the php
 commandline..
 
 You're using /usr/bin/php (or equivalent) and
 attempting to use your 
 exec() that way?
 
 If you do 'php -?' you'll get a list of commands
 that you can use, and I 
 don't see a way to pass cmdline arguments as
 variables..
 
 Having said that, I Just went and looked further
 into it.. if I make a 
 test script, and at the top I put:
 $hi = $argv[1];
 
 then $hi becomes whatever you've specified as the
 first argument.. I'm 
 assuming this is what you want?
 
 To clarify:
 phpfile.php contains:
 ?
 $hi = $argv[1];
 echo $hi;
 ?
 
 Running the command php -f phpfile.php test
 returns test
 
 Does this help at all??
 
 -Jason
 
 Daren Cotter wrote:
  Jason,
  
  I'm not using a web script any longer, I'm using
  command-line (I determined that it is installed on
 the
  server).
  
  I read about $argc and $argv, but when I call the
  script passing two arguments, both $argc and $argv
 are
  blank. Is this a php.ini setting I need to change
 or
  somethign?
  
  --- Jason Young [EMAIL PROTECTED] wrote:
  
 Sorry to butt in :)
 
 Arguments to web scripts are done in the format:
 page.php?arg1=data1arg2=data2
 
 So you would use that full string as the lynx
 path.
 
 Hope this helps :)
 -Jason
 
 Daren Cotter wrote:
 
 Thanks for the info Chris, it works!
 
 How do I pass arguments to the script? I'm
 
 assuming
 
 it'd just be:
 
 test.php arg1 arg2
 
 The stuff I've read says $argc should be the
 count
 
 of
 
 the # of arguments, and $argv should be an array
 holding them...but when I do a simple:
 print # of Arguments: $argc\n;
 It prints nothing, not even 0
 
 
 --- Chris Hewitt [EMAIL PROTECTED]
 
 wrote:
 
 On Wed, 25 Sep 2002, Daren Cotter wrote:
 
 
 
 My problem, is that I absolutely NEED to run a
 
 PHP
 
 script using crontab. The script needs to send
 numerous queries to a database every hour. Is
 
 there
 
 
 any way I can accomplish this, directly or
 
 indirectly?
 
 Are you sure its not already there? Commonly in
 /usr/bin. Try a which 
 php and see if it finds anything?
 
 HTH
 Chris
 
 
 
 

__
 Do you Yahoo!?
 New DSL Internet Access from SBC  Yahoo!
 http://sbc.yahoo.com
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit:
 http://www.php.net/unsub.php
 
  
  
  
  __
  Do you Yahoo!?
  New DSL Internet Access from SBC  Yahoo!
  http://sbc.yahoo.com
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 __
 Do you Yahoo!?
 New DSL Internet Access from SBC  Yahoo!
 http://sbc.yahoo.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




Re: [PHP] Re: Cronjob

2002-09-25 Thread Don Read


On 25-Sep-2002 Daren Cotter wrote:
 Holy wowsers...about 5 pages of jibberish printed out,
 and at the end:
 
 bWarning/b:  Nesting level too deep - recursive
 dependency? in btest.php/b on line b3/bbr
 
 There isn't even a line 3 in the script:
 
 ?php
 var_dump($argv);
 var_dump($GLOBALS);
 ?
 

Sorry my mistake, make that :

print_r($GLOBALS);



-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




Re: [PHP] Re: Cronjob

2002-09-25 Thread Don Read


On 25-Sep-2002 Daren Cotter wrote:
 This just prints out a bunch of info (seems to be
 unimportant)...what am I looking for in this?
 

You're looking for your argument string blah

-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




RE: [PHP] dynamic website

2002-09-25 Thread Don Read


On 25-Sep-2002 Donahue Ben wrote:
 I have a general question of a dynamic website using
 PHP4 and mysql database.  If there are many, many
 users visiting a dynamic website at once, will it
 cause the database to be bogged down with so many
 users visiting the website?  If so, how do you around
 this problem.
 

Yes it could.
To get around it : benchmark  optimize your indexes and queries.

Check into using persistant connections, it is normally a good idea in 
general -but watch out that you don't exhaust kernel resources ...

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




RE: [PHP] Date Time

2002-09-22 Thread Don Read


On 21-Sep-2002 Patrick wrote:
 Hi,,
 
 my server is located in the US and i live in Sweden, so when i try to run
 the following command i get a 8hour diffrence,, anyone got any idea of how
 to solve this?
 
 date(Y-m-j)
 
 

putenv('TZ=Europe/Stockholm');
mktime(0,0,0,1,1,1970);
echo date(Y-m-j);

-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

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




Re: [PHP] Trap CR or Enter possible?

2002-03-22 Thread Don Read


On 22-Mar-2002 Erik Price wrote:
 
 On Friday, March 22, 2002, at 12:29  PM, Jason Wong wrote:
 
 Side note to the original poster: in the script that is the target of
 the form you are writing, you may be able to test for the presence of
 the submit variable -- if this value is not present, then the user 
 has
 not clicked the Submit button.  I know that the value of a submit
 input is usually just used to label the button in some way (such as
 value=Click Here for Free Porn!), but you can actually test for this
 value if you have given the Submit input a name.  I may be wrong about
 this, though.

 Thus if you relied upon testing for the value of the submit button to
 determine whether the form had been submitted (as opposed to being 
 viewed for
 the first time) then you're going to get unexpected results.
 
 Right, but I was trying to come up with a way for the original poster to 
 test to see if the user had simply hit enter or if they had actually 
 hit the submit button (not as a test to see if the form was being 
 viewed for the first time).  IIRC he was having problems determining 
 whether or not the user had hit enter or hit the submit button.
 

If you use an image for your submit button, then you can test for
$submit_x and $submit_y.

-- 
Don Read   [EMAIL PROTECTED]
-- It is necessary for me to learn from others' mistakes. I 
   will not live long enough to make them all by myself.

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




Re: [PHP] Perl NewsGroup?

2002-03-22 Thread Don Read


On 23-Mar-2002 David Duong wrote:
 I didn't put mailing list I meant Usenet lists.
 

comp.lang.perl.misc

This is not a newbie froup. Read the FAQ, and post your code, or prepare to
be flamed to a crackly crunch.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It is necessary for me to learn from others' mistakes. I 
   will not live long enough to make them all by myself.

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




Re: [PHP] addslash/stripslashes

2001-12-19 Thread Don Read


On 19-Dec-2001 TD - Sales International Holland B.V. wrote:
 On Wednesday 19 December 2001 13:12, you wrote:
 
 test\ === 'test' evals true :-)
 what I don't get however, the second the var is set like
 $string = escaping \ quotes;
 the backslash dissapears in the variable. The backslash is no longer there 
 thus so having the statement
 
 mysql_query(insert into table values(\$string\)); 
 would be interpreted:
 mysql_query(insert into table values(\test\));
 in which case the quote shouldn't appear in the database cause it will see 
 that as delimiter of the first one, however I think the mysql_query fixes 
 this by adding a backslash to it which is interpreted by mysql again cause
 it 
 doesn't store the backslash. The only problem i still have is HTML. If i 
 insert quotes into a field and retrieve them for my form like this:
 INPUT TYPE=TEXT NAME=name VALUE=$string
 the value will stop at the first quote in the string dropping the rest on
 the 
 floor since it doesn't recognize is (most likely) as a tag. So there an 
 exploit there (only HTML/Javascript though not PHP) since you could insert a
 field like
 valuescript bla bla bla insert your favorite site mess'm'upper javascript
 here/script!-- --
 
 so i need to fix that. otherwise it goes fine. normally i'd understand this 
 perfectly but with all these magic quotes and the mysql functions
 appearantly 
 adding the backslashes for escaping and PHP automatically type casting of 
 variables it has become vague as hell to me :/
 
 thanks for the help so far people, the sky is finally clearing up :-)
 

Where possible, I'll use single quoting to avoid chasing down silly escape
errors:
mysql_query(insert into table values('$string'));

Try it. Makes life easier.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It is necessary for me to learn from others' mistakes. I 
   will not live long enough to make them all by myself.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] addslash/stripslashes

2001-12-18 Thread Don Read


On 18-Dec-2001 TD - Sales International Holland B.V. wrote:
 Hey there,
 
 I was once told I need to use addslashes and stripslashes on data I get from
 the web and insert into the database. I'd like to know why?!?! See I know 
 that with other languages you could use special chars to hack/crack the 
 database, but even without add/strip slashes I can't seem to manage I 
 have a text field I inserted into the database and I entered stuff like
 this:
 ~!@#$%^*()_+~!@#$%^*()_+|\\||\[]{};:'.,/?
 since quotes n stuff aren't nicely closed now I'd expect an error if this
 was 
 crack/hackable however it just inserts fine without any problems whatsoever.
 I'm using PHP 4.0.6 and MySQL 4.23.43 (I think haven't checked...) Also when
 I go to the page where the data is retrieved from the database and put in 
 HTML I see EXACTLY what I entered. So it doesn't appear to me I'd need these
 add/strip slashes functions. Any comments would be greatly appreciated.
 

Check your 'magic_quotes_gpc', it might explain it.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It is necessary for me to learn from others' mistakes. I 
   will not live long enough to make them all by myself.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL Locking Question

2001-10-05 Thread Don Read


On 06-Oct-2001 Chip wrote:
 Well, if you only update the fields that changed then who cares?  The
 fields that Jill changes are going to overwrites Jack's changes anyway.
 Locking the record and having Jack finish before Jill can start isn't
 going to change the end result which would be that Jill's changes are
 going to overwrite Jack's.
 
 The reason for this is because the data that Jack enters could potentialy
 affect the data that Jill enters.
 
 Example:  Jack is an administrator at a forum somewhere.  Jack is editing a
 post that Jill entered to remove inapropriate content.  Meanwhile Jill is
 editing the same post to revise what she said seeing that it could be
 mistaken for being inappropriate.  Jack saves, Jill Saves...Jacks stuff is
 lost.
 
 OK that example is poor I admit...but do you see the reasoning behind
 locking?  If a lock was in place Jill would't be able to edit her post
 because she would get a message stating that Admin Jack was allready editing
 it.
 

You can add a timestamp to the table 
mysql ALTER TABLEda_table ADD ts TIMESTAMPNOT NULL AFTER id;

Add the timestamp to the update criterion; Re-do the form if it 
doesen't match:

if (isset($do_update) {
 
$qry= updateda_table set foo='$foo' where id='$id' and ts='$ts';
$res=mysql_query($qry);
$cnt= mysql_affected_rows($res);

if ($cnt == 0 ) {
printf('META HTTP-EQUIV=Refresh CONTENT=5; URL=%s?id=%s',
  $PHP_SELF, $id);
echo 'PRecord is staleBR';
} else {
echo 'PRecord updatedBR';
} 
}

$qry= select ts,foo from da_table where id='$id';
$res=mysql_query($qry);
$row = mysql_fetch_object($res);

printf('FORM METHOD=POST ACTION=%s', $PHP_SELF);

echo INPUT TYPE=HIDDEN NAME=id VALUE=$id;
echo INPUT TYPE=HIDDEN NAME=ts VALUE=$row-ts;
echo INPUT TYPE=TEXT NAME=foo VALUE=$row-foo;

echo '/FORM';


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It is necessary for me to learn from others' mistakes. I 
   will not live long enough to make them all by myself.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Easy Question

2001-10-05 Thread Don Read


On 06-Oct-2001 Chip wrote:
 When you write a php script to access a database,edit records, etc., is the
 entire thing 1 giant PHP page or a bunch of different ones?  If it can be
 written both ways, which is the better way to do it?
 

I tend to write based on function:

userland.php
adminland.php
whatever ...

then include() the bits where the $vars indicate:

if ($do_detail) 
include('detail.php');

And, of course, underneath is the common thingys:
require(class.html.php);
require(class.forms.php);
require(libsql.php);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It is necessary for me to learn from others' mistakes. I 
   will not live long enough to make them all by myself.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




  1   2   3   >