Re: [PHP] Validation function doesn't work (sort of...)

2003-05-27 Thread David Grant
Jason Lange wrote:
   for ($i = 0; $i < $vCount; ++$i) {
   if (($cryptUser === $validUser[$i]) &&
   ($cryptPass === $validPass[$i])) {
   $retVal = true;
+	 break;
   } else {
   $retVal = false;
   }
   }
   return $retVal; // return true if valid false otherwise
You MUST call the return function in order to escape from the loop (or 
use a break statement as above), as Jonathan pointed out.

As for the === comparison, I don't believe there is an problem, as will 
ALWAYS return a string.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Validation function doesn't work (sort of...)

2003-05-27 Thread David Grant
Jonathan Wilkes wrote:

That's not his problem, he is using "===" euality check which just checks
the "type" of data, hence his code is returning TRUE for every item in the
array.
http://www.php.net/manual/en/language.operators.comparison.php

Not so -- the identical ("===") comparison operator checks for variable 
type AND variable value equality.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Installation help

2003-05-27 Thread David Grant
Brian Dunning wrote:
I am a lamer & a newbie, and ran the PHP and MySQL installers on my XP 
box, but can't connect to any database and don't see any new processes 
running. Is there someplace I can find documentation for this that is 
optimized for the newbie lamer? Thanks,
May be a stupid question, but have you specifically started MySQL?

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Regexp question...

2003-05-28 Thread David Grant
Andrew D. Luebke wrote:
> OK, here is the regexp command I am trying to use:
>
> $split_filename = preg_split('/\./', $_FILES["userfile"]["name"], 
-1);
>
> However, when I do a count($split_filename) I don't get what I expect.
> For instance if the input is:
>
> abc.xyz.123
>
> I get 2 from count, why doesn't preg_split put three elements in the
> array?  It works since I'm actually looking for the last part of the
> filename.  Thanks for any help.

If you're looking for the file extension, use pathinfo() instead.  To 
actually answer your question, have you tried using print_r() to get the 
contents of the array?

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] My Sincere Request!![Scanned]

2003-05-28 Thread David Grant
Michael Egan wrote:

And what exactly has this got to do with PHP :-)
It's important to know that there are PHP users all around the world, 
including Nigeria!  Perhaps Rev. Dr. Ego Momoh wants someone on the list 
to build him a web site, so he can provide even more information on this 
scam^H^H^H^H business opportunity..

Man... I haven't seen one of these for a while... :)

-Original Message-
From: REV DR EGO MOMOH [mailto:[EMAIL PROTECTED]
Sent: 01 January 1999 17:59
To: [EMAIL PROTECTED]
Subject: [PHP] My Sincere Request!![Scanned]
BRANCH MANAGER, 
UNITED BANK FOR AFRICA PLC 
ILUPEJU BRANCH LAGOS NIGERIA 
ATTN: PRESIDENT/C.E.O 
I am pleased to get across to you for a very urgent and profitable business proposal, though I don't know you neither have I seen you before but my confidence was reposed on you when the Chief Executive of Lagos State chamber of Commerce and Industry handed me yourcontact for a confidential business. I am the manager of United Bank for Africa Plc (UBA),Ilupeju branch, Lagos Nigeria.The intended business is thus; We had a customer, a Foreigner (a Turkish) resident in Nigeria, he was a Contractor with one of the Government Parastatals.He has in his Account in my branch the sum of US 38.6 Million (Thirty Eight Million, Six HundredThousandU.SDollars).Unfortunately, the man died four years ago until today non-of his next of kin has come forward to claim the money. Having noticed this, I in collaboration with two other top Officials of the bank have covered up the account all this while. Now we want you (being a foreigner) to be fronted as one of his next of kin and forward your
account and other relevant documents to be advised to you by us to attest to the Claim. We will use our positions to get all internal documentations to back up the claims . The whole procedures will last only five working days to get the fund retrieved successfully without trace even now or in future.Your response is only what we are waiting for as we have arranged all necessary things. As soon as this message comes to you kindly get back to me indicating your interest, then I will furnish you with the whole procedures to ensure that the deal is successfully concluded. For your assistance we have agreed to give you twenty five percent (25%) of the Total sum at the end of the transaction while 65% would be for my colleagues and I and the remaining 10% would be for any form ofexpenses that may be incurred during the course of the transaction which would be given to us when the money is transferred into your account before splitting the balance on the agreed percentage of 65% t
o 25%. In order to get all the legal documents from the court, kindly send the following information to us immediately. Your full name,telephone,mobile and fax numbers as well as your resident or company address. I await your earliest response. 
Thanks, 
Yours Sincerely 
REV DR EGO MOMOH.





--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] php 4.3.1 / latest

2003-05-28 Thread David Grant
[EMAIL PROTECTED] wrote:

where can i find php (version  4.3.1 or latest ) rpm?
i need to upgrade php on my RHL 8.0 box for its running on 4.2.2 and i
cant use many inbuilt functions.
http://rpmfind.net//linux/RPM/PLD/dists/ra/updates/security/i686/php-4.2.3-9.i686.html

If this is the wrong processor type, just look here:

http://rpmfind.net/linux/rpm2html/search.php?query=php&submit=Search+...

If you must use RPMs :(, look no further that http://rpmfind.net.

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] sessions and domains

2003-05-28 Thread David Grant
bk wrote:
I've to set up a shared shopping cart to buy items
from four different sites and pay them at once
passing trough a single checkout.

Provided that these sites are hosted on the same
server (actually in the same directory), but have
different names, is it possible to share php
sessions across multiple domains? How?


As far as I know, you cannot share a cookie-enabled session object 
between different domains (otherwise what's to stop me reading your 
session?).  Perhaps if you serialize the session object to a 
file/database row using a unique identifier, that might be a way of 
doing it.

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] flawless script

2003-05-28 Thread David Grant
sven wrote:

you can use the default: statement as last case in switch, too.
I always use default: to exit() the script, as something is obviously 
fubar if it gets there...

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Variables don't pass... *sniff*

2003-05-28 Thread David Grant
Leif K-Brooks wrote:

To maintain absolute compatibility, just use $HTTP_GET_VARS.  It's 
availalable in all PHP versions, just deprectaed in versions here $_GET 
is available.
I would've thought that $HTTP_*_VARS will be deprecated sometime in the 
future.  It might be an idea to write your own accessor methods, e.g.

function RetrieveGetParameter($parameterValue)
{
  if (FALSE == is_null($_GET))
  {
 if (FALSE == empty($_GET[$parameterValue]))
 {
   return ($_GET[$parameterValue]);
 }
 else
 {
   return (NULL);
 }
  }
  else
  {
 if (FALSE == empty($HTTP_GET_VARS[$parameterValue]))
 {
   return ($HTTP_GET_VARS[$parameterValue]);
 }
 else
 {
   return (NULL);
 }
  }
}
--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Update to DB

2003-05-28 Thread David Grant
Kalle Saarinen wrote:

Hello,

I was just wondering how to update data to database from html text field.

I have a form that retrieves data from dbase and put's values into text
field in a web page. I want to be able to modify data and then save it dbase
by hitting save button (also form object).
ie.

$sql="SELECT col1 FROM table WHERE id = 1";
$result=mysql_query($sql);
$num = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$var = $row["col1"];
echo "";
echo "";
echo "";

Anyone know what is the proper way to do this?

-Kalle
You need to capture the values passed by the form in the script 
referenced in the form action attribute, using the relevant superglobal 
referenced in the form method attribute (e.g. $_GET or $_POST).

Using your example, you would access the "name" form element like so:

$_POST['name']

Then you should use this variable in an UPDATE or INSERT statement and 
send that to your database server, e.g.:

mysql_query("UPDATE table SET col1 = " . $_POST['name'] . " WHERE id = " 
. $_POST['id'] . " LIMIT 1");

I would suggest reading the PHP manual a little more carefully, in 
particular those sections regarding variable and form handling, as well 
as the section on MySQL.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Variables don't pass... *sniff*

2003-05-29 Thread David Grant
Wendell Brown wrote:
Egads!  Wouldn't the following be a little simpler?

At the top of the file put.

if( is_array($_POST) ) 
  $pArray = $_POST;
else
  $pArray = $HTTP_POST_VARS;
Absolutely!  I've been getting a little carried away with moving a lot 
of PHP functions to OO classes recently...  Damn it!  I must learn to 
simplify a bit more.. :P

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Resending POST Variables

2003-05-29 Thread David Grant
Shaun wrote:

Hi,

I have a page which uses POST variables sent from a form. If a user clicks
on a link on this page is it possible to send those POST variables to the
next page aswell?
You can send them by tagging them to the end of the link, or saving them 
into a session, but you can't (for obvious reasons) access POST 
variables after a GET request.

Just loop through the POST superglobal (i.e. using foreach) and create a 
appending string for your hyperlink.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Parsing html to extract images

2003-05-29 Thread David Grant
Hidrahyl wrote:
Hi,

anyone can help me parsing html files in order to get all the images
containing a file?
Thanks, Simon.

1. Use fopen() to grab the HTML file you're after.
2. Read in each line to an array using file();
3. Loop through the array, and apply the following reg. exp.:
preg_match("/\/U", $line, $matches);

NOTE:  this might need a bit of tweeking, since I'm not too hot on 
regular expressions... :)

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] vpopmail what is it???

2003-05-29 Thread David Grant
Haseeb Iqbal wrote:

hi,
can anyone direct me.i want information about vpopmail  and what is does . a tutorial 
or something will work
thanx in advance. i searched google but got only manual pages of php. but there isn't 
any info there.
Try this:

http://www.pscs.co.uk/products/vpop3/index.html

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] PHP redirect

2003-05-29 Thread David Grant
Awlad Hussain wrote:
Try this
header("LOCATION: page2go.php");
I'm not normally so pedantic, however, the HTTP specification defines 
the above header as "Location", not "LOCATION".  It might also be an 
idea to give the filename as a path relative to the root directory, e.g.

header("Location: /foo/bar/index.php");

This should ensure compatability between user agents.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Help with eval()

