RE: [PHP] php die function for MySQL connection errors

2004-08-16 Thread Ford, Mike [LSS]
On 14 August 2004 15:50, raditha dissanayake wrote:

 Ford, Mike [LSS] wrote:
 
  
  (And, BTW, the HTTP definition says that the Location:
 header should specify a full absolute URL, so that should be:
  
   header(Location:
 http://your.server.name/path/to/errors/servererror.php;);
  
  
 are you sure?

Yes.  In fact, I was too conservative -- the HTTP RFC says it *must*.  See:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30

and

http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2

Just because many browsers accept and process a non-standard header is no
reason to write non-standard headers... ;)

Cheers!

Mike

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

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



RE: [PHP] String compare of 7 text strings

2004-08-14 Thread Ford, Mike [LSS]
-Original Message-
From: Brent Clements
To: [EMAIL PROTECTED]

I wanted to see if anyone has an easier way to do this. The end result
is this: I need to compare 7 different text strings(which are in an
array). They should all be the same, if they are not the same, a message
should be outputted saying they weren't.

How would one do this outside of using a huge if/then statement?

---

Two approaches come to mind off the top of my head:

  $values = array_count_values($array);

  if (count($values)1):
// there's more than one unique value in the array
  endif;

or...

  $value = $array[0];
  for ($i=1; $i7; ++$i):
if ($array[$i]!= $value):
  // this value doesn't match
  break;
endif;
  endfor;

Cheers!

Mike

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



RE: [PHP] php die function for MySQL connection errors

2004-08-14 Thread Ford, Mike [LSS]
 -Original Message-
 From: John Gostick
 Sent: 14/08/04 15:19

 I have a quick question about using the PHP die() function. 

[...]

 I changed the code to this:
 
   $connection = mysql_connect($host, $user, $password)
or die(Error connecting to SQL server);
   $db = mysql_select_db($database, $connection)
or header('Location: ../errors/databaseselect.php');
 
 Which works fine (tested by deliberately misnaming database so it can't
find it).
 
 However if I then use the same approach for the server connection error,
 like below, it doesn't work.
 
 
   $connection = mysql_connect($host, $user, $password)
or header('Location: ../errors/servererror.php');

On failure, this causes the header to be sent, but doesn't actually stop execution of 
your script, so...

   $db = mysql_select_db($database, $connection)

this will now fail because you don't have a valid $connection.

or header('Location: ../errors/databaseselect.php');

The bottom line is, whenever you issue a header(Location: ) call, you also need 
to cause the script to die if your logic demands that -- so the above should be 
written something like:

  if (!$connection = mysql_connect($host, $user, $password)):
header('Location: ../errors/servererror.php');
die();
  endif;

  if (!$db = mysql_select_db($database, $connection)):
header('Location: ../errors/databaseselect.php');
die();
  endif;

(And, BTW, the HTTP definition says that the Location: header should specify a full 
absolute URL, so that should be:

  header(Location: http://your.server.name/path/to/errors/servererror.php;);

etc.)

Cheers!

Mike

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



RE: [PHP] If Else Syntax Incorrect (I Think)

2004-08-13 Thread Ford, Mike [LSS]
On 13 August 2004 12:52, Jay Blanchard wrote:

 if( strlen( $UserID ) != 0
  strlen( $UserPassword ) != 0
  strlen( $SecretPassword ) != 0
  strlen( $UserMail ) != 0 )
 {
 Do something
 }
 elseif ( strlen( $UserID ) == 0
   strlen( $UserPassword ) == 0
   strlen( $SecretPassword ) == 0
   strlen( $UserMail ) == 0 )
 {
 Do Something else
 }

In fact since the elseif condition is the exact logical complement of the if condition 
(by application of deMorgan's rules), you only need:

  if( strlen( $UserID ) != 0
  strlen( $UserPassword ) != 0
  strlen( $SecretPassword ) != 0
  strlen( $UserMail ) != 0 )
  {
Do something
  }
  else
  {
Do Something else
  }

Cheers!

Mike

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

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



RE: [PHP] timestamp according to timezone?

2004-08-12 Thread Ford, Mike [LSS]
On 12 August 2004 14:07, Justin French wrote:

 Hi,
 
 How can I get a unix timestamp of the current timezone, rather than
 GMT as supplied by time()?

Sorry, but this question makes no sense to me. A timestamp is absolute and
is always in GMT, taking no account of timezones -- that's just the way it's
defined.  If you want a time in the current timezone, you have to feed the
(absolute, GMT) timestamp through something that knows how to adjust for
timezones, such as date().

Cheers!

Mike

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

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



RE: [PHP] sessions not working when page redirects

2004-08-10 Thread Ford, Mike [LSS]
On 10 August 2004 13:19, Ron Stiemer wrote:

  Hi there,
 
 Try to add the session_id(); into the redirection:
 
 header(Location: ../admin/include/B.php?PHPSESSID= . session_id() );

No, no, no!  Use the SID constant -- that's what it's for.  It only has a value if you 
need one, so:

  header(Location: ../admin/include/B.php?.SID);

will redirect to include ../admin/include/B.php?PHPSESSID=whatever or 
../admin/include/B.php? as appropriate to the particular circumstances of the current 
invocation of the script.

Cheers!

Mike

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

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



RE: [PHP] Re: Image and variable

2004-08-10 Thread Ford, Mike [LSS]
On 10 August 2004 15:55, Henri Marc wrote:

 Hello,
 
  Variables in single-quoted strings are not
  evaluated. Either user double
  quotes or concatination:
 Thank you very much all for your help, specially Kevin
 Waterson for his complete program.
 It was simple, I always make some mistakes with those
 quotes :-(
 
 Another problem still related to those images.
 
 I have done that just as a test. Its' very simple but
 I really don't know why, the result is always the same picture.
 
 ?php
 $random=MT_RAND(1,2);
 echo $randombr;
 if ($random=1) {

You mean == (comparison) not = (assignment).

Cheers!

Mike

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

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



RE: [PHP] Problems with array_reverse!

2004-08-10 Thread Ford, Mike [LSS]
On 10 August 2004 15:36, Labunski wrote:

 Hello,
 First of all, I should apologize for my bad English,
 and I hope somebody will understand what I was trying to say..
 
 
 ?php
 if ($handle = opendir('news')) {
while (false !== ($topic = readdir($handle))) {
if ($topic != .  $topic != ..) {
 
$topic_b = array($topic); // the problem starts here.   
rsort($topic_b); //array_reverse($topic_b);
 
foreach($topic_b as $topic_c){
$date = $topic_c;
}
print($date);
 
 }
 }
closedir($handle);
 }
  
 
 This way, this will print:
 2004.08.11
 2004.08.31
 2004.11.07
 
 But I want to reverse this array, so that it would print: 2004.11.07
 2004.08.31
 2004.08.11
 
 BTW, I thought that $topic is an array

Why? You've done nothing to make it an array -- the only thing you ever assign to it 
is a single (string) filename.

Try this (untested!):

?php
  if ($handle = opendir('news')) {
while (false !== ($topic = readdir($handle))) {
  if ($topic != .  $topic != ..) {
$topic_a[] = $topic;
  }
}
if (rsort($topic_a, SORT_STRING) {
  foreach($topic_a as $topic_c){
print($topic_c);
  }
}
closedir($handle);
  }
?
 
Cheers!

Mike

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

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



RE: [PHP] Flush()....go to bottom of page (might be 0T)

2004-08-09 Thread Ford, Mike [LSS]
On 07 August 2004 23:24, PHP Gen wrote:

 This is what i am using:
 
 for($i=0; $i1000;$i++)
 {
 echo somethingbr;
 echo str_repeat( , 256);   flush();   ob_flush();
 sleep(1);
 }

Regardless of solving your scrolling problem, these flush calls are the
wrong way round -- ob_flush() flushes to the layer which is flushed by
flush(), so you should be doing

ob_flush(); flush();

to get an immediate flush of the thing just echoed.

Cheers!

Mike

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

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



RE: [PHP] Local version works - production breaks

2004-08-09 Thread Ford, Mike [LSS]
On 08 August 2004 14:20, Josh Acecool M wrote:

 Try adding
 if (!function_exists(function_name)) {
 function function_name ($blah) {
 // Function Code
 }
 }
 for each function.

As I understand it, that will *not* work in PHP 5 as it still parses the entire file, 
barfing on the duplicate function definition, before even attempting to evaluate the 
if() at the top of the file.

Cheers!

Mike

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

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



RE: [PHP] annoying autoreplies

2004-08-09 Thread Ford, Mike [LSS]
On 08 August 2004 03:25, Robby Russell wrote:

 To all those who have auto-replys set for their email, please
 turn them
 off. ;-)

If you're referring to SpamCease, it seems that these are, on the whole, not
genuine auto-replies but are themselves from a spam email address harvester
masquerading as a spam-blocker and using faked From: addresses.  Ignore them
or set up a rule to junk them.

(Although there does seem to be a genuine SpamCease challenge-response
spam-blocker, all of the emails I've seen here are clearly fakes and not the
genuine thing.)

Cheers!

Mike

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

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



RE: [PHP] RE: IMPORTANT: Please Verify Your Message

2004-08-06 Thread Ford, Mike [LSS]
On 06 August 2004 15:44, Ed Lazor wrote:

 Spamcease.  Apparently it's the guy's anti-spam software that
 automatically sends messages.

General consensus seems to be that it's not a guy, it's a spambot
pretending to be an auto-responder and using a fake from address.  If you
click the link, you merely confirm to the bot that your email address is
good, and hey presto! you're a target for even more spam.  Just ignore them
or make yourself a filter rule to kill them automatically.

Cheers!

Mike

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

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



RE: [PHP] Branching blunder

2004-08-05 Thread Ford, Mike [LSS]
On 05 August 2004 15:15, Jay Blanchard wrote:

 [snip]
 if($ans_three[$qzid] === 'None of the above' || $ans_three[$qzid] ===
'All of the above'){ if($ans_four[$qzid] === 'None of the above'
   || $ans_four[$qzid] === 'All of the above'){
 $answers  =   rand(6,8); 
 
}
$answers   =   5;
 }
 else{
$answers   =   rand(1,4);
 }
 
 However when I run it, it checks everything correctly until it has
 answer three and four having 'All of the above' and 'None of
 the above',
 then it branches to $answer = 5, only.  Why?
 [/snip]
 
 Because $answers = 5; is the last check of $answers unless the else
 statement is invoked. Try this...
 
 if($ans_three[$qzid] === 'None of the above' || $ans_three[$qzid] ===
'All of the above'){ if($ans_four[$qzid] === 'None of the above'
   || $ans_four[$qzid] === 'All of the above'){
$answers   =   rand(6,8); } elseif($ans_four[$qzid] !== 'None of
the
 above' || $ans_four[$qzid] !== 'All of the above'){

Ehhhrrrmmm -- that elseif () condition is always going to be true:
logically, it's got to be not equal to one or other of the values.

From a quick glance at the code, I'd say just a straight else would do the
job here, thus:

  if ($ans_three[$qzid] === 'None of the above'
  || $ans_three[$qzid] === 'All of the above')
  {
if ($ans_four[$qzid] === 'None of the above'
|| $ans_four[$qzid] === 'All of the above')
{
  $answers = rand(6,8);
}
else
{
  $answers = 5;
}
  }
  else
  {
$answers = rand(1,4);
  }

Cheers!

Mike

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

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



RE: [PHP] Location header does not work?

2004-08-05 Thread Ford, Mike [LSS]
On 05 August 2004 16:36, Bing Du wrote:

 I really appreciate everyone who responded taking your valuable time
 looking into my problem. 
 
 Now back to my problem.  Changing the condition to
 if($_SERVER['HTTPS']
 != 'on') did not make any difference unfortunately. So the result was
 still the URL in the Address box of the browser changed to
 https://computing.eng.iastate.edu/mambo/index.php?option=conte
 nttask=viewid=159Itemid=162
 fine.  But instead of showing the page that https address
 should point to,
 'You are in HTTPS mode' was displayed as the else clause specified.

Right, you're obviously not getting this, so let's take it step by step.

(1) Your browser requests
https://computing.eng.iastate.edu/mambo/index.php?option=contenttask=viewi
d=159Itemid=162

(2) This fires the script /mambo/index.php on your server.

(3) Script finds all conditions in the first if() are met, so tests
$_SERVER['HTTPS'].

(4) ... finding it is not set, it issues a Location: redirect to
https://computing.eng.iastate.edu/mambo/index.php?option=contenttask=viewi
d=159Itemid=162

(5) Browser sees the redirect, and issues a new request for
https://computing.eng.iastate.edu/mambo/index.php?option=contenttask=viewi
d=159Itemid=162; at this point, it also changes the URL displayed in its
address bar.

(6) This seems to be where you are confused -- WHICH PAGE DO YOU THINK THIS
IS GOING TO LOAD?





(6a) Server sees new request, this time via https, to exactly the same
script as before, so fires the script /mambo/index.php again.

(7) See (3).

(8) This time it finds $_SERVER['HTTPS'] is set (or =='on', depending), and
echos 'You are in HTTPS mode'.

(9) QED

Which step isn't what you were expecting?

Cheers!

Mike

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

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



RE: [PHP] Location header does not work?

2004-08-05 Thread Ford, Mike [LSS]
On 05 August 2004 17:12, Ford, Mike [LSS] wrote:

 (1) Your browser requests
 https://computing.eng.iastate.edu/mambo/index.php?option=conte
 nttask=viewi d=159Itemid=162

Bother! Sorry, that should, of course, be http:// in step (1)!

Cheers!

Mike

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

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



RE: [PHP] $HTTP_REFERER

2004-08-05 Thread Ford, Mike [LSS]
On 05 August 2004 17:18, Shaun wrote:

 Hi,
 
 I seem to have problems redirecting pages when I view my site using my
 laptop, the only difference is that my laptop has Norton
 Firewall installed,
 can this interfere with the $HTTP_REFERER variable

Not only can, does!  Other firewalls or proxies may alter it, some will simply block 
it, and anyway it can be forged by the user.

Cheers!

Mike

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

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



RE: [PHP] Query Results Question

2004-08-04 Thread Ford, Mike [LSS]
-Original Message-
From: Harlequin
To: [EMAIL PROTECTED]
Sent: 04/08/04 01:55
Subject: [PHP] Query Results Question

I have the following query which should return just two rows:

SELECT 'ID', 'Vacancy Role', 'Vacancy Salary', 'Vacancy Location',
'Vacancy
Type'
  FROM vacancy_details
  WHERE Publish = 'Yes'

As only two rows have Publish set to Yes.

yet even if I execute the query through phpMyAdmin I get two rows with
field
headings as field values.
--

I may be wrong, as I don't use mySQL, but shouldn't those be back-ticks around the 
column names and not single quotes?  With the quotes, you're just asking the database 
to return the literal text as if it were a column value.  Back ticks are used to 
enclose column names that contain non-alphanumeric characters.

Cheers!

Mike
Any suggestions on where I'm going wrong...? I'm pretty sure my query
syntax
is accurate as I've used this type of query many times before and have
even
checked the syntax by using a query window.

-- 
-
 Michael Mason
 Arras People
 www.arraspeople.co.uk
-

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

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



RE: [PHP] pconnect...

2004-08-02 Thread Ford, Mike [LSS]
-Original Message-
From: bruce
To: 'Curt Zirzow'; [EMAIL PROTECTED]
Subject: RE: [PHP] pconnect...

i meant mysqli/php5 regarding pconnect. although, i've since seen
information that leads me to believe htat pconnect would necessarily in
and
of itself be my solution.
--

No, it wouldn't.  Persistent connections were only ever a way to try and get faster 
connections to the database when the same logon credentials were used repeatedly.  
They DO NOT, DID NOT, AND NEVER HAVE provided the ability to manage transactions over 
multiple pages.  Give up on this tack and go write your middle-man application or 
whatever else you reckon you need to fulfill your requirement.

Cheers!

Mike.

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



RE: [PHP] Browser reload problem

2004-07-30 Thread Ford, Mike [LSS]
On 30 July 2004 16:25, Ashley M. Kirchner wrote:

 Jason Barnett wrote:
 
 Though I'm intrigued by two things: a) why am I getting both
 $_REQUEST as well as $_POST variables

Because $_REQUEST is an aggregate of $_GET, $_POST and $_COOKIE.  That's the way it's 
defined: see 
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.request.

Cheers!

Mike

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

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



RE: [PHP] VB--PHP

2004-07-29 Thread Ford, Mike [LSS]
On 29 July 2004 10:00, Jay wrote:

 Hi!
 
 Can someone pelase help me to convert the following Vbscript code to
 PHP, i am really sucky at Regular Expression:
 -CODE VBSCRIPT-
 Function IsValid(strData,blIncludeAlpha,blIncludeNumeric)
 Dim regEx, retVal,strPtrn
 Set regEx = New RegExp
 If blIncludeAlpha Then
 strPtrn=a-zA-Z
 End If
 If blIncludeNumeric Then
 strPtrn=0-9
 End If
 if blIncludeAlpha and blIncludeNumeric Then
 strPtrn=a-zA-Z0-9
 End if
 regEx.Pattern = ^[  strPtrn  ]+$
 IsValid= regEx.Test(strData)
 End Function

Something like:

function isValid($strData, $blIncludeAlpha, $blIncludeNumeric)
{
$strPattern = /^[;
if ($blIncludeAlpha):
$strPattern .= a-zA-Z;
endif;
if ($blIncludeNumeric):
$strPattern .= 0-9;
endif;
$strPattern .= ]$/;

return preg_match($strPattern, $strData);
}

Cheers!

Mike

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

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



RE: [PHP] strpos mystery

2004-07-29 Thread Ford, Mike [LSS]
On 29 July 2004 01:50, Jon Drukman wrote:

 with this code fragment:
 
 ?
 
 $string='/mobile/phone.html';
 if (strpos($string,'/mobile/')!==false) { print one: yes\n; }
 if (strpos($string,'/mobile/')===true) { print two: yes\n; }
 
  
 
 
 only the first if statement prints anything.  why is !==
 false not the
 same as === true ?

Because strpos returns the integer offset of the found substring, or FALSE
if not found; it *never* returns TRUE.  (You need the !== test because
strpos() can return an offset of zero, which would be ==FALSE but not
===FALSE.)

Cheers!

Mike

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

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



RE: [PHP] unset($_COOKIE['foo']) and $_COOKIE['foo'] = '' both do n't do anything.

2004-07-29 Thread Ford, Mike [LSS]
On 28 July 2004 20:17, Daevid Vincent wrote:

 No. I'm trying to delete it from PHP memory, but keep the cookie on
 their client in the cookie.txt file or wherever it's stored.

Where are you doing the test for it -- in the same script, or in a
subsequent one?  If the former, then I'm confused; if the latter, then this
is expected behaviour (explanation on request ;).

Cheers!

Mike

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

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



RE: [PHP] Re: Retrieving Stored Values for Dropdown Menu

2004-07-28 Thread Ford, Mike [LSS]
On 28 July 2004 12:50, Harlequin wrote:

 OK David.
 
 But here's the conundrum:
 
 a User has already selected a value which is stored in the database.
 Can I Display a range of option tags but make the one the user
 selected previously as the default...? 

That's been asked and answered many times on this list -- why not search the
archives?

Cheers!

Mike

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

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



RE: [PHP] Accessing a variable from inside a local function

2004-07-28 Thread Ford, Mike [LSS]
On 28 July 2004 12:29, Frank Munch wrote:

 Would anyone know how to resolve this scope problem? Or is
 this possibly
 something PHP can't (yet) do?
 
 The problem is to access a variable in a function foo from a function
 local to foo.

Actually, your problem is that the function bar is *not* local to foo.  Even
though PHP lets you declare functions lexically within the scope of other
functions, semantically they are still global functions and have no access
whatsoever to the enclosing function.

 
 - - -
 
 function foo($var_foo)
{
$my_foo_local = 10;  //How can I reach this from inside function
 bar(...? 
 
function bar($var_bar)
  {
  return $my_foo_local+$var_bar+1;  //  Doesn't work,  can't see
  $my_foo_local }
 
return bar($var_foo)+1;
}
 
 if (foo(0)==12)
echo Yes! I did it!;
 else
echo Nope. Sorry;

Cheers!

Mike

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

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



RE: [PHP] Re: If...Or...Else

2004-07-26 Thread Ford, Mike [LSS]
On 25 July 2004 21:16, Skippy wrote:

 
 Any idea why the need to have two logical operators with the
 same meaning BUT
 different precedences? I dig the need to put in OR as an
 alias, but why
 confuse people with the precedence issue? One would tend to
 think || and OR
 are perfectly interchangeable.

It's a horses for courses situation -- each tends to lead to better readability when 
used in its appropriate context.  For instance (to improve on the above example):

   $result = mysql_query(.) or die(mysql_error());

would need extra parentheses if rewritten using the || operator:

   ($result = mysql_query(.)) || die(mysql_error());

On the other hand, a construct like:

   $is_valid = $x0 || $y0;

would need additional parentheses with or:

   $is_valid = ($x0 or $y0);

Cheers!

Mike

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

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



RE: [PHP] Re: Embedding JavaScript into a PHP generated web page

2004-07-26 Thread Ford, Mike [LSS]
On 26 July 2004 01:13, Robert Frame wrote:

 OK, now I am bewildered again.
 
 Sample Code
 
 ?php
 
 echo 'script language=text/javascript';

   script language=JavaScript

 echo '!-- ';
 echo 'function myWindow() { alert(javascript from php)}';
 echo '//-- /script';

There's no need to echo your script from php -- just as with large chunks of
regular html, you can drop out of php mode and just write it as you want it:

?
script language=JavaScript
!--
function myWindow() { alert(javascript from php)}
//--
/script

Cheers!

Mike

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

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



RE: [PHP] Re: change value of session variable?

2004-07-22 Thread Ford, Mike [LSS]
On 22 July 2004 07:50, Five wrote:

  Sounds like an old bug in PHP. What version are you using?
 
 I've been trying to get it to work at:
 http://members.lycos.co.uk/primeooze/info.php

According to this phpinfo(), that site has session.use_cookies=On and 
session.use_trans_sid=Off.  This means that the simple Blue/Green test that has been 
bandied about here won't work for anyone who is not accepting cookies.  Hence, John 
Holmes's question

  Are you sure you're accepting the cookie? How are you sure?

is extremely relevant.

 I also have ( apache/php 4.3.4/mysql ) installed on my
 computer and I get much more satisfactory results on it.

Does that installation have session.use_trans_sid=On?  If so, another of John's 
questions is relevant:

   If you see an SID in the URL when navigating the pages, does it stay the same 
between 
pages or change?

Cheers!

Mike

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

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



RE: [PHP] Is that a PECL in your pants?

2004-07-01 Thread Ford, Mike [LSS]
On 01 July 2004 04:10, John W. Holmes wrote:

 Can anyone explain the purpose of PECL to me besides what it
 says on the
 web page (http://pecl.php.net)?

Besides what's already been said, it also decouples the release cycles of
the extensions from that of PHP itself.  An upgrade to a PECL extension can
now be released at any time, and the latest version can (theoretically, at
least) be installed against any recent release of PHP.  For extensions which
are chosen to be bundled with PHP, the latest *stable* version of each
extension will be packaged in the PHP release.  (This will also eliminate
the time-honoured cry on php-internals of Will all extension maintainers
please commit outstanding updates so we can roll version so-and-so! ;)

Cheers!

Mike

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

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



RE: [PHP] Re: Testing if cookies are enabled

2004-06-21 Thread Ford, Mike [LSS]
On 21 June 2004 12:11, Martin Schneider wrote:

 thanks for your reply, I think you missunderstood, please read more
 carefully. I know how to set and read a cookie, but as I
 wrote I wasn't
 able to set and text a cookie ON THE SAME PAGE.
 
 The manual says: http://php.net/setcookie
 Once the cookies have been set, they can be accessed ON THE
 NEXT PAGE.
 
 But I have seen pages on which it seems they set und check if
 the cookie
 has been set ON THE SAME PAGE. So I want to know how they do that
 (perhaps with a 302-header or something like that?).

Yes, that's one possibility, but there'd still have to be at least one page
load involved before you'd see the cookie.  What you describe makes it more
likely that there's actually some client-side technology involved, such as
JavaScript.

Cheers!

Mike

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

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



RE: [PHP] Problems with arrays

2004-06-17 Thread Ford, Mike [LSS]
On 17 June 2004 14:27, Phpu wrote:

 Here is the code:
 
 select name=model class=gform
 onchange=model_jump('parent', this)
option value=0
   ?
   foreach ($nav_model_names as $index = $element) {
 $InputString = $element;
  echo $InputString;
}
  /option
   /select

Each option needs to be in, er, option/option tags, do you want something like:

   foreach ($nav_model_names as $index = $element) {
  echo option value='$index'$element/option\n;
   }

Cheers!

Mike

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

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



RE: [PHP] Combo problems.. Multi Array??

2004-06-16 Thread Ford, Mike [LSS]
On 15 June 2004 00:07, Michael Benbow wrote:

 Thanks Mike,
 
 I have read up a lot on permutation but I'm not completely sure that
 this will solve my problem.  From what I can gather
 permutation takes a
 sample (i.e. ABC) and tells you how many different ways it
 can arrange
 the letters, with order mattering.  What I need to do is take
 a variable
 number of groups (in my example, 3) and then display the combinations
 of ways that my sample (in my example, 2) can be spread across
 the groups.

Ah, yes -- sorry.  Something in your original post must have made me think you just 
wanted the number of ways, not the actual permutations.  (And, in any case, I don't 
think this *is* actually a permutation, so I think I was doubly trigger happy!)

[...]
 
 The example again is as follows..
 
 A [1][2] BC
 AB [1][2] C
 ABC [1][2]
 A [1]B [2]C
 AB [1]C [2]
 A [1]BC [2]
 A [2]B [1]C
 A [2]CC [1]
 AB [2]C [1]
 
 Think of the letters as being static amongst all possible
 combinations, and the numbers as the piece of data which is
 varying.  In my actual code both fields are integers but this
 isn't really important here.

I've been fiddling with this for half an hour or so, and I'm pretty convinced the 
solution is going to involve a recursive function.  However, it might help if you 
could say exactly what you want as a result: printed out (in a format similar to the 
above), inserted into a database (how?), or some sort of PHP data structure (such as a 
multi-level array) containing all the possible results?

Don't guarantee to come up with a final (or even an approximate!) solution, but 
knowing what you're trying to work towards would help...!

Cheers!

Mike

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

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



RE: [PHP] Regarding variable reference

2004-06-15 Thread Ford, Mike [LSS]
On 15 June 2004 08:25, Ulrik S. Kofod wrote:

 [EMAIL PROTECTED] sagde:
  
  Hi,
  I have variables called Cookie1 to Cookie35.
  
  I would like to print the values of  Cookie1 to Cookie35 using for
  loop. 
  
  Could anybody correct the below code to print the variables.
  
  =for($i=1;$i34;$i++)
  {
  $x=Cookie.$i;
  
  if(isset($$x))
  {
  echo p$x:$$x/p;
  }
  }
 
 
 for($i=1;$i34;$i++)
 {
 $x=Cookie.$i;
 eval(\$y = \$$x;);
 if(isset($y))
 {
 echo p$x:$y/p;
 }
 }

No need for eval() here, this will work just fine:

$x = Cookie$i;
$y = $$x;

You could also collapse the two statements like this (if you didn't need
$x):

$y = ${Cookie$i};
or
$y = ${Cookie.$i};

However, this seems to be a classic case where the use of variable variables
looks like a fudged solution, and you should examine your data to see if it
can't be better represented in an array (which would have made coding the
above loop a snap).

Cheers!

Mike

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

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



RE: [PHP] Combo problems.. Multi Array??

2004-06-14 Thread Ford, Mike [LSS]


 -Original Message-
 From: Michael Benbow [mailto:[EMAIL PROTECTED] 
 Sent: 14 June 2004 08:31
 To: [EMAIL PROTECTED]
 Subject: [PHP] Combo problems.. Multi Array??
 
 
 Hi,
 
 I've got a problem which has left me scratching my head for 
 the better 
 part of a week.

[...]

 The outcome, if working properly, should be...
 
 A [1][2] BC
 AB [1][2] C
 ABC [1][2]
 A [1]B [2]C
 AB [1]C [2]
 A [1]BC [2]
 A [2]B [1]C
 A [2]CC [1]
 AB [2]C [1]
 
 Does anyone have any ideas on how I could do this?  As I said I'm 
 completely stumped.

This is called a permutation.  Googling for permutation formula brings up
any number of good links; the most succinct is probably
http://www.mathwords.com/p/permutation_formula.htm, but most of the other
top 10 links will give you the same answer with a bit (or a lot!) more
explanation.

Cheers!

Mike

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

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



RE: [PHP] Can someone explain this?

2004-06-09 Thread Ford, Mike [LSS]
On 08 June 2004 19:00, René Fournier wrote:

 OK, that makes sense. But here's the problem: I receive binary data
 from SuperSPARC (big-endian), which I need to unpack according to
 certain documented type definitions. For example, let's say that $msg
 has the value 3961595508 and is packed as an unsigned long integer
 (on the remote SPARC). But when I receive it, and unpack it...
 
 $unpacked = unpack('Nval', $msg); // N for unsigned long integer,
 big-endian (SPARC) echo $unpacked[val];
 
 ...the output value is -71788. (???) Which tells me that PHP is
 NOT unpacking $msg as an unsigned long integer, but rather as
 a signed
 integer (since unsigned integers cannot be negative).
 
 Now, thanks to your suggestions, I can convert that number back to an
 unsigned integer-or at least make it positive. But I
 shouldn't have to
 convert it, should I?

Yes.

Whether an integer is signed or unsigned is simply a matter of how you interpret the 
32 bits representing it -- unsigned 3961595508 is represented in 32 bits in exactly 
the same way as signed -71788.  This explains the results you are getting: PHP 
*is* unpacking your binary(?) data as unsigned, but, as PHP doesn't have an unsigned 
type, the only place it has to put the resulting 32-bit representation is in a PHP 
integer, which is signed -- so when you print it, you get the signed representation.

To get PHP to print the unsigned representation of an integer, you can use the %u 
format specifier of sprintf() (http://www.php.net/sprintf) or one of its *printf 
friends.

Cheers!

Mike

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

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



RE: [PHP] ini_get

2004-06-07 Thread Ford, Mike [LSS]
On 06 June 2004 22:43, Dennis Gearon wrote:

 CC me please.
 
 Does anyone know if ini_get returns the values BEFORE or AFTER the
 .htaccess modifies them? i.e., does it return the server or
 local version?

It gets the value the script is currently running with.  This will be the
local version, unless it has been further modified by an ini_set in the
script.

Cheers!

Mike

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

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



RE: [PHP] Newbie question about isset and binary conditionals

2004-06-07 Thread Ford, Mike [LSS]
On 07 June 2004 14:04, Al wrote:

 I posted this previously; but the subject was misleading.

You seem to have several possible misconceptions in your posting -- this may
just be me misreading you, but anyway...

 I could use one additional clarification regarding good practice.
 
 As I understand the php manual the following is acceptable
 and I assume
 good practice.
 
 $foo= TRUE;

Not only acceptable but encouraged.

 
 if($foo) do..  ;  where $foo is a binary; but not
 a variable.

$foo is always a variable -- it can contain values of several types, one of
which is Boolean (not binary -- that's just a way of representing integers)
TRUE/FALSE.
 
 isset should be used for variables, such as;
 
  isset($var) for variables and be careful with $var= ' ';
 etc.  because
 $var is assigned, i.e., set.

To work out which test you need to use, it's crucial to understand what
evaluates to FALSE in a Boolean context (which the test of an if() statement
is.  This is covered in precise detail in the PHP manual at
http://www.php.net/manual/en/language.types.boolean.php#language.types.boole
an.casting, but to summarize:

   the following are considered FALSE: Boolean FALSE, numeric zero (0 or
0.0), the strings  and 0, an empty array or object, and NULL; all other
values are TRUE.  In addition to this, an unset variable will be evaluated
as NULL, and hence considered FALSE, but PHP will also issue an undefined
variable warning in this case (which may or may not be suppressed by your
PHP configuration!).

On the other hand, isset($var) will return TRUE if $var has been set to any
value except NULL, and FALSE otherwise -- so an isset() test on all the
other values listed above (including FALSE!) will be TRUE.

Other tests you may want to look into are empty() http://www.php.net/empty
and is_null() http://www.php.net/is-null; there are also some handy tables
at http://uk.php.net/manual/en/types.comparisons.php to help you see what
the various tests return.

Cheers!

Mike

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

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



RE: [PHP] Re: how to insert form data

2004-06-03 Thread Ford, Mike [LSS]
On 03 June 2004 03:57, Ligaya Turmelle wrote:

 shouln't be
 QUOTE: input type = textarea name=quote...

If that was a question, then: No, it shouldn't.  Some versions of a certain
browser may have supported this, but it has never been part of any HTML
standard.

Cheers!

Mike

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

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



RE: [PHP] weird error

2004-06-03 Thread Ford, Mike [LSS]
On 03 June 2004 15:52, pagongski wrote:

  Hi guys,
 
  I recently installed easy-php on my laptop so i
 could work on the
 go without having to upload my scripts to the server to test them
 out. The problem is that when i tried one of my scripts on it, i get
 some weird errors, and the script works fine on the online server.
 
  Here are some example errors:
 
  Notice: Use of undefined constant REMOTE_ADDR - assumed
 'REMOTE_ADDR' in c:\win2kapp\easyphp1-7\www\index.php on line 35
 
  Notice: Undefined variable: HTTP_REFERER in .
 
  I have register globals on. (was off so i turned
 them on thinking
 that might be the problem..didnt work either way)

These Notices will not prevent your script running to completion -- they merely point 
out places where your code can potentially be improved.

Looks like error_reporting on your laptop is turned all the way up to E_ALL, whereas 
on on the server E_NOTICE level messages are excluded.  This is actually a *good* 
configuration -- on your test server, you get to see all the nitty-gritty warnings 
about the minor errors that PHP will ignore or automatically correct for you, whilst 
on your live service they are suppressed.  You can then decide, on a fully-informed 
basis, whether you want to adjust your code to be comletely notice-free, or whether 
you're prepared to leave them as is and let PHP take care of them.

Cheers!

Mike

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

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



RE: [PHP] Update Multiple Records From Form

2004-05-28 Thread Ford, Mike [LSS]
On 28 May 2004 04:47, Albert Padley wrote:

 I feel I'm so close.
 
 I have a form with multiple database records with a checkbox to
 indicate which records to update set up like so:
 
 $name = ed[ . $row['id'] . ];
 
 input type=\checkbox\ name=\ . $name . \ value=\Y\
 
 Each text input is set up like so:
 
 input type=\text\ name=\fname[]\ value=\ . $row['fname'] . \
 
 On the processing page I am doing this:
 
 foreach($ed as $id=$val){
   $query = UPDATE ref_events_reg
SETfname = '$fname'
   WHERE id = '{$id}';
 
 I am looping through the correct records, but every field is being
 updated to Array. 
 
 What tweak do I need to make?

I'd make two tweaks, actually.  First and most obviously, you're not selecting *which* 
fname field to pass to your update query, so this needs to be:

$query = UPDATE ref_events_reg
 SET fname = '{$fname[$id]}'
 WHERE id = '{$id}';

(By putting just $fname there, you are telling PHP to insert the string representation 
of the whole array -- and the string representation of any array is, er, exactly 
Array! ;)

This change may give you a clue to my other tweak -- I'd explicitly set the indexes of 
all the fname[] fields to be sure they sync correctly to the related check box, thus:

input type=\checkbox\ name=\ed[{$row['id']}]\ value=\Y\
input type=\text\ name=\fname[{$row['id']}]\ value=\{$row['fname']}\

Cheers!

Mike

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

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



RE: [PHP] Re: Changing variable names in a while loop

2004-05-28 Thread Ford, Mike [LSS]
On 28 May 2004 12:30, Torsten Roehr wrote:

 I.A. Gray [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Hi all,
  
  Easy question (I hope).  My brain seems not be working today, so
  could someone help me with this one?

[...]

  How can I get the value to change in each form?  The name and id
  for each input field will change from (for example) fcomposer1 to
 fcomposer30 but
 how
  do I change the value for each input to show the variables taken
  from the database which will be $composer1 to $composer30 ?
  Obviously if I put in $composer$countything that will just output
  the value of $composer followed by the value for $countything, but
  I want it to output the value for $composer1 if $countything=1 or
  $composer10 if $countything=10 .  Is there something I can do with
  variable variables?  I couldn't see 
 any examples
 in
  the PHP manual.
 
 What you want is this:
 $temp = 'composer' . $countything;
 Then use ${$temp} - it will efectively be $composer1.

You can also write this as

  ${'composer'.$countything}

But I'd really, really suggest looking into using arrays for this -- it looks much 
more like an array-ish problem than a variable-variable-ish problem to me.  Using 
arrays, your input fields would look like:

  input name='fcomposer[$countything]' type='text' size='20' maxlength='60' /

and then your processing code can easily address $fcomposer[$countything] etc.

Cheers!

Mike

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

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



RE: [PHP] IF statement question...

2004-05-19 Thread Ford, Mike [LSS]
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] 
 Sent: 19 May 2004 12:55
 
 Is it possible to request that a string CONTAINS another string...?
 
 EG:
 $string = 1, 2, 3, 7, 8, 9;
 if ($string CONTAINS 7) {
 // Do stuff
 }

   if (strpos($string, 7)!==FALSE)

Cheers!

Mike

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

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



RE: [PHP] IF statement question...

2004-05-19 Thread Ford, Mike [LSS]
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] 
 Sent: 19 May 2004 15:47
 
 If I'm being Dumb, I apologies...
 but When using this:
 
 $row[bands] = 1,2,3,4,5,6,7,8;
 $row2[id] = 7;
 if (strpos($row[bands], $row2[id]) != FALSE) {
 // do stuff
 }
 
 I get the No 13 (as it's inthe 13th place in the string) as my result.
 
 Now I'm aware that it should work, as it's not returning a 
 false value... But I'm still not getting the correct output 
 on my page...

(i) needs to be !== not != (since the substring might appear in position 0 and 
0==FALSE).

(ii) post some lines of your actual code showing what you expect, and what you 
actually get.

(iii) to know exactly what we're dealing with, var_dump $row and $row2 before you do 
the strpos, and cut'n'paste the results for us.

(iv) also, quote your string subscripts ($row['bands']) -- not vital, but suppresses a 
constant-lookup and notice for each one, and hence is more efficient.

Cheers!

Mike

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

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



RE: [PHP] using returned references directly?

2004-05-18 Thread Ford, Mike [LSS]
On 17 May 2004 22:26, Jeff Schmidt wrote:

 Hello,
Say I have object A, with method getObjectB(), which returns a
 reference to object2. 
 
 Is there a way to do something like
 $A-getObjectB()-methodFromObjectB();
 
 ??
 
 When I try that, I get a parse error? Is this simply not
 possible with
 PHP, or is the syntax just a little different?
 
 I mean, I could:
 
 $b = $A-getObjectB();
 $b-methodFromObjectB();

That's how you have to do it in PHP 4.  In PHP 5, you will be able to use the 
collapsed version -- it's one of the OO improvements.

Cheers!

Mike

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

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



RE: [PHP] Select box

2004-05-18 Thread Ford, Mike [LSS]
On 18 May 2004 09:06, Brent Clark wrote:

 Hi all
 
 For the likes of me I cant seem to figure out how to have a
 select drop down
 box , and have it so, that when I click the submit button,
 the page displays
 the correct content (which is what it does) but at the same
 time I need the
 select box to be at the option of the query.
 
 Below is part of my code.
 
 If someone could help, it would be most appreciated.
 
 select name=uname
 ?php
 $sqlu=SELECT id,user,name FROM users
 ORDER BY user
 ASC;
 $name_result = mysql_query($sqlu);
 while($rowu=mysql_fetch_array($name_result)){
 echooption
 value=\$rowu[user]\$rowu[user]/option\n;
 }
  
 /select

Assuming that this form submits to itself, so $_POST['uname'] will be set to the 
selected value:

$selected = @$_POST['uname'];
while($rowu=mysql_fetch_array($name_result)){
  echo option value=\$rowu[user]\;
  if ($selected==$rowu['user']) echo ' selected';
  echo $rowu[user]/option\n;
}

Cheers!

Mike

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

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



RE: [PHP] PHP and Caching and IMS Headers

2004-05-18 Thread Ford, Mike [LSS]
On 18 May 2004 13:58, Nick Wilson wrote:

 Hi,
 
 I was reading this post here:
 http://www.cre8asiteforums.com/viewtopic.php?t=9801
 
 No, not my site ;-)
 
 I think it sounds like there are some mistaken views in there, anyone
 that knows about If-Modified-Since headers, PHP and Caching
 could shed a
 little conclusive light on the subject?

From my own experience, I can confirm that ILoveJackDaniels is definitive in that 
thread.  What he describes is exactly how I do it.

Cheers!

Mike

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

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



RE: [PHP] Not sure

2004-05-14 Thread Ford, Mike [LSS]
On 14 May 2004 09:59, Brent Clark wrote:

 Hi all
 
 I have the following php code:
 
 echotdnbsp;/tdtdinput type=\checkbox\ name=\frow\
 value=\$var\/td\n; 
 
 I now have the following javascript code:
 !-- From webmin--
 
 a href='' onClick='document.frm.frow.checked = true; for(i=0;
 idocument.frm.frow.length; i++) {
 document.frm.frow[i].checked = true; }
 return false'Select all/anbsp;
 a href='' onClick='document.frm.frow.checked =
 !document.frm.frow.checked;
 for(i=0; idocument.frm.frow.length; i++) {
 document.frm.frow[i].checked =
 !document.frm.frow[i].checked; } return false'Invert
 selection/abr 
 
 the problem I have is that if I change the
 
 echotdnbsp;/tdtdinput type=\checkbox\ name=\frow\
 value=\$var\/td\n; to
 echotdnbsp;/tdtdinput type=\checkbox\ name=\frow[]\
 value=\$var\/td\n; 
 
 Then my php task is fine, but if I make it a normal variable, like
 name=frow 
 
 But then my PHP does not work, and the Javascript does work (Selects
 all the checkboxes with a tick)
 
 I can determine if this is a javascript fault or a php fault.

Neither -- a programmer fault! ;)

Name the field with name=frow[], and refer to it in JavaScript like this:

   document.frm['frow[]']

Cheers!

Mike

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

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



RE: [PHP] FIXED: Max file size for uploads?

2004-05-13 Thread Ford, Mike [LSS]
On 12 May 2004 16:48, Robert Sossomon wrote:

 It's fixed now..
 
 If using Apache on RedHat here is everything to fix at once:
 
 FIRST AND FOREMOST DECIDE THE MAX SIZE YOU WANT IN MB, ADD A COUPLE
 MORE TO IT, AND THEN CONVERT TO BYTES (MB * 1024 * 1024)
 
 1.  httpd/conf.d/php.conf
 LimitRequestBody  ?? #byte size you calculated
 
 2.  /etc/php.ini
 max_file_size = ???M #Max size in MB
 post_max_size = ???M #Max size in MB

post_max_size should be larger than max_file_size, since you need to allow
space for any other fields in the form.  If any of your forms have more than
one file upload field, post_max_size should be the appropriate multiple of
max_file_size, plus some overhead.  Apache's LimitRequestBody should also be
adjusted accordingly.

Cheers!

Mike

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

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



RE: [PHP] dinamic hashes

2004-05-13 Thread Ford, Mike [LSS]
On 13 May 2004 12:59, Yivi wrote:

 Hello everyone.
 I am having a stupid problem with a couple of arrays, tried a
 couple of
 things but I am feeling disconcerted.
 
 The thing is, I thought it was possible to create arrays in a dynamic
 fashion, as in: $newarray['newkey'] = new_value;
 And the array would be incremented accordingly.
 And afterwards, if I wanted to add a new key to the thing, just doing:
 $newarray['anotherkey'] = anothervalue; would be enough.
 Generally speaking I have been trying that and it was
 working, but right
 now I am having some trouble with this.
 
 I am parsing a kind of referrals log file, and as I get the values I
 want to create  a hash with all the values I get into a hash to use
 later on. 
 
 Each line of the log is processed in a while() loop, and after
 extracting the values for $searchSource, $searchDomain and
 $searchTerm I try to create the hash entries with these lines:
 
 $table[$searchSource][$searchDomain][$searchTerm][total
 ]+=$row['order_total'];
 $table[$searchSource][$searchDomain][$searchTerm][count]++;

Your problem here is that you are using the += and ++ operators, which need
to fetch the existing value of your array element before adding to or
incrementing them.  Of course, the *first* time you attempt to do this the
array element doesn't exist yet, so PHP throws a notice for each of the
subscripts; subsequent additions to or increments of the same elements will
proceed without problem.
 
 total is an amount that I want to aggregate for each $seachTerm, and
 count an obvious counter with total hits per
 $searchTerm/Domain/Source
 combination. $table is an array which I create before
 entering the loop
 with: $table = array();

This is irrelevant and, strictly speaking, unnecessary.
 
 The problem is that I keep getting this warnings and notices:
 Notice: Undefined index: GGAW in
 c:\www\deepswarm.co.uk\script\monthlytable.php on line 60

[...]

 Using the @ operator the scripts works perfectly, but I

That's one of the obvious ways to suppress these notices.  Others are to
turn off E_NOTICE level messages for the duration, or use isset() on each
access to decide whether to do a plain assignment or use an
increment/addition.

BTW, all those quotes are unnecessary and inefficient -- just write your
array accesses like this:

$table[$searchSource][$searchDomain][$searchTerm][count]

Cheers!

Mike

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

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



RE: [PHP] Variables Help

2004-05-13 Thread Ford, Mike [LSS]
On 13 May 2004 19:52, John Nichel wrote:

 Monty wrote:
  Is there any way to get JUST the user-defined variables in PHP?
  Problem with get_defined_vars() is that it contains everything,
  including server and environment vars, and there's no easy way to
  keep just the user-defined vars part of the array created by
  get_defined_vars. 
  
  Monty
  
 
 foreach ( get_defined_vars() as $key = $val ) {
   if ( ! preg_match (
 /_POST|_GET|_COOKIE|_SERVER|_ENV|_FILES|_REQUEST|_SESSION/, $key )
   ) { $user_defined[$key] = $val;
   }
 }

U, or even, possibly, if no user variable names begin with _

 if ($key{0}!='_')



Cheers!

Mike

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

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



RE: [PHP] PHP Sessions on Windows

2004-05-12 Thread Ford, Mike [LSS]
 -Original Message-
 From: David Mitchell [mailto:[EMAIL PROTECTED] 
 Sent: 12 May 2004 13:21
 
 OK, I managed to get it working. 
 
 I first attempted to edit the php.ini so that the session 
 save path was C:\Temp. No matter what I did, the save path 
 always showed up in phpinfo() as /tmp. So I created folder on 
 the root of C: called tmp and everything worked.

This still looks like PHP is not looking for the php.ini file where you
think it is.  I strongly suggest you follow the previous advice to work out
where PHP is actually expecting your php.ini to be, before you have a need
to change another initialization parameter.

Cheers!

Mike

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

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



RE: [PHP] default and another constructor

2004-05-12 Thread Ford, Mike [LSS]
 -Original Message-
 From: Rudy Metzger [mailto:[EMAIL PROTECTED] 
 Sent: 12 May 2004 14:27
 
 On Wed, 2004-05-12 at 15:18, Mark Constable wrote:
  
   function forum($naam=NULL,$tijd=NULL,$tekst=NULL)
  
  and test the incoming variables with isset() before 
  attempting to use 
  any of them.
 If you assign default values to the method arguments, you 
 cannot test them with isset() anymore, as they will be set.

Not if the default is NULL -- isset(NULL) is false.

Cheers!

Mike

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

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



RE: [PHP] unexpected array_diff output

2004-04-30 Thread Ford, Mike [LSS]
On 30 April 2004 09:47, Frederic Noyer wrote:

 Hello there !
   I am trying to fill and then compare two arrays: one
 filled by a
 foreach construct, and the second by a while construct.
 I check both with a print_r to be sure that both are correctly filled
 (which seems to be the case). But then, when I try to compare
 them with
 a array_diff , the result is incoherent (at least to me...). I have
 tried several variant, but I don't understand what's wrong. Sure you
 guys can tell me where is my mistake.
 
 Here is the code:
 
 ?
 
 // creates first array (from a _POST[''] )
   foreach ($_POST['input_auteur'] AS $aut_ligne) {
   $part_ligne = explode(,,$aut_ligne);
   $arr1[] = (string) $part_ligne['2'];
   }
   echo Array from POST :;
   print_r ($arr1);

I don't have any great insight into what appear to be your odd array_diff()
results, but try using var_dump() instead of print_r() -- it will give you
more information about *exactly* what values are stored in the arrays, and
it may just be that you'll spot an odd discrepancy.

Cheers!

Mike

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

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



RE: [PHP] A to Z incremental

2004-04-23 Thread Ford, Mike [LSS]
On 22 April 2004 15:22, Paul wrote:

 Hi!
 Got this script:
 
 ?php
 for($i='A';$i='Z';$i++){  echo $i.' | ';  }
  
 
 The output is:
 A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P
  Q | R | S | T | U | V | W | X | Y | Z |
  AA | AB | AC |
  ...
   YX | YY | YZ |
 
 where is should display only letters from A to Z.
 Why is that?

Because 'Z'++ (if you see what I mean!) is 'AA'.

(So, at the end of the loop iteration which echoes 'Z', $i becomes 'AA',
which is 'Z', and as a result the loop continues on through all the values
you saw.  The loop terminates after 'YZ' is echoed, since at the end of that
iteration $i increments to 'ZA', which is not 'Z', and Bob's your uncle!)

One way of solving this is:

   for ($i='A'; $i!='AA'; $i++)

Cheers!

Mike

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

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



RE: [PHP] Unwanted e-mails

2004-04-20 Thread Ford, Mike [LSS]
On 19 April 2004 23:02, Lester Caine wrote:

 OK 72 Hours later I got 6 bounce messages back related to Fridays
 eMails direct to lists.php.net ( one of which is yet another attempt
 to unsubscribe from php-db ) 
 
  Delivery-date: Mon, 19 Apr 2004 20:30:30 +0100
  Received: from dswu27.btconnect.com ([193.113.154.28])
  by mx1.mail.uk.clara.net with smtp (Exim 4.30)
  id 1BFeTO-000KR9-8m
  for [EMAIL PROTECTED]; Mon, 19 Apr 2004 20:30:30 +0100
  Received: from btconnect.com by dswu27.btconnect.com id
 [EMAIL PROTECTED]; Mon, 19 Apr 2004
 20:27:04 +0100
  Message-Type: Delivery Report

Yeah, get that bounce every time a message is sent to php-general.  It's
obviously coming from a bad address subscribed to the list, though, as all
messages appear on the list long before that bounce comes in.

Cheers!

Mike

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

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



RE: [PHP] lt;buttongt; tag

2004-04-20 Thread Ford, Mike [LSS]
On 20 April 2004 09:45, Nunners wrote:

 button type=submit is not a standard HTML v4 tag

Bzzt! Completely wrong. See
http://www.w3.org/TR/html401/interact/forms.html#h-17.5.

Cheers!

Mike

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

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



RE: [PHP] Unwanted e-mails

2004-04-20 Thread Ford, Mike [LSS]
On 20 April 2004 07:47, Lester Caine wrote:

 Chris W. Parker wrote:
 
  but your messages *ARE* getting accepted otherwise i would not be
  reading this email right now!
 
 NO THEY ARE NOT - This reply HAS to be sent via the newsgroup!
 
 The bounce messages I am getting are as a result of .php.net NOT
 accepting my perfectly valid posts!

No, I don't believe so -- the bounce you posted looks exactly like the one I get from 
every message posted to the list, and my messages get through fine.  In fact, the 
bounce generally arrives days after the message has made it to the list!

Cheers!

Mike

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

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



RE: [PHP] Logic problem

2004-04-20 Thread Ford, Mike [LSS]
On 20 April 2004 16:44, Alex Hogan wrote:

 foreach ( $array1 as $flds ) {
   if ( $start ) {
   $query .= $flds;
   $start = false;
   } else {
   $query .= ,  . $flds;
 
   }
 }

   $query .= implode(, , $array1);

Cheers!

Mike

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

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



RE: [PHP] RegExp (preg) - how to split long string to length,wit hout cutting words

2004-04-16 Thread Ford, Mike [LSS]
On 16 April 2004 11:47, moondog wrote:

 Hi,
 I am a RegExp newbie, and need help with this:
 i have a long string (500 / 600 chars), and need to split it in lines.
 
 Each line has a maximum length (20), and words in the line
 shouldn't be
   cut, instead the line should end at the end of the word whose last
 char position is = 20. 
 
 the effect is like a left align in a word processor, where
 lines wrap at
 20, and the words are not cut.
 
 example:
 
 string= a b c d e ff g
 (char)112233444
   1234567890123456789012345678901234567890123456
 
 
 regexp should output:
 
 a b c
   d e
   ff g
 
 
 Is it a sensible thing to do this job with regExp or is it
 better to use
   the usual string functions?

The latter -- the usual string function in this case being 
http://www.php.net/wordwrap.

Cheers!

Mike

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

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



RE: [PHP] unexpected $ in ... WTF?

2004-04-15 Thread Ford, Mike [LSS]
On 14 April 2004 21:30, Brian V Bonini wrote:

 Parse error: parse error, unexpected $ in /foo/bar/foo.php4 on line
 150 

Just to add to previous responses, '$' is PHP's unhelpful notation for end
of file (think regex end-of-string anchor, if it helps!).

Cheers!

Mike

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

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



RE: [PHP] PHP version usage statistics?

2004-04-15 Thread Ford, Mike [LSS]
On 15 April 2004 06:18, Curt Zirzow wrote:

 * Thus wrote Jeffrey Tavares ([EMAIL PROTECTED]):
  netcraft shows how many servers have php, but nothing specific about
  versions. Maybe I'm wrong, but I checked all over netcraft's site.
 
 Sorry if I put ya on a bad lead. I could have swore they had
 some stats like that there, I guess I was wrong I can't find them
 either. 

I'm also sure such statistics used to exist in the free reports either at
Netcraft or Security Space -- I guess if they're still available they've
moved to the paid-for category. ;(

Cheers!

Mike

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

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



RE: [PHP] Maths not working.. or is it me?

2004-04-15 Thread Ford, Mike [LSS]
On 15 April 2004 10:59, [EMAIL PROTECTED] wrote:

 Im trying to implement some really simply credit card encryption...
 I know it's not perfect, but it's a stop gap measure until I do this
 properly... however... 
 
 To Encrypt before I put into my DB, I'm using this formula...
 $encrypt = $CardNumber / ($ExpiryYear * 41.9);
 (41.9 is just a random No to help encrpt the data)
 
 To see the correct credit card No later, I'm using this formula:
 $decrypt = $row[encryptedno] * $row[expiryyear] * 41.9;
 
 The credit car No I'm testing with is:
 1234123412341234
 and the Exp year is 2008
 
 However, I keep getting this result...
 1.2341234123412E+15
 
 What on earth am I doing wrong?

Trying to express your credit card number as an integer or a float, instead
of a string.  On a 32-bit architecture, an integer can't hold a number that
big -- and a float can probably only express about 14 significant digits, so
that's no good either.  Subject to those restrictions, the result you're
getting is a correct floating point representation of your original number,
so your maths is fine.

You'd be better off keeping your CC number as a string and using one of the
string encodings or encryptions.

Cheers!

Mike

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

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



RE: [PHP] Session confusion again :( - Thanks!

2004-04-15 Thread Ford, Mike [LSS]
On 14 April 2004 17:53, Paul Fine wrote:

 Thanks guys but I have register globals ON so once the
 session variable is
 defined I should be able to address it without specifying $_SESSION ?

I don't think the documentation is clear on this point -- it may be that the
association between the global variable and the $_SESSION array doesn't
take until the next page load and session_start(), and in any case the
behaviour seems to be different between 4.2 and 4.3.  I *think* you may have
to session_register('element_countp') to make the association in the current
page, but this is buggy and seriously disrecommended in 4.2 (although fixed
in 4.3).

Personally, I'd just use the $_SESSION[] variable anyway, and not bother
with the equivalent global.

Cheers!

Mike

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

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



RE: [PHP] php dateadd function?

2004-04-15 Thread Ford, Mike [LSS]
On 30 April 2004 13:23, Angelo Zanetti wrote:

 Hi all,
 
 I have found this code that is supposedly meant to be used
 for a dateadd
 function. I only need it for the adding of days, my problem is that it
 doesnt validate when adding days at the end of the month. eg:
 
 march 31 and the I add 2 days is meant to return  april 2.
 But it returns
 March 33.

Have you actually *tried* it?  Because that's not what this code does.  (Take a look 
at http://www.php.net/mktime for why not.)

Cheers!

Mike

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

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



RE: [PHP] php dateadd function?

2004-04-15 Thread Ford, Mike [LSS]
On 30 April 2004 13:45, Angelo Zanetti wrote:

 Hi Mike, I actually changed the return statement to return
 the date in a
 format that is different from the mktime format, so that
 would explain it.

So run the mktime(), then format the resulting timestamp.  Job done.

Cheers!

Mike

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

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



RE: [PHP] umask() and chmod()

2004-04-15 Thread Ford, Mike [LSS]
On 15 April 2004 16:26, David T-G wrote:

 Hi, all --
 
 When I move_uploaded_file() a file into place, I want to give it the
 correct permissions; by default they are 600 (rw-/---/--).  I already
 have the umask set correctly for any given situation in
 anticipation of
 creating directories, and that works for creating files from scratch,
 but chmod() needs a permissions setting rather than a umask.
 
 The challenge is in representing this as octal.  With some
 mucking around
 I was able to print
 
   $u = decoct(umask()) ;
   $m = 0777 ;
   $r = decoct($m) - $u ;
   print The setting is $r\n ;
 
 and get
 
   The setting is 664
 
 when umask returns 113.  All is great, right?  Well, no...  I need to
 convert that 664 octal value into an octal representation of
 
   0664
 
 to feed to chmod() -- and apparently I can't just
 
   $r = 0.$r ;

That would be

$r = '0'.$r;

I'm not sure, however, that this is a totally foolproof way of doing it, as
it would fail with any permission set (however unlikely) where the owner
odgit was a zero -- perhaps you should be sprintf()-ing it?

Cheers!

Mike

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

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



RE: [PHP] Explanation of cookie behavior

2004-04-15 Thread Ford, Mike [LSS]
On 15 April 2004 15:43, Ryan Schefke wrote:

 I'm running a login script where the user enters
 login/password and if it
 matches what I have in my db and their account is active, I set a
 login cookie (login_ck) and an authentication cookie
 (authenticate_ck).  If the
 login and authentication cookies are set when the user goes back to
 the login page I prompt with welcome back..  Now, I refresh the
 login page a few times, sometimes it gives the welcome back prompt. 
 Then after anywhere from 2-5 refreshes, it deletes the login cookie
 but the authenticate cookie persists.  Any ideas why this is
 happening? 
 
 I'm setting my cookies like this:
 
 setcookie (authenticate_ck, $daysRemaining); //set cookie for
 active account, for 30days
 
 setcookie (login_ck, $lo, time()+ 60*60*24*30, , , 0);
 //set cookie for login, for 30days

You're quoting all sorts of things that shouldn't be.  The above should read:

  setcookie (authenticate_ck, $daysRemaining); //set cookie for active account, for 
30days

  setcookie (login_ck, $lo, time()+ 60*60*24*30, , , 0); //set cookie for login, 
for 30days

Cheers!

Mike

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

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



RE: [PHP] umask() and chmod()

2004-04-15 Thread Ford, Mike [LSS]
On 15 April 2004 17:26, David T-G wrote:

 Mike, et al --
 
 ...and then Ford, Mike   [LSS] said...
 %
 % On 15 April 2004 16:26, David T-G wrote:
 %
 %  but chmod() needs a permissions setting rather than a umask. % 
 %  The challenge is in representing this as octal.  With some ...
 %  to feed to chmod() -- and apparently I can't just % 
 %$r = 0.$r ;
 %
 % That would be
 %
 % $r = '0'.$r;
 
 Hmmm...  OK.
 
 
 %
 % I'm not sure, however, that this is a totally foolproof way
 of doing it, as
 % it would fail with any permission set (however unlikely)
 where the owner
 
 Would it?  Suppose I were setting it to 007; that would be 0007 with
 the leading zero and should still be fine.

No.  The way you're building it, $r would be an integer before you add the leading 
zero -- 007 would thus be represented as just 7, and adding the leading zero the way 
I've shown above would give '07'.  Not good.

 
 
 % odgit was a zero -- perhaps you should be sprintf()-ing it?
 
 Heck, I'll take any advice I can get :-)  I think, though, that the
 problem is that I'm trying to use a string -- if I can get it built
 correctly in the first place -- as an octal digit.

Possibly, but I think you're making the whole thing more complicated than it need be.  
After a quick look at the manual, I'd suggest this:

   $u = umask();  // Integer value of umask -- no need to convert
  // to octal representation as that's just a human
  // convenience of no value to your computer ;)
   $m = 0777; // $m is now an integer corresponding to octal
  // 0777 again, the visual representation of this
  // in octal (or binary, or hex...) is just a
  // human convenience.
   $r = $m ^ $u;  // remove bits set in $u from $m (subtract should
  // work too, but since this is technically a
  // bitwise operation, I prefer the bitwise
  // operator!
   // $r is now the correct value, and just needs representing in octal:
   $r = sprintf('%04o', $r);
   // Done -- use it as you wish.

Of course, I've been quite verbose there -- the short version is:

  $r = sprintf('%04o', 0777 ^ umask());

... ;))

Cheers!

Mike

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

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



RE: [PHP] umask() and chmod()

2004-04-15 Thread Ford, Mike [LSS]
On 15 April 2004 16:26, David T-G wrote:

 Hi, all --
 
 When I move_uploaded_file() a file into place, I want to give it the
 correct permissions; by default they are 600 (rw-/---/--).  I already
 have the umask set correctly for any given situation in
 anticipation of
 creating directories, and that works for creating files from scratch,
 but chmod() needs a permissions setting rather than a umask.
 
 The challenge is in representing this as octal.  With some
 mucking around
 I was able to print
 
   $u = decoct(umask()) ;
   $m = 0777 ;
   $r = decoct($m) - $u ;
   print The setting is $r\n ;

I've just re-read this properly, and realised you want to feed the end value to 
chmod() -- so all the guff about octal representations is a complete red herring.  
What you want to feed to the 2nd parameter of chmod() is just:

0777 ^ umask()

Within the computer, the value is just an integer, and that's what umask() provides 
and what chmod() expects for its 2nd argument -- so no conversions required.  Even 
0777 is an integer -- it's just a different way of representing 511 which is more 
understandable to us poor humans in that context.

Your original offering was, in fact, barking up the wrong tree -- what it was printing 
out, although it looked right, was the *decimal* value 664, which in octal would be 
01230 and really not what you want.

I guess what this boils down to is that integers are just integers when you manipulate 
them in your script -- octal, decimal, hex and any other representations are just 
convenient notations for making them more human readable.

Cheers!

Mike

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

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



RE: [PHP] Re: Need help

2004-04-14 Thread Ford, Mike [LSS]
On 09 April 2004 16:39, Strogg wrote:

[snip original problem for which a fix has been posted]

   $taxrate = 0.175;  //local tax rate in UK is 17.5%

You should note that UK VAT is always rounded *down*, so that this:

   $totalamount = $totalamount * (1 + $taxrate);

should be something like:

$totalamount += round($totalamount*$taxrate-0.00499, 2);

or:

$totalamount += floor($totalamount*taxrate*100)/100;

Cheers!

Mike

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

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



RE: [PHP] Finding value in multi-dimensional array - Solved

2004-04-14 Thread Ford, Mike [LSS]
On 10 April 2004 02:21, Verdon Vaillancourt wrote:

 Hi,
 
 Thanks much to Richard and Andy for the input :)  This one
 did the job...
 
 if($_SESSION['OBJ_user']-modSettings['listings']['active'] == '1') {
 
 I'm still not entirely sure I understand the syntax ;)

Well, by relating back to your print_r() and building up the syntax by stages, you can 
see that $_SESSION['OBJ_user'] is... 
 
   phpws_user Object

... an OBJECT (of class phpws_user), with a property of ($_SESSION['OBJ_user']-)...

   (
 [modSettings] = Array

... modSettings ($_SESSION['OBJ_user']-modSettings) which is an ARRAY 
($_SESSION['OBJ_user']-modSettings[]), which has a subscript (or key) of...

 (
 [listings] = Array

... 'listings' ($_SESSION['OBJ_user']-modSettings['listings']), which is in turn an 
ARRAY ($_SESSION['OBJ_user']-modSettings['listings'][]), which has a subscript of...

 (
 [active] = 1

... 'active' ($_SESSION['OBJ_user']-modSettings['listings']['active']).  TaDa!

HTH.

Cheers!

Mike

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

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



RE: [PHP] Most bizarre date problem ever

2004-04-14 Thread Ford, Mike [LSS]
On 10 April 2004 16:11, Brian Dunning wrote:

 Check this out: I'm returning a list of the last 30 days, looping
 through i, subtracting it from $end_date where $end_date is 2004-04-10
 00:00:00. I'm just trying to derive a timestamp $check_date for each
 iteration, like 1081321200. Here's the code within the loop:
 
 $check_date = mktime(0, 0, 0, substr($end_date, 5, 2),
 substr($end_date, 8, 2) - $i, substr($end_date, 0, 4), -1);
 
 Note that this works PERFECTLY for every date, and always has. Except
 for one particular day. When $end_date - $i is supposed to be
 April 4,
 the timestamp returned is -7262, which it thinks is 12/31/1969.

This looks like a Daylight Savings timeshift bug on your system (and there are more of 
those around than you can shake a stick at!).  Because of such problems, you should 
never use a time anywhere near the DST hour-change when you are calculating 
consecutive dates, and most especially not a time that could conceivably be shifted 
into the adjacent day (i.e. 00:00-00:59) -- always use something squarely in the 
middle of the day, such as midday:

   $check_date = mktime(12, 0, 0, substr($end_date, 5, 2), substr($end_date, 8, 2) - 
$i, substr($end_date, 0, 4), -1);

Cheers!

Mike

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

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



RE: [PHP] Session confusion again :( - Thanks!

2004-04-14 Thread Ford, Mike [LSS]
On 14 April 2004 17:40, BOOT wrote:

 Any help with this would be appreciated. the p and v lnames are
 posted from a form. In the form, the user seperates last names with a
 /. What I can't understand is why Test1 shows as nothing, while
 Test2 shows the value I wanted. Thanks a lot!
 
 
 $p_lnames= explode(/, $p_lnames);
 
 
 $_SESSION['element_countp'] = count($p_lnames);
 
 
 echo TEST 1.$element_countp;

Because here, you haven't assigned anything to $element_countp -- you've
only assigned it to $_SESSION['element_countp'].  (With register_globals
Off, the two are not the same.)  If you turned your error_reporting level up
to E_ALL, you'd probably get a warning at this point saying that
$element_countp is undefined.

 
 
 $element_countp = $_SESSION['element_countp'];
 
 
 echo TEST 2.$element_countp;

Now you've assigned a value to $register_countp, so you get it output.

Cheers!

Mike

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

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



RE: RE: [PHP] Validating form field text input to be a specific v ariable type

2004-04-07 Thread Ford, Mike [LSS]
On 07 April 2004 03:03, [EMAIL PROTECTED] wrote:

  From: Merritt, Dave [EMAIL PROTECTED]
  
  Okay seems to makes sense, but when I do the following it doesn't
  appear to be working correctly, or I'm viewing my logic incorrectly
  one: 
  
  if ( (int)$PageOptions['Default'] == $PageOptions['Default'] ) {
 
 This works:
 
 if(strcmp((int)$PageOptions['Default'],$PageOptions['Default'])==0)

This does too:

  if ((string)(int)$PageOptions['Default'] === $PageOptions['Default'])

Cheers!

Mike

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

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



RE: [PHP] warning:supplied argument to mysql_fetch_array not vali d resource type?

2004-04-07 Thread Ford, Mike [LSS]
On 07 April 2004 15:56, Andy B wrote:

 i have this query set:
 $EditQuery=select * from $EventsTable where Id='$edit';
 $query=mysql_query($EditQuery)||die(mysql_error());

Don't use || for this, use or -- they have different precedence, and it *matters*.

 //later in the code i have this:
 while($old=mysql_fetch_array($query)){
 //do stuff
 }

Cheers!

Mike

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

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



RE: [PHP] Validating form field text input to be a specificvariab le type

2004-04-07 Thread Ford, Mike [LSS]
On 07 April 2004 15:48, William Lovaton wrote:

 I guess that works but every possible solution posted in this thread
 is a lot of lines of code to perform a simple validation.

Uh -- how are:

  if(strcmp((int)$PageOptions['Default'],$PageOptions['Default'])==0)

  if ((string)(int)$PageOptions['Default'] === $PageOptions['Default'])

a lot of lines of code?

Cheers!

Mike

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

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



RE: [PHP] Array_keys problem

2004-04-06 Thread Ford, Mike [LSS]
On 04 April 2004 01:13, Robin 'Sparky' Kopetzky wrote:

   function key_exists($ps_key)
   {
   if ( in_array($ps_key,
 array_keys($this-ma_arguments)) ) {
 return true;
  } else {
 return false;
  }
   }

Ummm --

   function key_exists($ps_key)
   {
  return array_key_exists($ps_key, this-ma_arguments);
   }

?

(Assuming it's passed the is_array() test, of course!)

Cheers!

Mike

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

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



RE: [PHP] Header Redirect POST

2004-03-26 Thread Ford, Mike [LSS]
On 25 March 2004 20:17, Chris Thomas wrote:

 I am not sure if this was designed like this, or if its just
 something im doing wrong.
 
 Im posting some data to a processing page, where i handle it then use
 Header('Location: other.php') to direct me to another page.
 
 The problem that im running into is that the posted data is available
 in other.php.
 I would like to get it so that in other.php $_POST  should be
 an empty array

At a guess, you're using Apache and it's doing an internal redirect because you've 
used a relative pathname (so the file must be in the same document root!); in this 
case, Apache just does a silent internal substitution of the redirect page, and all 
data associated with the context will remain intact -- there is no round-trip back to 
your browser.

If you use an absolute URL in the Location: header, Apache will return the redirect to 
your browser -- and because your browser now knows it's a genuine new request, the 
POST data is not resent.

The trick is to look at the URL appearing in your browser's address bar -- if it stays 
as the originally requested address, Apache did an internal redirect; if it changes to 
the redirect address, it was an external redirect which round-tripped to your browser.

Cheers!

Mike

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

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



RE: [PHP] $_POST not working with str_replace

2004-03-26 Thread Ford, Mike [LSS]
On 24 March 2004 22:28, PHP Email List wrote:

 And ? #2 are there any settings within PHP that would limit
 my ability to
 visually display the contents of a POST variable on a .rtf document as
 opposed to being displayed on the browser?

Yes -- take a look at the variables_order directive 
(http://uk.php.net/manual/en/configuration.directives.php#ini.variables-order) -- it's 
not immediately clear from its description that this is a relevant setting, but on the 
Predefined variables page 
(http://uk.php.net/manual/en/language.variables.predefined.php), the last sentence in 
the first section (just above the PHP Superglobals heading) says:

   If certain variables in variables_order are not set, their appropriate PHP 
predefined arrays are also left empty.

It's clear from this that if your variables_order setting does not include P, the 
$_POST array will not be populated in your scripts.

HTH

Cheers!

Mike

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

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



RE: [PHP] login problem fixed!!

2004-03-25 Thread Ford, Mike [LSS]
On 25 March 2004 09:32, Andy B wrote:

 the final line then is: if($result==false) {//test the query
 itself..if false then 
 print whatever
 } else {//if it did work then do this...}
 
 but of course it could always be turned around to:
 if($result==true) {...} but dont know what way is better or
 if it is a personal choice...

Well, which way round you do it is pretty much personal preference, but on a more 
general note whenever you find yourself writing a test like $x==true or $x==false, you 
should stop and rethink it because there's something wrong.

Either:

(a) you should be using the === operator, because it matters whether the value is 
actually a Boolean true or false, and not just some other non-Boolean value that is 
taken as equivalent to true or false.

Or:

(b) you are writing inefficent and less readable code. Consider what happens in the 
following cases:

  (i)  if ($x==true)
   - PHP retrieves the value of $x and converts it to Boolean
   - compares it to the Boolean value true
   - if it was true uses, er, true; if not, uses false
  (ii) if ($x)
   - PHP retrieves the value of $x and converts it to Boolean
   - and uses it

Why go to the trouble of forcing PHP to do a comparison just to produce the value it 
had already thought of, when you can just use it as is?

The scenario is similar with if ($x==false), except that the alternative if(!$x) (if 
not x) performs a nice efficient Boolean not instead of the more expensive comparison.

This lean, mean approach also tends to lead to better variable naming, and code which 
is readable in a more natural fashion; for example:

   if ($is_raining) open_umbrella();

is closer to the natural if it's raining, open your umbrella than:

   if ($raining==true) open_umbrella();

/rant ;)

Cheers!

Mike

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

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



RE: [PHP] session_register vs. $_SESSION superglobal

2004-03-24 Thread Ford, Mike [LSS]
 -Original Message-
 From: Kim L. Laage [mailto:[EMAIL PROTECTED] 
 Sent: 24 March 2004 10:52
 
 Once again, thanks for the replies...
 
 But I'm afraid I'm not getting this right... I've tested with 
 the various
 versions of $_SESSION syntax which I've been recommended by 
 the people on
 this group. i.e.:
 $_SESSION['s_user'] = $_POST['s_user'];
 $_SESSION['s_pass'] = $_POST['s_pass'];

Those assignments look good.
 
 or
 
 $_SESSION['s_user'] = s_user;
 $_SESSION['s_pass'] = s_pass;

So do those (assuming you want the value of the s_user session variable to
be s_user and the s_pass session variable to be s_pass!).
 
 None of this seems to really make a difference I was 
 wondering if this
 was due to the nature of the array being used...
 If I understand you right
 session_register(s_user);
 session_register(s_pass);

Don't do that. If you're using the $_SESSION[] array, you shouldn't use
session_register() (or any of its friends such as session_unregister(),
session_is_registered(), etc.).  Just assign values to the $_SESSION[]
array, and test its elements directly with, e.g., isset().

 adds the values s_user and s_pass to an array, I suppose 
 by index so the
 key/value pairs would look like this 0/s_user and 
 1/s_pass - correct?

No.  If anything, these would give you $_SESSION['s_user']==NULL and
$_SESSION['s_pass']==NULL -- but, like I said, just don't bother.
Effectively, $_SESSION[] *is* your session -- assigning a value to an
element of $_SESSION implicitly registers that elements key as a session
variable.
 
[...]

 As I said I'm not getting any real headway here, so I've 
 posted the relevant
 pages below in the hope that someone had the time and 
 inclination to take a
 look at them.
 I've added a few comments of my own and removed the MySQL 
 credentials 8-)
 
 
 --- START session.php START ---
 ?php
 session_start();
 
 include(_include/loginFunc.php);
 
 /* ==
 * When we got this code, it looked like this:
 *
 * session_register(s_user);
 * session_register(s_pass);
 *
 * ===
 */
 $_SESSION['s_user'] = s_user;
 $_SESSION['s_pass'] = s_pass;

Using $_SESSION{}, you don't need an equivalent of session_register(), so
just forget these lines.
 
[...]

 ?php
 # generic stuff
 /* =
  * Password and  Username directly in the code?!?!?
  *
  * I commented on this earlier in the thread, but I would like to
  * your comments on this... personally I think it's a terrible way
  * of handling security!
  *
  * =
 */

I agree with that.  I'd definitely set these up in an include file which is
*outside* the Web server hierarchy (or alternatively in my database, or a
config file which I fread).
 
 $LOGIN_INFO = centerLOGIN/center;
 $HEADER = ADMIN;
 $USER = admin;
 $PASS = admin;
 $WIDTH = 600;
 $logout_text = centerh3You have now logged out from the Admin
 Application/h3/center;
 $login_page = adminHome.php;
 
   #-#
   # login functions #
   #-#
 
 function checklogin($s_user, $s_pass)
 {
   global $USER,$PASS;
   if($s_user == $USER  $s_pass == $PASS)
 return OK;
   else
 return 0;
 }

Ugh!  Any function which returns a straight yes/no value should return
Boolean TRUE or FALSE, since that's what those are designed for.  The above
could then be written much more simply as:

   return ($s_user == $USER  $s_pass == $PASS);

[...]

 function dologout()
 {
  global $logout_text,$login_page;
   session_destroy();

I'd add a session_write_close() here, I think.

   echo $logout_text;
   echo a href='$login_page'centerh3Log in/h3/center/a;
 }
 
 function dologin($user,$pass)
 {
   global $s_user, $s_pass;
   if($user  $pass)
   {
 $s_user = $user;
 $s_pass = $pass;
   }

I can't see anywhere in what you've posted that you assign *real* values to
$_SESSION['s_user'] and $_SESSION['s_pass'], so I assume that's what's
supposed to be happening here -- so these two lines should be:

$_SESSION['s_user'] = $user;
$_SESSION['s_pass'] = $pass;

Incidentally, you also don't seem to unpack $user and $pass from the
$_POST[] array, so either you're running with register_globals=On (bad) or
these variables will be undefined (also bad!).  In any case, I'd probably
prefer to access the $_POST[] array directly, and write something like:

if (@$_POST['user']  @$_POST['pass']):
   $_SESSION['s_user'] = $_POST['user'];
   $_SESSION['s_pass'] = $_POST['pass'];
else:
   ...
endif;
   
Which makes it pellucidly clear what's going on (and also eliminates the
need for the ugly global statement).

I also notice you appear to have variables called $USER and $user, as well
as $PASS and $pass.  This is *terrible* programming style -- differentiating
purely by case is a disaster waiting to happen, and should be avoided by
renaming one of each pair appropriately.

Hope this 

RE: [PHP] $_POST not working with str_replace

2004-03-24 Thread Ford, Mike [LSS]
 -Original Message-
 From: PHP Email List [mailto:[EMAIL PROTECTED] 
 Sent: 24 March 2004 00:13
 
 
 what happens if you do the following?
 
 ?php
 
 $name = $_POST['FNAME'];
 
 echo ::$name::;
 
 $output = str_replace(FNAME, $name, $output);
 
 ?
 
 ??
 
 I tried that, but I know I can get the values from the $_POST 
 array as per John's email about using print_r($_POST) to see 
 what was showing. And yes I get the value I wanted in between 
 the :: ::.
 
 Thanks for trying though,
 
 Anyone else have any ideas on this problem?

OK, if $name is ok, what's in $output at this point?  Try var_dump()-ing that.

Cheers!

Mike

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

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



RE: [PHP] looping variables from a file

2004-03-24 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ryan A [mailto:[EMAIL PROTECTED] 
 Sent: 24 March 2004 17:30
 
 Hi,
 I have a config_inc.php file which has around 60 parameters set in it.
 eg:
 $db_name=something;
 $db_user=root;
 $db_pass=blah;
 $x_installed_path=/home/blah/;
 etc
 
 I have a requirment of echoing out these statements to the 
 client to show him how his setup is:
 
 eg:
 echo DB_name=font color green.$db_name./font;
 
 if I was getting variables via a POST or a GET I would use 
 something like
 this:
 
 foreach ($_POST as $key = $val)
 { echo $key=font color green $value /font;}
 
 as you can imagine the above loop will save a crapload of 
 time instead of partially hard codeing each key and value 
 but how do I do this while reading from a file? and the other 
 big problem is the file contains one or two arrays...

One possibility, if you're able to change the format of the config_inc file
without causing too much havoc, would be to write it something like this:

$CONFIG = array(
  'db_name' = 'something',
  'db_user' = 'root',
  'db_pass' = 'blah',
  'x_installed_path = '/home/blah/',
  ...
);

Then you have your array all neatly set up for you.  (And you can always
extract($CONFIG) whilst you convert all your other usages to $CONFIG[]...!!)

I do like John Holmes's solution, though!

As far as the arrays-within-the-array goes, this sounds like a perfect setup
for a recursive procedure.  If you write it to emit, say, an unordered list,
then each recursive call will produce a nested list and, hey presto!, you've
got nicely structured output too.

Cheers!

Mike

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

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



RE: [PHP] Peculiar number_format() behaviour

2004-03-22 Thread Ford, Mike [LSS]
On 22 March 2004 10:31, Paul Hopkins wrote:

 Here's the code:
 
 ?php
 $a = 676.6;
 $b = 0.175;
 
 $y = $a * (1 + $b);
 echo(y:  . $a .  * (1 +  . $b . ) = $yBR);
 
 $z = $a + ($a * $b);
 echo(z:  . $a .  + (  . $a .  *  . $b . ) = $zBR);
 
 echo(number format(y)=.number_format($y, 2).BR);
 echo(number format(z)=.number_format($z, 2).BR);
  
 
 
 Here's the output:
 
 y: 676.6 * (1 + 0.175) = 795.005
 z: 676.6 + ( 676.6 * 0.175) = 795.005
 number format(y)=795.01
 number format(z)=795.00

This is because of the inherent minor imprecision in the way floating point numbers 
are represented in a computer -- please see the big fat note headed Floating point 
precision at http://www.php.net/manual/en/language.types.float.php.  You should never 
rely on the absolute accuracy of floating point numbers -- even very simple 
calculations can be off by an infinitesimal but nonetheless significant amount (for 
example, 10.0/3*3 almost never equals 10.0 ;).

Cheers!

Mike

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

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



RE: [PHP] Decoding a URL without decoding values

2004-03-22 Thread Ford, Mike [LSS]
On 21 March 2004 16:03, Ben Ramsey wrote:

 I've got a querystring that looks like this:
 ?url=http%3A%2F%2Ftest.alpharetta.ga.us%2Findex.php%3Fm%3Dlink
 s%26category%3DRecreation%2B%2526%2BParks%26go.x%3D22%26go.y%3D7
 
 As you can gather, I'm trying to pass a URL to another script
 for some
 processing.  Before I urlencode() the URL and pass it to the query
 string, it looks like this: 
 
 http://test.alpharetta.ga.us/index.php?m=linkscategory=Recrea
 tion+%26+Parksgo.x=22go.y=7 
 
 As you can see, there are already encoded entities in the
 URL, which are
 further encoded when passed through urlencode().  The problem
 I'm having
   is that when I urldecode() the string from $_GET[url], I get the
 following string: 

Don't.  GET values are automatically urldecoded once by the Web server
before they ever reach your script.

Cheers!

Mike

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

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



RE: [PHP] Simple: Whats wrong with this?

2004-03-18 Thread Ford, Mike [LSS]
On 17 March 2004 17:09, Chris W. Parker wrote:

 
 $var++ is a post incrementer meaning the value is updated at the next
 command*.

 * i'm not exactly sure how the compiler determines when to post
 increment, but i think i'm correct.

Not quite -- the increment is performed immediately after the access -- in
fact, as part of the same operation.  So:

$x = 3;
$y = ($x++ * 2) + $x;

is likely to give you $y==10, not 9.

(I say is likely to, because you don't have any absolute cast-iron
guarantees that a compiler won't, if it thinks it has good reason, commute
the above to $x + ($x++ * 2), which would give you $y==9!  In general, it's
best to regard the value of a pre- or post-incremented variable as uncertain
in the rest of the expression containing it.)

Cheers!

Mike

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

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



RE: [PHP] Changes in php.ini have no effect

2004-03-16 Thread Ford, Mike [LSS]
On 16 March 2004 15:10, Harry Sufehmi wrote:

 Problem:
 Changes made in c:\winnt\php.ini doesn't have any effect even after
 restarting Apache. 
 
 Steps tried:
 # looking for other copies of php.ini - none found
 # entering the related values in Apache's httpd.conf file
 instead - works for some values, but not for others.
 # entering the related values in Apache's .htaccess file - doesn't
 work at all 
 
 PHP version: 4.3.3
 phpinfo() output - http://www.harrysufehmi.com/inf.php
 
 If you at the output of phpinfo(), it stated that the
 configurations were read from c:\winnt\php.ini

No, it actually states:

Configuration File (php.ini) Path  C:\WINNT

which means that it's looking in C:\WINNT for your php.ini file, but hasn't
found one -- if it found a php.ini there, that line would have read:

Configuration File (php.ini) Path  C:\WINNT\php.ini

As you're on Windows, my guess is that the old hidden extension trick is in
play and you've actually got a file called something like php.ini.txt -- try
turning off the Windows option that hides recognised extensions, and taking
another look.

Cheers!

Mike

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

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



RE: [PHP] Changes in php.ini have no effect

2004-03-16 Thread Ford, Mike [LSS]
On 16 March 2004 19:01, Harry Sufehmi wrote:

 On 16/03/2004 at 18:18 Ford, Mike [LSS] wrote:
  On 16 March 2004 15:10, Harry Sufehmi wrote:
   Problem:
   Changes made in c:\winnt\php.ini doesn't have any effect even
   after restarting Apache. 
   
   PHP version: 4.3.3
   phpinfo() output - http://www.harrysufehmi.com/inf.php
   
   If you at the output of phpinfo(), it stated that the
   configurations were read from c:\winnt\php.ini
  
  No, it actually states:
 Configuration File (php.ini) Path  C:\WINNT
  which means that it's looking in C:\WINNT for your php.ini file,
  but hasn't found one -- if it found a php.ini there, that line
 would have read: Configuration File (php.ini) Path 
  C:\WINNT\php.ini 
  As you're on Windows, my guess is that the old hidden extension
  trick is in play and you've actually got a file called something
  like php.ini.txt -- 
 
 Good one but I just checked (from command prompt) and
 indeed php.ini is there (not php.ini.txt), double-checked as
 well just to make sure.

H'm!  Permissions problem?

Cheers!

Mike

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

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



RE: [PHP] use of @ operator to suppress errors

2004-03-15 Thread Ford, Mike [LSS]
On 15 March 2004 12:12, Stuart wrote:

 Ben Joyce wrote:
 
 On the contrary, the @ prefix suppresses all errors for the block of
 code it precedes where a block is a function or variable. Essentially
 it sets error_reporting to 0 while it evaluates that block.

In fact, to be completely accurate, @ is an operator and suppresses error in
the *expression* to which it applies -- this means you can affect what it
applies to by using parentheses.

Cheers!

Mike

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

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



RE: [PHP] If Using PHP CLI to Query Oracle8I DB, is Version Numbe r Critical?

2004-03-11 Thread Ford, Mike [LSS]
 -Original Message-
 From: Martin McCormick [mailto:[EMAIL PROTECTED] 
 Sent: 10 March 2004 21:31
 To: [EMAIL PROTECTED]
 Subject: [PHP] If Using PHP CLI to Query Oracle8I DB, is 
 Version Number Critical?
 
 
   We use PHP 4.3.4 (cli) to query a Microsoft SQL 
 database server with no problem.  We are now going to attempt 
 the same sort of thing, only with a Pinnacle server running 
 an Oracle8I data base.
 
   The php installation is on a FreeBSD UNIX platform and 
 the Pinnacle server is on a Windows platform.
 
   Being very new to all this, my question is simply 
 whether or not this should work?  I am concerned that php 
 comes with an Oracle7 client, but the data base I need to 
 query and write back to is Oracle8I which might, someday, 
 upgrade to a higher version.

For an Oracle 8i database you want the OCI extension, not the Oracle
extension.  OCI should be the extension of choice for Oracle version 7 and
later.

   If I am using the PHP CLI to extract data from the 
 server with, of course, correct syntax, does the Oracle 
 version even matter?

No, not as long as it's supported by the extension you use.  OCI should be
fine for Oracle 8i and subsequent versions -- there have certainly been
users of 9i posting to this or the PHP-DB list.

Cheers!

Mike

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

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



RE: [PHP] $_GET, expressions and conditional statements

2004-03-11 Thread Ford, Mike [LSS]
 -Original Message-
 From: Jason Wong [mailto:[EMAIL PROTECTED] 
 Sent: 11 March 2004 14:19
 
 On Thursday 11 March 2004 21:15, I.A. Gray wrote:
 
What I want the 
  script to do is set $SPORDER to this value.  If 
 $_GET['ORDER'] is not 
  set then it gets the default value (ASC), if this is any other than 
  ASC, DESC or RAND (ie. someone has messed with the variables in the 
  URL) then it also gets the default (ASC). Finally if 
 $_GET['ORDER'] is 
  set to RAND then I want $SPORDER to equal RAND() so that I 
 can use the 
  value in the SQL query.
 
 Try something like:
 
   if (isset($_GET['ORDER'])) {
 switch ($_GET['ORDER']) {
   case 'ASC'  :
   case 'DESC' :
   case 'RAND' :
 $SPORDER = $_GET['ORDER'];
 break;
   default :
 $SPORDER = 'ASC';
 }}
   else {
 $SPORDER = 'ASC';
   }

Or even:

switch (@$_GET['ORDER']):
  case 'ASC':
  case 'DESC':
$SPORDER = $_GET['ORDER'];
break;
  case 'RAND':
$SPORDER = 'RAND()';
break;
  default :
$SPORDER = 'ASC';
endswitch;

(which, I think, also gives the requested result for 'RAND').

Cheers!

Mike

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

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



RE: [PHP] Return value efficiency question

2004-03-10 Thread Ford, Mike [LSS]
On 10 March 2004 13:48, Burhan Khalid wrote:

 Kelly Hallman wrote:
  Consider this method:
  
  function xyz() {
  return $this-data = unserialize($this-serial); }
  
 
 Maybe I'm just being stupid, but wouldn't that simply return true if
 the assignment was successful, and false otherwise?

Nope.  The value of an assignment expression is the value assigned, so that
will return whatever was assigned into $this-data.

Cheers!

Mike

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

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



RE: [PHP] absolute path

2004-03-08 Thread Ford, Mike [LSS]
On 08 March 2004 14:00, Mike Mapsnac wrote:

 I'm looking for PHP function that takes $filename as
 parameter and returns
 absolute path.
 
 I looked on php.net but cannot find such function. Any ideas if such
 function exist? 

How about http://www.php.net/realpath ?

Cheers!

Mike

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

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



RE: [PHP] PHP Sessions - Cookies Not Saving

2004-03-05 Thread Ford, Mike [LSS]
On 05 March 2004 03:33, Paul Higgins wrote:

 When I do:  print_r($_COOKIE); I get the following:
 Array ( [PHPSESSID] = 11781ce29c68ca7ef563110f37e43f38 )
 
 Does that mean its setting the Cookie?

Yes.

Cheers!

Mike

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

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



RE: [PHP] ASCII

2004-03-05 Thread Ford, Mike [LSS]
On 05 March 2004 16:02, csko wrote:

 Hi!
 Is there a function to convert a ASCII char to decimal or binary? Or
 a program? 
 
 csko

http://www.php.net/ord

Cheers!

Mike

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

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



RE: [PHP] php session ID attached to URL

2004-03-04 Thread Ford, Mike [LSS]
On 04 March 2004 10:25, matthew oatham wrote:

 Hi,
 
 I have a quick question about PHP session. In my website I
 have included the command session_start(); at the top of
 every page. Firstly is this correct?

Yes (sort of).  The real deal is that session_start() has to occur before you start 
sending any actual content -- if you have, say, a lot of initialization logic, this 
could actually be quite a long way into your script.

  Secondly when I visit
 the website the first link I click on has the php session ID
 appended to the url however this php session ID is not
 appended to subsequent links ! Is this correct behaviour?

Yes.  It's simply the nature of cookies that it takes at least one round trip to the 
server to work out if you have them enabled -- and on that trip, the only way to 
propagate the session id is to pass it in the URL.

 What is going on? Can anyone explain?

On your initial visit to the site, you will not have a session-id cookie set, so PHP 
doesn't know if you have cookies enabled or not.  When you first click a link, 
therefore, the session id is appended to the URL, *and* a session-id cookie header is 
sent.  On the next (and subsequent) clicks, the cookie will be received from your 
browser, PHP knows you have cookies enabled, and therefore relies on the cookie and 
does not add the session id to the URL.

Cheers!

Mike

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

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



RE: [PHP] convert a strtotime date into a text representation of the date

2004-03-04 Thread Ford, Mike [LSS]
On 04 March 2004 04:37, Andy B wrote:

 hi.
 
 i found strtotime and it seems to work but not quite sure if i know
 how to use it right... here is my code:
 ?php
 $time= strtotime(third saturday january 2005);
 echo date(M/D/YY, $time);
  
 
 i wanted it to take the third saturday of next year (2005)
 and say do this: saturday january 24?? 2005 for the output.
 All I get for the output though is sat/june/20092009?? I'm sort of
 confused now... 
 
 any ideas on what the problem is?

Firstly, 'Y' is date()'s format letter for a 4-digit year -- so 'YY' outputs
the 4-digit year twice.  If you want a 2-digit year, the format code is 'y'

Now, on to your more serious problem.  strtotime() won't let you have both
an absolute date and a relative date in the same string -- if you try, the
absolute date alwys seems to take precedence.  So hte 'third saturday'
phrase in your string is completely ignored.

Looking at 'january 2005': a month on its own has no particular meaning to
strtotime(), since valid calendar date formats containing a literal month
name either have the day number in front, or are 'month day year' or 'month
day'.  Only the latter of these fits your string, so we have to consider
'january 2005' as meaning the 2005th day of January, with the current year
being assumed by default; by a quick estimate, the 2005th January 2004 is
roughly 180 days into 2009, or somewhere near the end of June 2009 -- which,
unsurprisingly, is the result you've been getting.

The way to do what you want is in two steps -- first getting an absolute
value for 1-Jan-2005, and then finding the third Saturday from that base
date.  There are probably several valid ways to do this, but here are two
possibilities:

   strtotime('third saturday', strtotime('1 jan 2005'));
   strtotime('third saturday', mktime(12, 0, 0, 1, 1, 2005));

(Note: I strongly advocate using midday-ish as a base time when calculating
relative dates, because of the possible adverse effects of a DST timeshift
intervening if you use anything in the 00:00-03:00 range -- I'm sure dealing
exclusively with January is probably fairly safe in this respect, but
getting into the habit of using 12:00:00 for such calculations is just plain
good practice.)

Cheers!

Mike

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

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



RE: [PHP] Hidden File Upload Limit

2004-03-04 Thread Ford, Mike [LSS]
On 04 March 2004 16:44, Raditha Dissanayake wrote:

 You didn't tell us the error message and you have not
 mentioned if you
 tried LimitRequestBody and max_input_time and max_execution_time.

... or if you restarted the Web server after each change to php.ini.

Cheers!

Mike

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

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



RE: [PHP] IE6 with latest hotfixes breaks forms ...

2004-03-02 Thread Ford, Mike [LSS]
On 02 March 2004 00:04, Marc G. Fournier wrote:

 We're having a weird problem with some of our PHP forms, where, when a
 client uses IE6 with the latest hotfixes, they are reporting
 that have to
 re-submit a couple of times for it to take ... as if
 somehow the data
 isn't being passed down properly to the FORM/ACTION ...
 
 We're using sessions to pass the data around, and it seems to
 work with
 every other browser we've used, including IE6 previous to the latest
 hotfixes ... but, could it be something that *we* aren't
 doing right, or
 is there a known bug with sessions + IE6?  Some sort of work around?

Yes, there are known issues of this sort with the 6-Feb-2004 security
update, and there is a fix posted on the MS Web site -- see
http://support.microsoft.com/default.aspx?scid=kb;en-us;831167Product=ie600
for more info.

Cheers!

Mike

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

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



RE: [PHP] Security Question

2004-02-24 Thread Ford, Mike [LSS]
On 20 February 2004 22:29, Ed Lazor wrote:

 PHP include statements default to the current directory.  If
 the path to
 my PHP files is /home/osmosis/public_html, why would users visiting my
 site occasionally get an error that the include file wasn't found in
 /home/budguy/public_html? 
 
 It's like PHP is somehow confused and running my script with
 the account
 settings (and permissions, possibly) for another user on my host
 provider's server.  If that's true, wouldn't this quality as
 a security
 issue?
 
 They use open_basedir for security.  Isn't that part of PHP?  They're
 running the latest version of PHP (4.3.4).

This looks like http://bugs.php.net/bug.php?id=25753 to me, which has only
recently been marked as fixed and I don't believe has made it into an
official release yet.

Cheers!

Mike

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

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



RE: [PHP] where is my uploaded file ?

2004-02-24 Thread Ford, Mike [LSS]
On 24 February 2004 06:58, adwinwijaya wrote:

 input name=image type=file

 $uploadfile = $uploaddir . $_FILES['userfile']['name'];

 Array
 (
 [image] = Array

Hint: image!=userfile

Cheers!

Mike

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

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



  1   2   3   4   5   6   7   >