[PHP] Cannot Redeclare Function

2002-09-19 Thread Robert Miller

Hello,

My function to read a comma separated text file and return a sorted multi-dimensional 
array will not work if used more than once per page.

I know why I'm having this problem. But, I don't know how to solve it. :-(





Calling it Twice:
$services = tbl2array ("../locations/service.txt", "default", $divdetail['id'], "0");
$collections = tbl2array ("../download/collection.txt", "name", $divdetail['id'], "4");


The Error:
Fatal error: Cannot redeclare compname() in ../tbl2array.inc on line 35


Function Table 2 Array:




--
Robert J. Miller
Internet Support Specialist
Department of Government Services and Lands
P.O. Box 8700, St. John's, NF., A1B-4J6
(709) 729-4520 (phone)
(709) 729-4151 (facsimile)
(709) 778-8746 (pager)

http://www.gov.nf.ca/gsl/
mailto:[EMAIL PROTECTED]
--
Simple things should be simple and hard things
should be possible.
--


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




[PHP] usort will not take variable

2002-09-19 Thread Robert Miller

Hello,

Do you know the answer to this got'tcha? I want to call usort with a variable function 
name. Basically, I want usort to sort any field I specify. Currently, I'm stuck 
declaring a pile of functions and calling usort from if/elseif statements. :-(

Current:
function compname ($a, $b) {
return strcmp ($a["name"], $b["name"]);
}

function comptitle ($a, $b) {
return strcmp ($a["title"], $b["title"]);
}

function compcity ($a, $b) {
return strcmp ($a["city"], $b["city"]);
}

function compdesc ($a, $b) {
return strcmp ($a["description"], $b["description"]);
}

function compfile ($a, $b) {
return strcmp ($a["filename"], $b["filename"]);
}

if ($sortby == "name") {
usort ($result, "compname");
}
elseif ($sortby == "title") {
usort ($result, "comptitle");
}
elseif ($sortby == "city") {
usort ($result, "compcity");
}
elseif ($sortby == "description") {
usort ($result, "compdesc");
}
elseif ($sortby == "filename") {
usort ($result, "compfile");
}


What Works in Theory:
function mysort ($a, $b, $c) {
return strcmp ($a["$c"], $b["$c"]);
}

usort ($result, "$mysort, $sortby");

...but, that chokes.

Your help appreciated. :-)

Rob



--
Robert J. Miller
Internet Support Specialist
Department of Government Services and Lands
P.O. Box 8700, St. John's, NF., A1B-4J6
(709) 729-4520 (phone)
(709) 729-4151 (facsimile)
(709) 778-8746 (pager)

http://www.gov.nf.ca/gsl/
mailto:[EMAIL PROTECTED]
--
Simple things should be simple and hard things
should be possible.
--


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




[PHP] Validating E-mail Accounts

2002-10-31 Thread Robert Miller
Is it possible, or (even better) do you have a sample script that can take a 
user-submitted e-mail address, contact the host, and verify that the account exists?

Thanks,

Rob



[PHP] Browser Sniff (Code Review Encouraged)

2002-02-18 Thread Robert Miller

Hello,

Below is code I hacked up to read a user agent string (i.e. Mozilla/5.0 (Windows; U; 
Windows NT 5.0; en-US; rv:0.9.8) Gecko/20020204
) and return several items including:
- the browser name,
- the browser version,
- the browser's major version number, and
- user definable compatibility listings.

This post is attached so that others may benefit. DISCLAIMER: I've been working with 
PHP for a few months... about as long as I've ever been programming - feel free to 
trust my brain at your own risk. Your thoughts and suggestions are welcome. :-)

ASSUMING CORRECTIONS ARE MADE DUE TO MAILING-LIST COMMENTS, I WILL REPOST THIS CODE.

Cheers, Rob

P.S. Is this the correct forum for tossing code around?



Now for the code...




WEB PAGE: (*.php )   <-- I removed all the HTML for readability.







REQUIRED FILE: (sniff.inc )

 $name , 'version' => $version, 'major' => $major, 
'raw' => $ua );
}
?>





REQUIRED FILE: (ua.inc )

 array (
4 => "true",
5 => "true",
6 => "true"
),
"Netscape" => array (
4 => "true",
6 => "true"
),
"Opera" => array (
5 => "true",
6 => "true"
),
"Mozilla" => array (
0 => "true"
),
);
if ($uaarray[$name][$major]) {
return "1";
}
}
?>



--
Robert J. Miller
Internet Support Specialist
Department of Government Services and Lands
P.O. Box 8700, St. John's, NF., A1B-4J6
(709) 729-4520 (phone)
(709) 729-4151 (facsimile)
(709) 778-8746 (pager)

http://www.gov.nf.ca/gsl/
mailto:[EMAIL PROTECTED]
--
Simple things should be simple and hard things
should be possible.
--


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




[PHP] Adding Dates (To Obtain Future Dates)

2001-11-13 Thread Robert Miller

This problem took a while to figure out. I'm posting the solution so that =
other's may find this example. If you know of a better way, please reply. =
:-)

Cheers,

Rob

Problem: Generate Future Dates:
Sub-Problem: Future Dates are Dictated by Record Type (Permanent or =
Temporary)
The Script:

$cyear =3D date("Y");
$cmonth =3D  date("m");
$cday =3D date("d");
if ($sType =3D=3D p)
{
   $fyear =3D $cyear + 6
   $sExpiry =3D $fyear.$cmonth.$cday;
}
else
{
   $adv =3D $cmonth + 6;
   $newunix =3D mktime(0,0,0,$adv,$cmonth,$cyear);
   $sExpiry =3D date("Ymd", $newunix);
}

$sCreated =3D date("Ymd");
$sUpdated =3D date("Ymd");



It seems weird to have use months possibly greater than 12 ($adv =3D =
$cmonth + 6;), but hey... it works.




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




[PHP] PDF Library Not Working (Call to undefined function)

2001-11-13 Thread Robert Miller

I RTFM but did not find a solution. My head hurts from banging it against =
the wall. :-P

Apache, OpenSSL, MySQL and PHP work fine... but the PDF libraries will not =
work. I used the following configure commands:

PHP:  './configure' '--with-mysql=3D/usr/local/mysql/' '--with-xml' =
'--with-apache=3D../apache_1.3.22/' '--with-curl=3D/usr/local/curl' =
'--enable-shared-pdflib' '--enable-track-vars'

PDFLib: Almost defaults... just turned off Python and C/C++.

I can provide a complete list of configure options and the order they were =
executed if you need them...

The error message when attempting to use the PDFLib functions is:

Fatal error: Call to undefined function: pdf_new() in /usr/local/apache/htd=
ocs/program/dmipps/pdfdemo.php on line 2


Thanks for any help, it's really appreciated.

Rob




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




[PHP] Stripping Unwanted Characters

2001-11-24 Thread Robert Miller

I'm posting this (see below) for two reasons: 1. so that others may benefit, and 2. to 
invite feedback on my code (PHP is the first language I have learned... and I've only 
been doing this for a week or so).

Cheers, Rob

P.S. Has anyone found a good way to parse variables to validate specific formats? For 
example: Canadian postal codes (ZIP codes) are like A1A-1A1. Driver's Licences are 
A123456789.


Problem:
Unwanted characters are often added by users of web based forms. This causes problems 
when storing the data, especially given the constraints of a database such as MySQL.

Solution:
Evaluate each variable, character by character, and (if true) add it to a new variable 
which may be used.







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