2003-05-30 Thread David Grant
zavaboy wrote:

Umm, have you tested it? It didn't work for me...

"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
for ($i = $aNum; eval ('return $i ' . $do . ' $bNum'); )
Untested:

for ($i = $aNum; eval("return (\$i " . $do .  " \$bNum);");)

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Help with eval()

2003-05-30 Thread David Grant
zavaboy wrote:

I get a infinite loop and "parse error, unexpected $"...
Told you it was untested.. :P

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Getting POSTed values from dynamically named checkboxes

2003-05-30 Thread David Grant
Dillon, John wrote:

My problem relates to IF statement in the following code.  There are two
checkboxes, named altid$thisid, so for instance they become altid36 and
altid37.  When the form is submitted with both checked, I can read the first
altid36, but the second does not pass the IF test.  Any suggestions re
possible reasons?
$checkedalts = array();
$x=0;
$y=1;
$array_id = explode(",", $_POST["idlist"]);
foreach($array_id as $thisid){
if(${"altid" . $thisid} == 1){
//OR if(ISSET($_POST["${"altid" . $thisid}"])){
$checkedalts[$x] = $thisid;
$checkedalts[$y] = ${"altprice" . $thisid};
$x=$x+2;
$y=$x+1;
}
}
The HTML before submission is (without the 

Not what you're looking for, but... are you sure you're doing this the 
easiest way?

Try putting your values in an array instead, e.g.

altid[36] and altprice[36]

Then access through:

foreach ($_POST['altid'] as $id => $value)
{
  $price = $_POST['altprice'][$id]
}
Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] generate random

2003-05-30 Thread David Grant
Marius wrote:

  how to generate random number ?
Look no further than rand().  Well, actually do look further because 
srand() is better.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] mail function problem

2003-05-30 Thread David Grant
Bersani Francesco wrote:

Hi, I have a problem with the "mail" function; it always sends mails
assuming in the "from" field the user "[EMAIL PROTECTED]".
I tried to override it with this code:


mail($email, $subject, $message, $headers);

?>
--
It doesn't work...

Can anybody help me ?


Take a peek into php.ini to change the default value.

Note that you should seperate mail headers with \r\n.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] "Email This Story" and "Print" Functions

2003-05-30 Thread David Grant
Jeffrey L. Fitzgerald wrote:

Thanks to Kevin, Monty and the others who helped with my earlier 
post...

Anyone have experience with PHP based "Email This Story" and "Print 
This Story" functions?? I am looking to add these along with a digital 
postcard mailer.

Probably not the answer you're looking for, but a hell of a lot easier:

For print this story, you only need an alternate print stylesheet... 
Look at the CSS spec.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] generate random

2003-05-30 Thread David Grant
Leif K-Brooks wrote:

I reccomend you RTFM!
There's a MANUAL?!  Wow! :)

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] PHP- Converting to and from TIMESTAMPS

2003-05-30 Thread David Grant
Ian Gray wrote:
I am wanting one field on a table in one of my MYSQL databases to contain different dates and times as a epoch timestamps.
You're better off storing as a DATETIME field -- it has limits from 
1000-01-01 to -12-31, instead of 1970 to 2037..

Firstly how do I convert a particular time and date which the user will enter on the website into the epoch timestamp.
You need to use mktime() if you are getting the individual time segments 
(e.g. hour, minute, date, month).

And secondly, how do I convert it back once taken of the table.  I'd like to use the date function to print out this particular date and time- for example $a = date('g:IA l, jS F, Y') so that $a could say '7:30PM Saturday, 23rd August, 2003'  Does date only work by outputting the current date or time?  Can you get it to output the format of any date and time you would like?
The date() function accepts a second parameter, which is a UNIX 
timestamp of your choice.

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Zend Gone missing

2003-05-30 Thread David Grant
Chris Blake wrote:
Any ideas ?
From: http://www.zend.com/install_instruct.php:

To start the ZDE (Zend Development Environment), run the zde in the 
directory where you installed it (typically, /usr/local/Zend/bin)

Looks like you'll have to create your own shortcut (advice on how to is 
beyond the scope of this list).  Perhaps you should write them an e-mail 
detailing your problems?

Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] CR in MySQL?

2003-05-31 Thread David Grant
Dan Joseph wrote:

How do you put a carriage return in a MySQL database and have it 
display as a line break on the web page?


str_replace ("\n", "", $var);

-Dan Joseph

Is CR == NL?  What's wrong with nl2br()?

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] CR in MySQL?

2003-05-31 Thread David Grant
Dan Joseph wrote:

Hi,


str_replace ("\n", "", $var);

-Dan Joseph

Is CR == NL?  What's wrong with nl2br()?


Beats me, is it?  nothing wrong with it I guess, I just didn't know about
that function.
-Dan Joseph


Just did a bit of checking..

NL == ASCII 010, CR == ASCII 015..

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] preg_match array question

2003-05-31 Thread David Grant
Daniel J. Rychlik wrote:

Hey,

Im trying to use preg_match to validate numbers in multiple fields.  I can check one field but Im having trouble checking multiple fields.  

preg_match ( '(foo)' , $_POST["num1"] ); <- That works fine.  but I need to check multiple fields.  

I thought I would build an array with the POST data like this...

$num = array ($_POST["num1"],
($_POST["num2"]);  There are more than that...  

and then use 
preg_match ('(foo)', $num) ;   $num should point to my array, but that doesnt work.  I get a warning message.. and it doesnt check the first num1 in the array.  

Im certain that Its my code, and I wanted to get some input on what Im doing wrong.

-Dan
A quick search turned this up:
http://www.php.net/manual/en/function.preg-grep.php
--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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


Re: [PHP] Error Messages, Windows, and Tequila

2005-11-16 Thread David Grant
Printing error messages to your output can be disabled with the
"display_errors" directive in your php.ini file.  To enable error
printing, the directive should read:

display_errors = On

Cheers,

Dave

Jay Blanchard wrote:
> Hidy-ho good meighbors and neighborettes!
> 
> I continue my, as yet unquenched, fascination with the Windows operating
> system[sic].
> 
> Does anyone know (I have error reporting set so high it would make your head
> swim) why errors wouldn't be output to a browser window when they occur? For
> instance, I typed the following;
> 
> while($doc = odbc_feych_array($dbDocData) // note the misspelling of fetch
> that means I was thinking in wild-west dialect at the time, 'fey-uch'
> 
> An erro went to the Apache log but no error, such as the highly popular
> "syntax erro" was sent to the browser. Alas, a search of Google revealed
> nothing worthwhile, probably because I didn't have the right search term.
> Would someone please shed some light on this?
> 
> Thanks!
> 

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



Re: [PHP] Formatting of a number

2005-11-16 Thread David Grant
Hi Scott,

How do you distinguish between a value filled with zeroes and a value
with 0 in both decimal positions?

For example, why is 3145900 expressed as 3,145.90, and not 31,459.00?

Cheers,

David Grant

Scott Parks wrote:
> Hi-
> 
> I have a number that I am trying to format.  It is data coming from a
> main frame and
> has 8 characters assigned to it (6 and two decimal places).  I have
> zerofill set up in
> MySQL on this field and am working on the best way to display the number.
> 
> Currently I have this:
> 
> $sOutput = number_format(rtrim($sValue,'0') /100,2);
> 
> What I am running into is this, I have a number in this field as:
> 3145900, using the above I will get:  314.59, which is wrong, it
> needs to be 3,145.90.
> 
> Yet, if I have a number of:  749450, I get the result I am looking for
> of 749.45.
> 
> I did not see a way to tell trim I only want one 0 cut?
> 
> Any thoughts?
> 
> Thank you!
> 
> -Scott
> 
> --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] SESSION expiry time setting

2005-11-18 Thread David Grant
Hi Angelo,

You might want:

session.cookie_lifetime = 

Obviously this only has an effect if the session.use_cookies directive
is set to "1".

Cheers,

David Grant

Angelo Zanetti wrote:
> Hi guys.
> 
> I've been searching for where the time is set for a session to expire
> but had little luck.
> 
> in the PHP.ini file I found:
> 
> session.cache_expire
> 
> which specifies the time in minutes but is this what sets the session to
> timeout once the setting time has been surpassed?
> 
> Or am I looking in the totally wrong direction??
> 
> thanks in advance.
> 
> Angelo
> 

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



Re: [PHP] Dynamic DB query - form display

2005-11-18 Thread David Grant
Hi Adrian,

This appears to be a security hole, but since that wasn't the reason for
the question, please try:

echo"";

php.net/htmlentities

Cheers,

David Grant

Adrian Bruce wrote:
> Hi
> 
> I am trying Dynamically creating a Query based on form input for an
> intranet, i have a text input that allows a user to input part of a
> where clause such as  - not like '04%' - . this bit works fine but i
> would like to display the clause back in the form field when the page
> reloads.
> $clause = "not like '04%'";
> echo"";
> 
> Now obviously i hit a problem with the use of 'the quotation marks ' ' 
> and just see - not like \  - in the form field.  I need to keep the '
> marks around the 04% for the query.  Any ideas how i can do this??
> 
> Any help much appreciated!
> 
> Adrian
> 

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



Re: [PHP] Dynamic DB query - form display

2005-11-18 Thread David Grant
Hi Adrian,

You can still use the text input, but you must ensure that the input is
filtered first.  There is a wealth of information on SQL injection and
its prevention on the Internet.  Try these for starters:

http://shiflett.org/articles/security-corner-apr2004
http://dev.mysql.com/tech-resources/articles/guide-to-php-security-ch3.pdf

Cheers,

David Grant

Adrian Bruce wrote:
> 
> I'm aware it would be a security hole if it were available to all users,
> but it's just for me at the mo, other users get a watered down version
> with just check  boxes. I basically want to allow flexible filtering of
> a set of data but obviously this poses a few challenges, any ideas
> always weclome!
> 
> Thanks for the tip by the way,  i ended up doing the following
> 
> $field = stripslashes(htmlentities($field,ENT_QUOTES));
> 
> Adrian
> 
> David Grant wrote:
> 
>> Hi Adrian,
>>
>> This appears to be a security hole, but since that wasn't the reason for
>> the question, please try:
>>
>> echo"";
>>
>> php.net/htmlentities
>>
>> Cheers,
>>
>> David Grant
>>
>> Adrian Bruce wrote:
>>  
>>
>>> Hi
>>>
>>> I am trying Dynamically creating a Query based on form input for an
>>> intranet, i have a text input that allows a user to input part of a
>>> where clause such as  - not like '04%' - . this bit works fine but i
>>> would like to display the clause back in the form field when the page
>>> reloads.
>>> $clause = "not like '04%'";
>>> echo"";
>>>
>>> Now obviously i hit a problem with the use of 'the quotation marks '
>>> ' and just see - not like \  - in the form field.  I need to keep the '
>>> marks around the 04% for the query.  Any ideas how i can do this??
>>>
>>> Any help much appreciated!
>>>
>>> Adrian
>>>
>>>   
>>
>>  
>>

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



Re: [PHP] another simple array question

2005-11-18 Thread David Grant
if (isset($values[4])
unset($values[4]);

Cheers,

David Grant

cybermalandro cybermalandro wrote:
> I have an array with indexes 0 to 4 and I want to delete an element of the
> array if the index is equals 4. I want to delete the variable key and value.
> What is the best way to do so?
> 
> foreach ($values as $key => $val){
> 
> if ($key == "0") {
> //
> }
> if ($key == "3") {
> //
> }
> if ($key == "4") {
> //delete value from array
> 
> }
> }
> 
> Thanks!
> 

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



Re: [PHP] Regex help

2005-11-18 Thread David Grant
Chris,

if (preg_match("/^[A-Za-z0-9\.]+\s*[A-Za-z0-9\.]*$/", "Co. Dublin"))
echo "TRUE";
else
echo "FALSE";

prints "TRUE" for me.

Cheers,

David Grant

Chris Boget wrote:
> Why isn't this regular expression
> 
> ^[A-Za-z0-9\.]+\s*[A-Za-z0-9\.]*$
> 
> allowing for this value:
> 
> 'Co. Dublin' (w/o the single quotes)
> 
> ?  It's failing the regular expression match...
> 
> thnx,
> Chris
> 

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



Re: [PHP] Real-Time Form Updating

2005-11-18 Thread David Grant
I might have the wrong end of the stick, but would it not be easier to
calculate these variables in the form handling script?

Cheers,

David Grant

Chase wrote:
> I am trying to build an order form for our clients to use to order hardware 
> and software, or atleast get a price quote for such.  The page is done and 
> working using a FORM POST to a second page taht works on the variables and 
> generates the totals.
> 
> That being siad, I have a field for total number of users that I would like 
> to calculate the total of about five variables in real-time, before the 
> submit button is activated.  Is this possible? 

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



Re: [PHP] add more features on working php?

2005-11-18 Thread David Grant
Bing,

Have you checked for a php-ldap RPM?

Cheers,

David Grant

Bing Du wrote:
> Hello,
> 
> PHP has already been installed through RPM. phpinfo() shows
> '--with-ldap'.  That's the only information about ldap.  I think there
> should be more than that if php were installed with ldap support
> properly.  So what should I check and get ldap support added?  Do I have
> to download PHP source and go through configure, make and make install?
> 
> Thanks in advance,
> 
> Bing
> 

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



Re: [PHP] testing on a local server

2005-11-18 Thread David Grant
http://www.php.net/manual/en/tutorial.php#tutorial.requirements

[EMAIL PROTECTED] wrote:
> i am new to PHP and web programming/management in general...
> 
> Using Dreamweaver I am trying to preview .php files on the local server, but 
> the
> page won't show up in a web browser. This is probably a stupid question, but
> does that just mean I need to install PHP on my computer?
> 
> 
> This message was sent using IMP, the Internet Messaging Program.
> 

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



Re: [PHP] php5 call by refference

2005-11-21 Thread David Grant
Georgi,

You should assign the output of the functions to variables before the
call and use those variables as the parameters.

Cheers,

David Grant

Georgi Ivanov wrote:
> Hi,
> AFAIK, in PHP5 one can't call function with function parameters .
> The error is that you only can pass variables by reference.
> foo(strlen('aaa'),strlen(''));
> 
> Is there some sort of workaround ?
> 

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



Re: [PHP] Sorting users geographically...

2005-11-21 Thread David Grant
Hi Tony,

I would think the first step would be to find a web service or dataset
to convert a zip code to longitude/latitude.

The formula for calculating distances from long/lat is available here:

http://www.colorado.edu/geography/gcraft/warmup/aquifer/html/distance.html

Cheers,

David Grant

Tony Di Croce wrote:
> I'm helping a friend of mine build a matchmaking website, and we have a
> doozy of a problem to solve:
> 
> What I need to do is two fold:
> 
> #1 Collect whatever geographical information I need from each user to enable
> #2
> #2 Be able to run query's to find people NEAR (geographically) another
> person.
> 
> Does anyone know of any commercial or free implementations of this? Is it
> primarily a database problem or is their some way (computationally) to
> compute the probable proximity of two zip codes?
> 
> Hopefully someone responds to this with a Pear package that does exactly
> what I need! :) If that can't happen, then I'd appreciate any options you
> can think of.
> 
> td
> 
> --
> Free Linux Technical Articles
> http://www.linuxtecharticles.com
> 

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



Re: [PHP] calling static methods of variable class names

2005-11-22 Thread David Grant
Ahmed,

call_user_func(array($className, 'doSomething'));

Cheers,

David Grant

Ahmed Saad wrote:
> hi all,
> 
> how can i call static methods of a class whose name is variable.. something 
> like
> 
> I can do this with reflection by creating a ReflectionMethod object
> then invoke()ing it, but is there a better way?
> Thanks
> 
> -ahmed

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



Re: [PHP] readdir and mime types

2005-11-22 Thread David Grant
Graham,

Is safe mode enabled in your config file?  If safe mode is on, PHP will
check the file to ensure it is owned by the same user executing the
script.  If this condition fails, file_exists() will not work on the file.

http://php.net/file_exists
http://php.net/manual/en/features.safe-mode.php

Cheers,

David Grant

Graham Cossey wrote:
> [snip]
>> Make sure to always hit reply-all, or the e-mail will not go back to the
>> list.
> 
> Yep, realised that after hitting 'send'. :-(
> 
>> If file exists is looking for an associated files is it probable that the
>> .mpg files do not have one associated with it in the other directory?
> 
> It is probable, that's why the check is there, but in this case the
> associated file(s) definitely does exist. If I simply change the file
> extensions from mpg to avi the script works.
> 
> 
> --
> Graham
> 

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



Re: [PHP] how to exist within the context?

2005-11-22 Thread David Grant
Hi,

Try this:



It's a hack, but it works.

Cheers,

David Grant

Bing Du wrote:
> Hi,
> 
> One webpage has its banner, left menu and footer ect that are controled
> by the template.  I want this php script to output the form and
> processing result within the page structure.  Without exit, if the
> 'yourname' field is empty, the script would output 'Please enter your
> name!' fine within the page structure (that is, banner, menu and footer
> are all there).  But obviously the script does not terminate as it's
> supposed to.  With exit, the script terminates fine, but it outputs the
> result in a page without banner, menu and footer.  So what's the correct
> way to get the script stop and output its results always in the page
> structure.
> 
> 
> 
> 
> 
> 
>  
> $submit = $_POST['submit'];
> $name = $_POST['yourname'];
> 
> if ($submit)
> {
>if ($name=="")
>   {
> print "Please enter your name!";
> //exit;
>   }
> }
> 
> echo "Continue processing...";
> ?>
> 
> Thanks in advance,
> 
> Bing
> 

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



Re: [PHP] Is there a way to determine wich browser a visitor uses in php?

2005-11-23 Thread David Grant
$_SERVER['HTTP_USER_AGENT'] contains whatever the browser passes to the
server to identify itself, which may be faked by certain browsers at the
discretion of the user.

The two user agents you provide as an example are both extremely common.

Cheers,

David Grant

twistednetadmin wrote:
> Thanks guys. That helps alot!
> 
> But this:
>  print $_SERVER['HTTP_USER_AGENT'];
> ?>
> 
> Returned this using Mozilla: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> rv:1.7.12) Gecko/20050915 Firefox/1.0.7
> And this using IE: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
> 
> Does that just mean that it's not completely accurate?
> 

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



Re: [PHP] Accessing Arrays in HTML

2005-11-23 Thread David Grant
Shaun,

This:

$values[] = $value;

Does this:

$values[] = array('Scheduling' => '44');

Therefore, it must be accessed like this:

$values[$i]['Scheduling'] // gives '44'

But not this:

$values[$i][0] // index doesn't exist.

Cheers,

David Grant

Shaun wrote:
> Hi,
> 
> I am trying to create a form on my page. The idea is that for each project 
> people can select whether they are allocated for scheduling, non_scheduling 
> or both. Here is an example of my form:
> 
> 
> value="44">
> value="44">
>Project 1
>   
> 
>
> value="25">
>Project 2
> 
> 
> I am trying to access the arrays in the HTML as follows:
> 
> if (is_array($_POST['project'])){
>$fields='';
>$values='';
>foreach ($_POST['project'] as $project_id => $value) {
> $fields[] = $project_id;
> $values[] = $value;
>}
>$i = 0;
>$num_elements = count($fields);
>while($i < $num_elements){
> if(($values[$i]) != 0){
>  echo '$i = '.$i.'';
>  print_r($fields);
>  $query = ("INSERT INTO Allocations (
>User_ID,
>Project_ID,
>Scheduling,
>Non_Scheduling
>   ) VALUES (
>'".$user_id."',
>'".$fields[$i]."',
>'".$fields[$i][0]."',
>'".$fields[$i][1]."',
>   )");
>  echo $query.'';
> }
> $i++;
>}
>   }
> 
> However I can't access the 'Scheduling / 'Non_Scheduling' part. Can anyone 
> see where I am going wrong here?
> 
> Thanks for your advice 
> 

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



Re: [PHP] PHP and email

2005-11-23 Thread David Grant
Hi Angelo,

Why not send them all in one go?  If you want to reduce server load, you
should perhaps adjust the 'nice'ness of the script.

If you do the following:

nice --adjustment=19 ./script.php

Your script will run in the background and use only spare resources.

Cheers,

David Grant

Angelo Zanetti wrote:
> Hi
> 
> I have a dedicated server in the states.
> 
> I need to send about 8000 emails (once off). There pretty small +- 5KB.
> 
> 
> so I want to write a php script and run it from the command line in the
> background. I was thinking of sending 50 emails then waiting 90 seconds
> then sending again.
> 
> Or
> 
> the same script gets run by cron every 90 seconds and just sends 50 emails.
> 
> What do you recommend?
> 
> thanks
> 
> clive

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



Re: [PHP] Autodeleting news when it has become yesterdays news

2005-11-23 Thread David Grant
twistednetadmin wrote:
> Just at the beginning of the page with the news is my thought. So that it
> checks for the eventdate and erases the overdued ones before it collects the
> news.

If you wanted to do that, I'd recommend adding some sort of probability
factor into it, so not all scripts have to run the function.

e.g. 1% chance of cleaning up the database.

 99) {
deleteItems();
}
?>

Cheers,

David Grant

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



Re: [PHP] understanding session vars ?

2005-11-24 Thread David Grant
Gregory,

Are you always setting $_SESSION['menu'] to the contents of
$_GET['menu']?  If so, the second link will set $_SESSION['menu'] to
null.  You need to check the contents of $_GET['menu'] first before
setting, i.e.

if (isset($_GET['menu']))
$_SESSION['menu'] = $_GET['menu'];

Cheers,

David Grant

Gregory Machin wrote:
> Hi
> I'm a bit stuck on session var, and thier implamentation, or my perseption
> thier of.
> I have a page and need certian vars to be persistat each time the page is
> called.
> This is done to detmin the content of the page through logic that calls
> different includes.
> 
> But I cant get the vars to be persistant.
> note the page call it's self.
> 
> ./index.php
>  session_start();
> $_SESSION['menu']
> 
> ?>
> option 1 // this works
> differnt action // this brakes
> it . when the user links here the 'menu' var is cleared
>  echo $_SESSION['menu'];
> 
> ?>
> 
> I would like the menu var (and others) to be persistant until it is reset or
> updated. how do I acheave this .
> 
> Thanks
> 
> 
> 
> 
> 
> 
> --
> Gregory Machin
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> www.linuxpro.co.za
> www.exponent.co.za
> Web Hosting Solutions
> Scalable Linux Solutions
> www.iberry.info (support and admin)
> 
> +27 72 524 8096

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



Re: [PHP] readfile and get_file_contents don't work

2005-11-24 Thread David Grant
Hi Richard,

Please ensure that the "allow_url_fopen" directive is set to "On" in
your php.ini file.

Cheers,

David Grant

Richard K. Miller wrote:
> I compiled PHP from source on Fedora Core 4, but I must have left
> something out because readfile and get_file_contents aren't working.  If
> I try to connect to a "http://"; address I get the error "failed to open
> stream: HTTP request failed".  Any ideas why?
> 
> Richard
> 
> --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] understanding session vars ?

2005-11-24 Thread David Grant
Gregory,

Values in the $_SESSION superglobal will persist over pages so long as
session_start() is called on each page.

Cheers,

David Grant

Gregory Machin wrote:
> I have a test script..
> What i'm trying to achieve is once the user has clicked on link1 the 
> value of item must equal x and if the user clicks on link2 the value of
> items must stay equal to x while setting action equal to y ..
> 
>  session_start();
> echo 'Welcome to testpg';
> $_SESSION['time']= time();
> 
> 
> if (isset($_GET['item'])){
>$_SESSION['item'] = $_GET['item'];
> echo $_SESSION['item'];
>}
> 
> if (isset($_GET['action'])){
>$_SESSION['action'] = $_GET['action'];
>echo $_SESSION['action'];
>   }
> 
> 
> ?>
> link1
> link2
> 
> thanks
> 
> On 11/24/05, * David Grant* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
> Gregory,
> 
> Are you always setting $_SESSION['menu'] to the contents of
> $_GET['menu']?  If so, the second link will set $_SESSION['menu'] to
> null.  You need to check the contents of $_GET['menu'] first before
> setting, i.e.
> 
> if (isset($_GET['menu']))
> $_SESSION['menu'] = $_GET['menu'];
> 
> Cheers,
> 
> David Grant
> 
> Gregory Machin wrote:
> > Hi
> > I'm a bit stuck on session var, and thier implamentation, or my
> perseption
> > thier of.
> > I have a page and need certian vars to be persistat each time the
> page is
> > called.
> > This is done to detmin the content of the page through logic that
> calls
> > different includes.
> >
> > But I cant get the vars to be persistant.
> > note the page call it's self.
> >
> > ./index.php
> >  > session_start();
> > $_SESSION['menu']
> >
> > ?>
> > option 1 // this works
> > differnt action //
> this brakes
> > it . when the user links here the 'menu' var is cleared
> >  > echo $_SESSION['menu'];
> >
> > ?>
> >
> > I would like the menu var (and others) to be persistant until it
> is reset or
> > updated. how do I acheave this .
> >
> > Thanks
> >
> >
> >
> >
> >
> >
> > --
> > Gregory Machin
> > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > www.linuxpro.co.za <http://www.linuxpro.co.za>
> > www.exponent.co.za <http://www.exponent.co.za>
> > Web Hosting Solutions
> > Scalable Linux Solutions
> > www.iberry.info <http://www.iberry.info> (support and admin)
> >
> > +27 72 524 8096
> 
> 
> 
> 
> -- 
> Gregory Machin
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> www.linuxpro.co.za <http://www.linuxpro.co.za>
> www.exponent.co.za <http://www.exponent.co.za>
> Web Hosting Solutions
> Scalable Linux Solutions
> www.iberry.info <http://www.iberry.info> (support and admin)
> 
> +27 72 524 8096

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



Re: [PHP] understanding session vars ?

2005-11-24 Thread David Grant
Gregory

Gregory Machin wrote:
> My test code is for test.php which is intended to call it's self, and
> starts with sesstion_start().
> buy does not disply x after link2 is clicked on, but only y..
> 
> what am I missing ?

"x" wouldn't display because it depends on $_GET['item'] being set,
which isn't.  Try var_dump($_SESSION) instead of the conditional echoing
of the variables.

Cheers,

David Grant

> Thanks
> 
> On 11/24/05, *David Grant* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
> Gregory,
> 
> Values in the $_SESSION superglobal will persist over pages so long as
> session_start() is called on each page.
> 
> Cheers,
> 
> David Grant
> 
> Gregory Machin wrote:
> > I have a test script..
> > What i'm trying to achieve is once the user has clicked on link1 the
> > value of item must equal x and if the user clicks on link2 the
> value of
> > items must stay equal to x while setting action equal to y ..
> >
> >  > session_start();
> > echo 'Welcome to testpg';
> > $_SESSION['time']= time();
> >
> >
> > if (isset($_GET['item'])){
> >$_SESSION['item'] = $_GET['item'];
> > echo $_SESSION['item'];
> >    }
>     >
> > if (isset($_GET['action'])){
> >$_SESSION['action'] = $_GET['action'];
> >echo $_SESSION['action'];
> >   }
> >
> >
> > ?>
> > link1
> > link2
> >
> > thanks
> >
> > On 11/24/05, * David Grant* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
> > mailto:[EMAIL PROTECTED]>>> wrote:
> >
> > Gregory,
>     >
> > Are you always setting $_SESSION['menu'] to the contents of
> > $_GET['menu']?  If so, the second link will set
> $_SESSION['menu'] to
> > null.  You need to check the contents of $_GET['menu'] first
> before
> > setting, i.e.
> >
> > if (isset($_GET['menu']))
> > $_SESSION['menu'] = $_GET['menu'];
> >
> > Cheers,
> >
> > David Grant
> >
> > Gregory Machin wrote:
> > > Hi
> > > I'm a bit stuck on session var, and thier implamentation, or my
> > perseption
> > > thier of.
> > > I have a page and need certian vars to be persistat each
> time the
> > page is
> > > called.
> > > This is done to detmin the content of the page through logic
> that
> > calls
> > > different includes.
> > >
> > > But I cant get the vars to be persistant.
> > > note the page call it's self.
> > >
> > > ./index.php
> > >  > > session_start();
> > > $_SESSION['menu']
> > >
> > > ?>
> > > option 1 // this
> works
> > > differnt action //
> > this brakes
> > > it . when the user links here the 'menu' var is cleared
> > >  > > echo $_SESSION['menu'];
> > >
> > > ?>
> > >
> > > I would like the menu var (and others) to be persistant until it
> > is reset or
> > > updated. how do I acheave this .
> > >
> > > Thanks
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Gregory Machin
> > > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> > > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> mailto:[EMAIL PROTECTED]>>
> > > www.linuxpro.co.za <http://www.linuxpro.co.za>
> <http://www.linuxpro.co.za>
> > > www.exponent.co.za <http://www.exponent.co.za>
> <http://www.exponent.co.za>
> > > Web Hosting Solutions
> > > Scalable Linux Solutions
> > > www.iberry.i

Re: [PHP] Regexp trouble

2005-11-24 Thread David Grant
Andy,

Try preg_match instead of ereg.

Cheers,

David Grant

Andy Pieters wrote:
> Hi list
> 
> I still fail to understand why regular expressions are causing me such a hard 
> time.
> 
> I used and tested my regexp in kregexpeditor (comes with Quanta [kdewebdev]) 
> but when I put it in the php script it fails.
> 
> ereg('^([\w]{3,3})[\s]([\d]{2,2})[\s]([\d]{2,2})[:]([\d]{2,2})[:]([\d]{2,2})'
> 
> Does not match my query string.
> 
> Which is
> 
> Nov 22 06:51:36
> 
> Any ideas why?  I mean Line start, followed by 3 word chars, followed by a 
> space, followed by 2 digits, followed by a space, followed by two digits, 
> folowed by a colon followed by 2 digits and followed by a colon, should match 
> that date?
> 
> With kind regards
> 
> 
> Andy
> 

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



Re: [PHP] What is

2005-11-25 Thread David Grant
Robert,

 I have some scripts that I downloaded and am trying to make compliant
> with my server.  They have  they are and how to fix them at this point.
> 
> Stupid question, I know, but...
> 
> Thanks,
> Robert
> 

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



Re: [PHP] What is

2005-11-25 Thread David Grant


Tells the parser that the XML it is parsing is version 1.

Jochem Maas wrote:
> Wolf wrote:
>> I have some scripts that I downloaded and am trying to make compliant
>> with my server.  They have > they are and how to fix them at this point.
>>
>> Stupid question, I know, but...
> 
> not stupid, although a 'google' might have helped, regardless you have
> already had the answer.
> 
> I find it funny that you say 'fix them' - one of the things [some of]
> the core
> developers are looking to get rid of is this shorthand syntax
> (according to posts on internals@lists.php.net) ... something
> to do with XML compatibility ... for now its valid php syntax though :-).
> 
>>
>> Thanks,
>> Robert
>>
> 

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



Re: [PHP] SQL Password() function

2005-11-28 Thread David Grant
Ahmed Saad wrote:
> On 11/26/05, Yaswanth Narvaneni <[EMAIL PROTECTED]> wrote:
>> I 'dont' want to use something like select * from table where
>> table.passwd=password($passwd);
> 
> (IIRC. they broke backward compatibility in
> version 5).. 

4.1 :(

Cheers,

David Grant

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



Re: [PHP] PhpMailer vs Pear:Mail

2005-11-28 Thread David Grant
*cough*

http://pear.php.net/package/Mail

*cough*

Mark Steudel wrote:
> Would you mind elaborating on why?  
> 
> -Original Message-
> From: Richard Heyes [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 28, 2005 12:53 AM
> To: Cabbar Duzayak
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] PhpMailer vs Pear:Mail
> 
> Cabbar Duzayak wrote:
>> Could you please tell which one you recommend in terms of 
>> stability/speed and share your experience in terms of these 2?
> 
> Ooo, that would have to be PEAR::Mail...
> 
> --
> Richard Heyes
> http://www.phpguru.org/
> 
> --
> 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] preg_slipt

2005-11-29 Thread David Grant
Hi Dan,

Try:

$a = split("\n", chunk_split('1234567890', 2), 5);

php.net/chunk_split
php.net/split

Cheers,

David Grant

Sichta Daniel wrote:
> Hi all !!!
>  
> I have string like this "1234567890"
>  
> I need to split this into array like this
> a[0] = "12"
> a[1] = "34" 
> a[2] = "56" 
> a[3] = "78" 
> a[4] = "90"
>  
> I know that for this is preg_split, but I don't know the string patern
> for split.
> Thank you in advance !!
>  
> 
> Dan
> 
>  
> 

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



Re: [PHP] preg_slipt

2005-11-29 Thread David Grant
There is an error in this code.  It should in fact read:

$a = split("\r\n", chunk_split('1234567890', 2), 5);

OR

$a = split("\n", chunk_split('1234567890', 2, "\n"), 5);

David Grant wrote:
> Hi Dan,
> 
> Try:
> 
> $a = split("\n", chunk_split('1234567890', 2), 5);
> 
> php.net/chunk_split
> php.net/split
> 
> Cheers,
> 
> David Grant
> 
> Sichta Daniel wrote:
>> Hi all !!!
>>  
>> I have string like this "1234567890"
>>  
>> I need to split this into array like this
>> a[0] = "12"
>> a[1] = "34" 
>> a[2] = "56" 
>> a[3] = "78" 
>> a[4] = "90"
>>  
>> I know that for this is preg_split, but I don't know the string patern
>> for split.
>> Thank you in advance !!
>>  
>>
>> Dan
>>
>>  
>>
> 

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



Re: [PHP] exclude part of text

2005-11-29 Thread David Grant
Hi,

021 wrote:
>  $lines = file('sometext.txt');
> for ($i = 0, $j = count($lines); $i <=1; $i++) {
> print $lines[$j - $i];
> }
> ?>

For a start, try this instead:

$lines = file('sometext.ext');
$last  = end($lines);

Secondly, do you have an example of the real log file?

Cheers,

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

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



Re: [PHP] exclude part of text

2005-11-29 Thread David Grant
Please try:

preg_match('/^[^\>]*\>(.*)\*.*$/', $line, $matches);

021 wrote:
> the log file is from a radio playlist:
> 
> TIME > ARTIST - TITLE *SONG_CATEGORY
> 
> for example
> 
> 17:12:26 > THE CURE - ALT.END *NEW
> 
> the values before > and after * are changing, hope there's a simple
> solution for this
> 
> thanx
> 


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

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



Re: [PHP] when to enter submitted in mysql?

2005-11-29 Thread David Grant
Personally, I'd keep it all in the session and write at the end, but
this approach has at least two drawbacks:

1. The user cannot complete the process at a later point.
2. You cannot conduct analysis of part-completed data.

Cheers,

David Grant

[EMAIL PROTECTED] wrote:
> Hi to all!
> I have form made on 4 pages (by groups of questions). Right now my code
> works this way: once somebody submit the first page of the form his/her
> submitted info is entered in database with status=temp. I store the ID
> (insert_id()) in session and then every time visitor submit the next
> page I do update of the current record using ID.
> But, I heard once that "the best" solution is store all entered info in
> session (array) and insert all info at once.
> Or, instead in sessions, move submitted info with serialized array.
> 
> Opinions?
> 
> Thanks for help.
> 
> -afan
> 


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

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



Re: [PHP] weird error, cookies??

2005-12-01 Thread David Grant
Hi Angelo,

This simply means that the redirection keeps going, like so:

foo.php


bar.php


Check the logic in your application that decides if the user gets
redirected and make sure you're not making any incorrect assumptions.

Cheers,

David Grant

Angelo Zanetti wrote:
> Hi guys.
> 
> Been working on my site and then been trying to navigate through it, the
> once page redirects to another.
> 
> then all of a sudden I get this weird popup (in mozilla) "Redirection
> limit for this URL exceeded. Unable to load requested page"
> 
> Also IE seems to timeout.
> 
> The page redirects from http to https.
> 
> anyone come across this or know what the problem is?
> 
> Thanks in advance.
> 


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

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



Re: [PHP] help with preg_replace only part of the string

2005-12-06 Thread David Grant
Replace the middle (.*) with ([^<]*).  This tells the regex engine to
ignore new opening tags.

Cheers,

David

Georgi Ivanov wrote:
> Hi,
> I want to replace the content of html links :  name="bla">REPLACETHIS.
> 
> $html=preg_replace("/()(.*)<\/a>/isU",$link,$html,1);
> This generally works but removes , tags too.
> How to make it work without removing anything else than (.*) in the middle of 
> .*
> 
> Thanks in advance.
> 


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

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



Re: [PHP] What software do you use for writing PHP?

2005-12-06 Thread David Grant
Jeff,

Jeff McKeon wrote:
> Forever now I've been using Frontpage for all my web work including php.
> I'm sure there's better software out there that is more suited to
> writing and editing PHP pages.  What do you all use?

I use Zend Studio 5, but there are plenty of other (cheaper) options.
Take a look at the following link for a list of editors with reviews.

http://www.php-editors.com/review/

Cheers,

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

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



Re: [PHP] What software do you use for writing PHP?

2005-12-06 Thread David Grant
Hi Jeff,

Jeff McKeon wrote:
> What is it you like about Zend Studio?

* Code completion
* Syntax highlighting for PHP, HTML and CSS
* Manual pages
* Debugging
* Code examination
* PHPDoc
* CVS & SVN support

Cheers,

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

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



Re: [PHP] Unnecessary if statement? Programming technique

2005-12-06 Thread David Grant
Jared Williams wrote:
> Why not
> 
> for ($i = 0; $i < 100/100; ++$i)

This involves dividing 100 by 100 for each iteration of the loop.
It would be better to test against 1.

There is also the unwanted side-effect of executing the code on each
hundredth iteration, which is unwanted (as far as I understand the
problem). :)

It would be interesting if Steve could divulge the greater problem that
he is seeking a solution to.

Cheers,

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

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



Re: [PHP] What software do you use for writing PHP?

2005-12-06 Thread David Grant
Stephen Leaf wrote:
> KWrite part of KDE. Notepad with Syntax Highlighting and AutoIndention.
> And because it's part of KDE all the kioslaves come with. Which means editing 
> sites over ftp, ftps, ssh and many others is possible.
> Like the Vim guy said. DEs? who needs them :)

Mmmm, reminds me of Kate!  When I use KDE, I used Kate for all non-PHP
coding tasks, because it has great highlighting, and code folding too. :)

Cheers,

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

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



Re: [PHP] What software do you use for writing PHP?

2005-12-06 Thread David Grant
According to http://kate.kde.org/info.php, kate and kwrite (and Quanta)
all use katepart (a rewrite of kwrite).

Stephen Leaf wrote:
> As far as I can tell kate has a kwrite embedded :) I'm sure that's not the 
> case but it seems like it. everything kwrite can do so can kate. only it has 
> more options that I'd never used.
> 
> And yes Code folding is nice don't use it much tho.
> 
> On Tuesday 06 December 2005 09:48, David Grant wrote:
>> Stephen Leaf wrote:
>>> KWrite part of KDE. Notepad with Syntax Highlighting and AutoIndention.
>>> And because it's part of KDE all the kioslaves come with. Which means
>>> editing sites over ftp, ftps, ssh and many others is possible.
>>> Like the Vim guy said. DEs? who needs them :)
>> Mmmm, reminds me of Kate!  When I use KDE, I used Kate for all non-PHP
>> coding tasks, because it has great highlighting, and code folding too. :)
>>
>> Cheers,
>>
>> David Grant
> 


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

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



Re: [PHP] Unnecessary if statement? Programming technique

2005-12-06 Thread David Grant
Hi,

I imagine this kind of thing is not especially taxing on the processor,
especially if the condition is a fairly simple comparison.  That said, I
have very little understanding aside from my own limited experience of
what runs slowly!

If you're worried about code maintenance, then move the code out to a
function and pass the parts that vary as parameters.

Cheers,

David Grant

Steve McGill wrote:
> Hi,
> David is right about the unwanted side-effect. Thanks for the idea though.
> Unfortunately the 'greater problem' is not so great, I've just been doing 
> this for a while now and find myself programming loops like these so often 
> and I've never got round to testing if a simple IF statement is a major 
> drain on the CPU. Somehow I doubt it.
> I got this reply from someone direct to my mail address, which seems to sum 
> it up:
> 
> --
> In truth you are not evaluating the whole if block just the condition
> and since its such a simple condition I can't see how it would be at
> all taxing on the server. In your specific case I can't think of a
> better way to do it either.
> --
> 
> I'll try and think of a better example:
> 
>  $bool = true; // this is set dynamically and not known in advance
> while(true) {
>   if($bool) { // this condition tested in every single loop
> // do first code
>   } else {
> // do second code
>   }
> }
> ?>
> 
> and I am wondering if the compiler is smart enough to turn this into:
> 
>  $bool = true; // this is set dynamically and not known in advance
> if($bool) { // this condition only tested once
>   while(true) {
> // do first code
>   }
> } else {
>   while(true) {
> // do second code
>   }
> }
> ?>
> 
> I realise this might be hard to follow without giving specific examples and 
> code.
> 
> In this case, the coding style of the 2nd example seems far better, but 
> sometimes the 2 blocks of code are practically identical and it's a 
> programmer's nightmare to have the blocks of code in 2 places and to 
> remember to keep them both updated.
> 
> I'm also assuming that using function calls is also much slower than 
> evaluating a very simple IF statement.
> 
> Thanks for your interest.
> 
> Best wishes,
> Steve
> 
> "David Grant" <[EMAIL PROTECTED]> schreef in bericht 
> news:[EMAIL PROTECTED]
>> Jared Williams wrote:
>>> Why not
>>>
>>> for ($i = 0; $i < 100/100; ++$i)
>> This involves dividing 100 by 100 for each iteration of the loop.
>> It would be better to test against 1.
>>
>> There is also the unwanted side-effect of executing the code on each
>> hundredth iteration, which is unwanted (as far as I understand the
>> problem). :)
>>
>> It would be interesting if Steve could divulge the greater problem that
>> he is seeking a solution to.
>>
>> Cheers,
>>
>> David
>> -- 
>> David Grant
>> http://www.grant.org.uk/ 
> 


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

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



Re: [PHP] Forum

2005-12-06 Thread David Grant
Larry E. Ullman wrote:
>>>> Does anyone of you know of a good forum that is easy to customize and
>>>> supports sticky notes, user registration, bb code and stuff like that?

http://fudforum.org/features.php

I've heard lots about it, but never used it.

Cheers,

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

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



Re: [PHP] Anyone getting bounces from

2005-12-07 Thread David Grant
Jay Blanchard wrote:
> [EMAIL PROTECTED] ?
> 
> I am getting failure notices out the wazoo for some very old messages to the
> general list.
> 

Just got seven in a row, looks like the MTA is trying for three weeks
and then giving up.  The messages appear to be for:

[EMAIL PROTECTED]

Can this address be unsubscribed?

Cheers,

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

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



Re: [PHP] Eval To String

2005-12-07 Thread David Grant
Shaun

Shaun wrote:
> Is it possible to return the result of eval function to a string rather than 
> outputting directly to the browser?

ob_start();
eval('$eval = "evil";');
$output = ob_get_clean();

Cheers,

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

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



Re: [PHP] Call to undefined function mysql_real_escape_string()]

2005-12-08 Thread David Grant
Try using mysqli, instead of mysql.

Have you tried Joomla! support channels?

Paul Hickey wrote:
> Can someone help me overcome this recurring problem? I am using the
> Joomla content management system and I keep coming across the following
> errors.  
> 
> Fatal error: Call to undefined function mysql_real_escape_string()
> in /usr/local/apache2/htdocs/common.php on line 24
> 
> Fatal error: Call to undefined function mysql_real_escape_string()
> in /usr/local/apache2/htdocs/class.inputfilter.php on line 344
> 
> I notice in my Dynamic Extensions section of php.ini there are no
> extensions called for; if that helps. Joomla works fine, but when adding
> components or modules the problems start. One component author made a
> test for the mysql_real_escape_string and I think avoided using it then
> the component worked. I think that's probably not the best solution. 
> 
> Fedora Core 3
> 
> Apache 2.0.55
> 
> PHP 5.0.5 (compiled with mysqli vice mysql)
> './configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-ftp'
> '--enable-inline-optimization' '--enable-magic-quotes' '--enable-
> mbstring' '--enable-track-vars' '--enable-trans-sid' '--enable-
> wddx=shared' '--enable-xml' '--with-dom' '--with-gd' '--with-gettext'
> '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-regex=system'
> '--with-xml' '--with-zlib-dir=/usr/lib'
> 
> MySQL 4.1.15
> 
> 
> TIA,
> 
> 
> Paul Hickey
> Christian Patriot 
> Palm Bay Fl
> 


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

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



Re: [PHP] Call to undefined function mysql_real_escape_string()]

2005-12-08 Thread David Grant
Is there no way to specify the database functions in Joomla?

You're getting undefined function because you haven't compiled it with
mysql, but mysqli instead, which means the functions you need are
prefixed with mysqli instead of mysql.

Paul Hickey wrote:
> I have PHP compiled with mysqli.
> 
> The standard answer from the Joomla forums is that I need to have
> "mysql" vice "mysqli". I was looking for a more global solution than
> having to modify the code for every component, module, mambot I want to
> use.
> 
> I don't understand why I'm getting "undefined function" errors. 
> 
> PHP.ini has no reference to mysqli. I don't know if changing this would
> enable the functions specific to PHP > 4.x.
> 
> Paul Hickey
> Christian Patriot 
> Palm Bay Fl
> 


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

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



Re: [PHP] Call to undefined function mysql_real_escape_string()]

2005-12-08 Thread David Grant
Hi John,

John Nichel wrote:
> Paul Hickey wrote:
>> I don't understand why I'm getting "undefined function" errors.
>> PHP.ini has no reference to mysqli. I don't know if changing this would
>> enable the functions specific to PHP > 4.x.
> 
> In your configuration line (how php was configured then compiled), you
> have...
> 
> --with-mysqli=/usr/local/mysql/bin/mysql_config
> 
> That is why you are getting undefined function errors.  Your version of
> php is using mysqli, not mysql.  You have two options: a) Recompile php
> or b) Change all mysql_* functions to their counterparts in mysqli_*


Hmm, that's how I *should* have put it. :)

Cheers,

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

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



Re: [PHP] PEAR Validate email question

2005-12-08 Thread David Grant
Validate::email appears to check for a MX or A record.  I'm a bit rusty
on my RFCs, but isn't is possible the mail host could be specified using
a CNAME?

Cheers,

David

Eric Butera wrote:
> Hello,
> 
> I'm using the PEAR Validate::email method to validate email addresses on our
> contact forms since the spam bots have gotten so bad.  I am using the
> "check_domain" flag which calls the php function "checkdnsrr."  This form
> processor is used on several sites now and all is going well except one
> problem.  It seems this "checkdnsrr" function randomly returns false on
> valid email addresses.  I built a little debug feature into the processor to
> let me know when the script fails and any error messages it has generated
> along the way to try and stay ahead of the spammers.
> 
> I've been getting randomly occurring failure notices.  Most of the time it
> works, sometimes it doesn't.  Every failure is a valid DNS and email
> address.  If I try running the email address against Validate::email later
> it works.  I was hoping somebody can shine some light on why checkdnsrr
> would work sometimes and why it wouldn't work others.  Any help or advice
> would be greatly appreciated.
> 
> Thanks in advance!
> 


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

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



Re: [PHP] Non-trivial task of converting text to HTML

2005-12-08 Thread David Grant
Hi Roman,

Check out this: http://www.michelf.com/projects/php-markdown/

Would this help you?

Cheers,

David

Roman Ivanov wrote:
> Task:
> Create a script that converts text into HTML with paragraphs.
> 
> Problem:
> Input text could use the book notation, as well as the web notation,
> plus it can contain HTML.
> 
> ==
> This is a title
> 
>This is a Book paragraph.
>This is another book paragraph.
> This is yet another book paragraph, but it's not indented with spaces,
> because user wrote it in OpenOffice.
> ==
> 
> ==
> This is a web paragraph.
> 
> This is another web paragraph.
> 
>This is yet another web paragraph, which is indented with spaces for
> some unknown reason.
> ==
> 
> Output text should be correctly formatted without using lots of br's and
>  's. Doing so manually is not a problem, I would just use  for
> web paragraphs, and  for book paragraphs. However,
> formatting such text with a scrip is very difficult. Does anyone knows a
> good exaple of such script?
> 


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

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



Re: [PHP] 1 ip address go here all others go here

2005-12-13 Thread David Grant
Try $_SERVER['REMOTE_HOST'] instead of REFERER.

Dave Carrera wrote:
> Jay Blanchard wrote:
> 
>> [snip]
>> Is there a way of sending users with a local ip address say 127.0.0.1
>> and 192.168.xxx.xxx to goto one page and all other visitors to goto
>> another?
>> [/snip]
>>
>>
>> Yes, there is.
>>
>>
>> $_SERVER['REFERER'] will give you the referer mosy of the time. More info
>> from TFM can be found here;
>>
>> http://us3.php.net/reserved.variables
>>
>> Header can then be used to redirect
>>
>> header("Location: http://www.example.com/";); /* Redirect browser */. More
>> info from TFM can be found here;
>>
>> http://us3.php.net/header
>>
>>  
>>
> snip from TFM
> 
> 'HTTP_REFERER'
> 
>The address of the page (if any) which referred the user agent to
>the current page. This is set by the user agent. Not all user agents
>will set this, and some provide the ability to modify HTTP_REFERER
>as a feature. In short, it cannot really be trusted.
> 
> notice the last 7 words 
> 


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

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



Re: [PHP] 1 ip address go here all others go here

2005-12-13 Thread David Grant
Quick and (very) nasty:

$parts = split(".", $_SERVER['REMOTE_HOST']);
if ($_SERVER['REMOTE_HOST'] == '127.0.0.1' || ($parts[0] == '192' &&
$parts[1] == '168')) {
// Local
} else {
// Remote
}


Dave Carrera wrote:
> i know about
> 
> $_SERVER['REMOTE_HOST']
> 
> but i think i should of said how do i compare any address starting with
> 192.168.
> 
> sorry if my first question was to vague
> 
> 
> David Grant wrote:
> 
>> Try $_SERVER['REMOTE_HOST'] instead of REFERER.
>>
>> Dave Carrera wrote:
>>  
>>
>>> Jay Blanchard wrote:
>>>
>>>   
>>>> [snip]
>>>> Is there a way of sending users with a local ip address say 127.0.0.1
>>>> and 192.168.xxx.xxx to goto one page and all other visitors to goto
>>>> another?
>>>> [/snip]
>>>>
>>>>
>>>> Yes, there is.
>>>>
>>>>
>>>> $_SERVER['REFERER'] will give you the referer mosy of the time. More
>>>> info
>>>> from TFM can be found here;
>>>>
>>>> http://us3.php.net/reserved.variables
>>>>
>>>> Header can then be used to redirect
>>>>
>>>> header("Location: http://www.example.com/";); /* Redirect browser */.
>>>> More
>>>> info from TFM can be found here;
>>>>
>>>> http://us3.php.net/header
>>>>
>>>>
>>>>
>>>> 
>>> snip from TFM
>>>
>>> 'HTTP_REFERER'
>>>
>>>   The address of the page (if any) which referred the user agent to
>>>   the current page. This is set by the user agent. Not all user agents
>>>   will set this, and some provide the ability to modify HTTP_REFERER
>>>   as a feature. In short, it cannot really be trusted.
>>>
>>> notice the last 7 words 
>>>
>>>   
>>
>>
>>  
>>
> 


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

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



Re: [PHP] 1 ip address go here all others go here

2005-12-13 Thread David Grant
Erm, REMOTE_ADDR, not REMOTE_HOST.  Sorry!

David Grant wrote:
> Quick and (very) nasty:
> 
> $parts = split(".", $_SERVER['REMOTE_HOST']);
> if ($_SERVER['REMOTE_HOST'] == '127.0.0.1' || ($parts[0] == '192' &&
> $parts[1] == '168')) {
>   // Local
> } else {
>   // Remote
> }
> 
> 
> Dave Carrera wrote:
>> i know about
>>
>> $_SERVER['REMOTE_HOST']
>>
>> but i think i should of said how do i compare any address starting with
>> 192.168.
>>
>> sorry if my first question was to vague
>>
>>
>> David Grant wrote:
>>
>>> Try $_SERVER['REMOTE_HOST'] instead of REFERER.
>>>
>>> Dave Carrera wrote:
>>>  
>>>
>>>> Jay Blanchard wrote:
>>>>
>>>>   
>>>>> [snip]
>>>>> Is there a way of sending users with a local ip address say 127.0.0.1
>>>>> and 192.168.xxx.xxx to goto one page and all other visitors to goto
>>>>> another?
>>>>> [/snip]
>>>>>
>>>>>
>>>>> Yes, there is.
>>>>>
>>>>>
>>>>> $_SERVER['REFERER'] will give you the referer mosy of the time. More
>>>>> info
>>>>> from TFM can be found here;
>>>>>
>>>>> http://us3.php.net/reserved.variables
>>>>>
>>>>> Header can then be used to redirect
>>>>>
>>>>> header("Location: http://www.example.com/";); /* Redirect browser */.
>>>>> More
>>>>> info from TFM can be found here;
>>>>>
>>>>> http://us3.php.net/header
>>>>>
>>>>>
>>>>>
>>>>> 
>>>> snip from TFM
>>>>
>>>> 'HTTP_REFERER'
>>>>
>>>>   The address of the page (if any) which referred the user agent to
>>>>   the current page. This is set by the user agent. Not all user agents
>>>>   will set this, and some provide the ability to modify HTTP_REFERER
>>>>   as a feature. In short, it cannot really be trusted.
>>>>
>>>> notice the last 7 words 
>>>>
>>>>   
>>>
>>>  
>>>
> 
> 


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

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



Re: [PHP] Problem: Distortion while saving text file.

2005-12-14 Thread David Grant
Could it be the other way around, i.e. Windows is stripping slashes, and
Linux is not?  How does $contents come to exist in the script?

Check for any difference in your ini files for magic_quotes_runtime.

Cheers,

David Grant

Janne Miettunen wrote:
> What could be wrong when this is transformed:
> ""
> to this form:
> ""
> 
> The line is saved to text file with this function:
> 
> function savesite($site, $lang, $contents){
> 
> if (check_session()){
> $file=fopen('content/' . $site . '_' . $lang . '.txt', "w");
> 
> fwrite($file, $contents);
> 
> fclose($file);
> }
> 
> I run it through nl2br() before saving and this only happens on Linux
> server, on Windows server it works fine, no \ before ".
> 
> Tested with:
> On Windows: Apache2, PHP5
> Linux: Debian distro, Apache2, PHP4, also tried with PHP5
> 


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

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



Re: [PHP] foreach $_FILES

2005-12-14 Thread David Grant
Shaun,

That is the documented behaviour for form fields in PHP.

See "Dots in incoming variable names" on the following page:

http://php.net/variables.external

Cheers,

David Grant

Shaun wrote:
> Hi,
> 
> I have a form on my site with many file fields for users to upload files. I 
> am trying to verify that for each file uploaded it corresponds with the name 
> of the file field i.e.
> 
> 
>File_1.CSV:
>
> 
> 
>File_2.CSV:
>
> 
> 
> However if I loop through the $_FILES array like this:
> 
> foreach( $_FILES as $key => $value ){
>echo '$key = '.$key.'';
>echo '$value = '.$value.'';
> }
> 
> $key = File_1_CSV
> $value['name'] = File_1.CSV
> $key = File_2_CSV
> $value['name'] = File_2.CSV
> 
> The . is replaced with an underscore in the $key value. I could get around 
> this with a substr() but it seems a little inelegant, can anyone tell me why 
> this is happening please?
> 
> Thanks for your advice. 
> 


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

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



Re: [PHP] 4 Digit ID with Leading Zeros

2005-12-15 Thread David Grant
Rahul,

Rahul S. Johari wrote:
> The 4 Digit ID (beginning from 0001) will be used in two places:
> (a) It will be the ID for the record in the mySQL table, instead of the
> usual ID that we create in mySQL. It will be a Primary Key, Not Null,
> Auto_Increment

Adding ZEROFILL to that definition might be what you're after.

Cheers,

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

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



Re: [PHP] PHP/MySQL noob rides again.. into trouble

2005-12-16 Thread David Grant
Paul Jinks wrote:
> $SQLQuery = "SELECT * FROM project WHERE
> projTitle = ".$HTTP_GET_VARS['projTitle']
> or die("SQLQuery 1 failed");

$SQLQuery = "SELECT * FROM project WHERE projTitle = '" .
$HTTP_GET_VARS['projTitle'] . "'";

Not sure why you've got the or die() there.

Cheers,

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

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



Re: [PHP] PHP/MySQL noob rides again.. into trouble

2005-12-16 Thread David Grant
Paul,

Paul Jinks wrote:
> David Grant wrote:
>> $SQLQuery = "SELECT * FROM project WHERE projTitle = '" .
>> $HTTP_GET_VARS['projTitle'] . "'";
> 
> Yep, that fixed it. Thanks. I had a feeling there was a mix up with the
> "s and 's. What's with the .  s?

The . is a concatenation operator, i.e. it joins two strings together.

>> Not sure why you've got the or die() there.
> 
> I had the idea that you could put an or die() after any command and it
> would tell you that it had screwed up at that point. Bad idea?

Bit hard to maintain I should think.  It's unlikely you're going to
screw up a string concatenation and it still be able to call the die().

Cheers,

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

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



Re: [PHP] ? Split string into smaller chunks

2005-12-19 Thread David Grant
Labunski wrote:
> I need to split a long string into smaler chunks (an array), as a separator 
> using every third \n (and not just every \n).
> I could use 'explode', but then it would produce too many chunks.

php.net/preg_split

Cheers,

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

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



Re: [PHP] can someone explain this query to me

2005-12-20 Thread David Grant
Ross,

Ross wrote:
> $query = "delete from meetings where id IN (".implode(",", $ids).")";
> 
> Just the end bit, ids is an array of values (1,2,3,4,5) what does the IN 
> do??

It's the equivalent of WHERE id = 1 OR id = 2 OR id = 3 OR id = 4 OR id = 5.

Cheers,

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

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



Re: [PHP] problem: pgsql (unicode) => php5 => HTML (iso-8859-1)

2005-12-20 Thread David Grant
Michelle,

Michelle Konzack wrote:
> Please can anyone tell me the right  (???) Tag to get Motilla
> right to UNICODE?

Try:



Cheers,

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

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



Re: [PHP] PHP is OK in IE but not in Netscape

2005-12-22 Thread David Grant
Nanu,

Nanu Kalmanovitz wrote:
> The http://www.kalmanovitz.co.il/hello.php file appears OK in M$-IE but
> not in Netscape 7.0.

Looks fine to me.  What is the contents of hello.php?

Cheers,

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

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



Re: [PHP] PHP is OK in IE but not in Netscape

2005-12-22 Thread David Grant
Nanu,

Nanu Kalmanovitz wrote:
> Ok, I will forget Netscape, what other popular browsers beside M$-IE
> works with M$-Windows?

I wouldn't "forget" Netscape, because people still use it.  Just make
sure your code validates to W3C standards and so long as it isn't too
cutting edge, must browsers should display it fine.

To answer your question, Opera is probably the third most popular
browser on Windows.

Cheers,

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

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



Re: [PHP] Graphically displayed number to confirm user is a human

2006-01-04 Thread David Grant
Dave M G wrote:
>   First, is there a term for these kinds of images, or that kind of
> verification system? What would be the best search terms to look for
> source scripts?

CAPTCHA

>   Second, can anyone recommend a resource for that kind of PHP script. If
> I really worked at it, I could probably write the script to generate a
> small PNG image with a random number in it. But I haven't the faintest
> clue how to distort it so it's only legible to humans, nor how to
> correlate the image with a number that a user inputs into a form field.

http://pear.php.net/package/Text_CAPTCHA

Cheers,

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

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



Re: [PHP] Problem with fsockopen and SSL

2006-01-09 Thread David Grant
Hi Barry,

I'm not terrible au fait with the workings of SSL, but it strikes me as
potentially problematic that you are communicating in plain text over an
encrypted protocol.  Might that be the problem?

David

Barry wrote:
> Hi everyone!
> 
> I want to connect to an SSL server but i can't get the content :(
> 
> Here is the code i use:
> $xml = 'Hello!';
> 
> function PostToHost($host, $path, $referer, $data_to_send) {
>   $fp = fsockopen($host, 443);
>   printf("Open!\n");
>   fputs($fp, "POST $path HTTP/1.1\r\n\r\n");
>   fputs($fp, "Host:$host\r\n");
>   fputs($fp, "Referer: $referer\r\n");
>   fputs($fp, "Content-type: text/xml\r\n");
>   fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
>   fputs($fp, "Connection: close\r\n");
>   //fputs($fp, $data_to_send);
>   printf("Sent!\n");
>   while(!feof($fp)) {
>   $res .= fgets($fp, 128);
>   }
>   printf("Done!\n");
>   fclose($fp);
> 
>   return $res;
> }
> 
> $data = $xml;
> 
> printf("Go!\n");
> $x = PostToHost(
>   "ssl://easy-demo.tcinternet.de",
>   "/hosting/servlet/Dispatcher",
>   $GLOBALS["HTTP_REFERER"],
>   $data
> );
> echo $x;
> 
> And this is what i get:
> Go! Open! Sent! Done! HTTP/1.1 400 Bad Request Date: Mon, 09 Jan 2006
> 10:28:48 GMT Server: Apache/2.0.53 (Unix) mod_ssl/2.0.53 OpenSSL/0.9.7e
> DAV/2 mod_jk/1.2.1 Content-Length: 363 Connection: close Content-Type:
> text/html; charset=iso-8859-1
> Bad Request
> 
> Your browser sent a request that this server could not understand.
> Apache/2.0.53 (Unix) mod_ssl/2.0.53 OpenSSL/0.9.7e DAV/2 mod_jk/1.2.1
> Server at easy-demo.tcinternet.de Port 443
> 
> What did the Webserver not understood?
> 
> Btw. i can't use cURL because the server has an old version of PHP (><)"
> 
> Would be glad if you can help or even have a code how to connect to a
> SSL webserver via fsockopen that works.
> 
> Btw the PHP version on server is: PHP Version 4.2.2
> 
> Thanks for any help!
> 
> Greets Barry
> 


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

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



Re: [PHP] Php5 SOAP WSDL parsing

2006-01-09 Thread David Grant
Simon,

It would appear you've not included the full message.  Please look at
the source of the message in your web browser.  The space between
unexpected and "in complexType" probably contains an XML tag.

David

Simon Detheridge wrote:
> I'm trying to get PHP5 to talk to a web service that I am developing.
> 
> I have created a wsdl for the service
> (http://www.symgate.com/symgate/symgate.wsdl) and am trying to get PHP
> to parse it. (The wsdl validates in a number of tools I've pointed at
> it, including mindreef soapscope and the wsdl analyser on xmethods.net)
> 
> When I try and get PHP5 to read the file, I get an error that it not
> very helpful. My code says:
> 
> try
> {
>  $client = new SoapClient (
> "http://www.symgate.com/symgate/symgate.wsdl"; ) ;
> } catch ( SoapFault $fault ) {
>  echo $fault ;
>  exit ;
> }
> 
> The output says:
> 
> SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: unexpected  in
> complexType in /var/www/localhost/htdocs/soap1.php:5 Stack trace: #0
> /var/www/localhost/htdocs/soap1.php(5):
> SoapClient->__construct('http://www.symg...') #1 {main}
> 
> This is obviously truncated. I've tried looking at the apache2 error_log
> but I can't see any further detail.
> 
> I'd really like to know what PHP's problem is with my wsdl. How can I
> see the full output of this error?
> 
> Thanks,
> Simon
> 


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

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



Re: [PHP] include() problem

2006-01-09 Thread David Grant
Nuno,

Have you considered $_SERVER['DOCUMENT_ROOT']?

David

Nuno Trancoso wrote:
> This may sound dumb, but i have been up all night going through
> php/apache docs, and still have not found an answer..
> 
> Throughout a site i need to include files that are scattered in subdirs,
> sometimes up in the dir tree, sometimes down. Bad design i know but i
> have to live w/ it...
> 
> Problem is in the way Apache/PHP see stuff. If i include /somefile.htm
> in html, it means somefile.htm wich is at site root dir. In PHP it looks
> like it means somefile.htm at SERVER root dir.
> 
> I can use getcwd() and go around truncating/adding to the string until i
> get a path to use with set_include_path() to add the site root dir to
> the include path, but it just seems wrong to waste cycles doing it...
> 
> So, question is, is there a more direct/elegant way to add the site root
> (or any other dir for that matter) to the include path?
> 
> TIA
> Nuno Trancoso
> 


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

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



Re: [PHP] The meaning of and "@"

2006-01-09 Thread David Grant
Todd,

The @ operator suppresses error messages.

http://www.php.net/manual/en/language.operators.errorcontrol.php

David

Todd Cary wrote:
> I have not been able to find in the Online Manual the use of the "@"
> symbol as in
> 
> while ([EMAIL PROTECTED]($sqlID, MYSQL_BOTH)){
> 
> Is that a "pointer"...address of...?
> 
> Todd
> 


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

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



Re: [PHP] Executing a string

2006-01-09 Thread David Grant
Philip Hallstrom wrote:
> http://us2.php.net/eval

Pay close attention to the oft-used quote from Rasmus Lerdorf:

"If eval() is the answer, you're almost certainly asking the
wrong question"

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

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



Re: [PHP] php + mysql - timstamp - calculate hours remaining

2006-01-10 Thread David Grant
Gregory,

Gregory Machin wrote:
> I have a table with a timestamp column and would like to use his to
> calculate the age of the record . how would i go about this...
> I would also like to exicute a mysql stament that pasess the tables and
> removes fields older than say 72 hours. how would i go about this . ?

A timestamp is the time in seconds (since Jan 1 1970), so you can
ascertain the age in seconds by subtracting the stored timestamp from
the current timestamp.

You can find the current timestamp in MySQL using the
CURRENT_TIMESTAMP() function.

Once you have the age of the record, finding 72 hours is fairly trivial
- 72 hours is 259200 seconds (72hrs * 60mins * 60secs).

Therefore your query will be:

DELETE FROM  WHERE CURRENT_TIMESTAMP() -  > 259200

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

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



Re: [PHP] php + mysql - timstamp - calculate hours remaining

2006-01-10 Thread David Grant
Gregory,

David Grant wrote:
> Gregory Machin wrote:
>> I have a table with a timestamp column and would like to use his to
>> calculate the age of the record . how would i go about this...
>> I would also like to exicute a mysql stament that pasess the tables and
>> removes fields older than say 72 hours. how would i go about this . ?
> 
> A timestamp is the time in seconds (since Jan 1 1970), so you can
> ascertain the age in seconds by subtracting the stored timestamp from
> the current timestamp.
> 
> You can find the current timestamp in MySQL using the
> CURRENT_TIMESTAMP() function.
> 
> Once you have the age of the record, finding 72 hours is fairly trivial
> - 72 hours is 259200 seconds (72hrs * 60mins * 60secs).
> 
> Therefore your query will be:
> 
> DELETE FROM  WHERE CURRENT_TIMESTAMP() -  > 259200

Following Albert's reply, the query ought to read:

DELETE FROM  WHERE CURRENT_TIMESTAMP() - UNIX_TIMESTAMP( >
259200

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

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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread David Grant
Sue,

Sue wrote:
> We have a form that contains a Select option for a listing of available 
> dates for the user to choose from.  Right now we have to manually change the 
> dates within the form's Selection list as new dates become available to 
> choose from.  We currently store these available dates in our database, and 
> am wondering if we can somehow extract these dates from the table to display 
> in our form?  This would eliminate alot of maintenance needed to this form. 
> If anyone has any ideas as to reference material etc. that I may look which 
> would give me an idea how to do this using PHP, I'd appreciate it!

I'd recommend reading the PHP manual at:

http://www.php.net/docs.php

There you will find chapters on using various database functions, such as:

MySQL
http://www.php.net/manual/en/ref.mysql.php

PostgreSQL
http://www.php.net/manual/en/ref.pgsql.php

Microsoft SQL Server
http://www.php.net/manual/en/ref.mssql.php

Oracle
http://www.php.net/manual/en/ref.oracle.php

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

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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread David Grant
Jochem,

Jochem Maas wrote:
> teaching noobs to output html while (oun intended) looping thru a
> result set is counter-productive. discuss.

I disagree, however, I do believe attention should be drawn to reasons
why doing so might be considered bad practice.

Even the longest journeys start with small steps, and asking someone new
to PHP to separate various tiers might put them off.

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

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



Re: [PHP] replacing .shtml #exec cgi with php calls

2006-01-10 Thread David Grant
Dr.

The Doctor wrote:
>  and wish to replace it with a php call.

php.net/exec

> Similarly we want to hide a js script.

You want to disable direct requests to the javascript file?  I can't
think of a way that couldn't be trivially circumvented.  You're probably
better off obfuscating the code.

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

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



  1   2   >