[PHP-DB] Re: php and mssql on seperate servers

2008-04-24 Thread Peter Westergaard

Rick Taylor wrote:
I'm new to PHP and having issues.  We have seperate servers for them.  
We can use ODBC to test the connection and it works fine.  However, when 
we try to run the site we get a message of *** Error: Unable to Connect 
to Database. Please Try Again Later. ***


We are using a custom app that we aren't getting a lot of assistance 
with. The relevant lines in the app are:

define(DBHOST, //database server name);
define(DBUSER, user);
define(DBPASS, password);

if(!$dbCon=mssql_connect(DBHOST,DBUSER,DBPASS)) $error = Unable to 
Connect to Database. Please Try Again Later.;


Can anyone assist a noob php user?

thanks


Thanks for removing any extraneous/irrelevant code.  Nice, well-laid-out 
question.


The obvious follow-up-question presents itself, so forgive me for asking 
if I'm underestimating, but you didn't mention whether or not you were 
quoting it verbatim, or whether you had replaced your database host, 
userid, and password from the code before you pasted it here.


Just in case it's the really obvious problem, you should be aware that 
you are expected to fill in those lines as relevant to your MSSQL server.


For example, if the MSSQL serer was living on a server called 
TORFOX001 (or //TORFOX001 in the MS local-network naming format), 
and you'd set it up with a userid zippy with password pinh34d, those 
lines should be modified to read:


define(DBHOST, //TORFOX001);
define(DBUSER, zippy);
define(DBPASS, pinh34d);

-P

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



[PHP-DB] Re: php-db Digest: Sending multiple values from a form having same field names.

2008-03-19 Thread Peter Westergaard

Your line :

input type=hidden name=field_id value=?php echo $field_id;? /


Should probably be:

input type=hidden name=?php echo $field_id; ? value=?php echo 
$field_id;? /


So that each field's name isn't the string field_id, but rather is 
each field's unique ID.




Hi,

How can I send multiple values from a form to be stored in a database, as
name of the fields is the same?

For example:

?php
foreach ($field_data as $field) {

 $field_name=$field[field_name];
 $field_id=$field[field_id];
 $datatype=$field[datatype_name];

?
input type=hidden name=field_id value=?php echo $field_id;? /
tr
tdstrong?php echo $field_name;?strong/td
?php
 if ($datatype==text || $datatype==integer) {
echo tdinput type=\text\ name=\field_data\/td;
 }
 elseif ($datatype==textarea) {
  echo tdtextarea rows=\10\ cols=\100\
name=\field_data\/textareabr/td;
  }
  echo /tr;
}
?

This creates a form with field names and text box or textarea box next to
each field name depending on the datatype. After the user enters the
values in the text or textarea and clicks submit, the values should get
stored in a database. But what is happening is that only the value entered
in the last field of the form is getting entered into the database.
This code is embedded in an application which is having an inbuilt
structure of taking the values from a form in a hash. Since key is the
same (i.e. field_id) everytime, the value gets overwritten and only the
last value gets stored in db. But I am not able to work out a solution for
this.
I hope I am able to make my problem clear enough.

Thanks,
Suamya.

 
-
DISCLAIMER:- 
  The information in this e-mail is confidential, and is intended 
solely for the addressee or addressees. If you are not the intended recipient,
 please delete the mail and kindly notify the sender of misdelivery. Any 
unauthorised use or disclosure of the contents of the mail is not permitted 
and may be unlawful.

-

 Scanned By MailScanner

  




Subject:
Re: [PHP] Fastest way to get table records' number
From:
Daniel Brown [EMAIL PROTECTED]
Date:
Wed, 19 Mar 2008 09:42:07 -0400
To:
Shelley [EMAIL PROTECTED]

To:
Shelley [EMAIL PROTECTED]
CC:
[EMAIL PROTECTED], PHP DB php-db@lists.php.net


On Tue, Mar 18, 2008 at 11:43 PM, Shelley [EMAIL PROTECTED] wrote:
  

Hi all,

 What do you think is the FASTEST sql to get the total number of a table
 with millions of records?



That question would be better on the PHP-DB list, so for archive's
sake, I'm CC'ing that list.

$sql = SELECT COUNT(*) FROM your_table;

  



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



[PHP-DB] Re: Kesalahan posting: Don Komo

2008-03-19 Thread Peter Westergaard

Oops, I'm sorry, recovering from a 102 fever the other day.  :)

You don't want duplicate field IDs anywhere, really.  The hidden fields 
are probably completely unnecessary; what do you use them for?


It's the latter section you really need to correct, however, where each 
data field's name is being set to field_data all the time.  That's not 
going to help you push it back into the database.  the data won't be 
distinguished, and all but one will be discarded.   also, in my 
suggested corrections, I assume you're passing default values to this 
page in the field_data elements.


-P


?php
if ($datatype==text || $datatype==integer) {
   echo tdinput type=\text\ name=\$field_id\ 
value=\$field_data\/td;

}
elseif ($datatype==textarea) {
 echo tdtextarea rows=\10\ cols=\100\
name=\$field_id\$field_data/textareabr/td;
 }
 echo /tr;
}
?





Your line :

input type=hidden name=field_id value=?php echo $field_id;? /


Should probably be:

input type=hidden name=?php echo $field_id; ? value=?php echo 
$field_id;? /



So that each field's name isn't the string field_id, but rather is 
each field's unique ID.




Hi,

How can I send multiple values from a form to be stored in a 
database, as

name of the fields is the same?

For example:

?php
foreach ($field_data as $field) {

 $field_name=$field[field_name];
 $field_id=$field[field_id];
 $datatype=$field[datatype_name];

?
input type=hidden name=field_id value=?php echo $field_id;? /
tr
tdstrong?php echo $field_name;?strong/td
?php
 if ($datatype==text || $datatype==integer) {
echo tdinput type=\text\ name=\field_data\/td;
 }
 elseif ($datatype==textarea) {
  echo tdtextarea rows=\10\ cols=\100\
name=\field_data\/textareabr/td;
  }
  echo /tr;
}
?

This creates a form with field names and text box or textarea box 
next to

each field name depending on the datatype. After the user enters the
values in the text or textarea and clicks submit, the values should get
stored in a database. But what is happening is that only the value 
entered

in the last field of the form is getting entered into the database.
This code is embedded in an application which is having an inbuilt
structure of taking the values from a form in a hash. Since key is the
same (i.e. field_id) everytime, the value gets overwritten and only the
last value gets stored in db. But I am not able to work out a 
solution for

this.
I hope I am able to make my problem clear enough.

Thanks,
Suamya.

 
- 

DISCLAIMER:-   The information in this e-mail is 
confidential, and is intended solely for the addressee or addressees. 
If you are not the intended recipient,
 please delete the mail and kindly notify the sender of misdelivery. 
Any unauthorised use or disclosure of the contents of the mail is not 
permitted and may be unlawful.
- 



 Scanned By MailScanner

 



Subject:
Re: [PHP] Fastest way to get table records' number
From:
Daniel Brown [EMAIL PROTECTED]
Date:
Wed, 19 Mar 2008 09:42:07 -0400
To:
Shelley [EMAIL PROTECTED]

To:
Shelley [EMAIL PROTECTED]
CC:
[EMAIL PROTECTED], PHP DB php-db@lists.php.net


On Tue, Mar 18, 2008 at 11:43 PM, Shelley [EMAIL PROTECTED] wrote:
 

Hi all,

 What do you think is the FASTEST sql to get the total number of a 
table

 with millions of records?



That question would be better on the PHP-DB list, so for archive's
sake, I'm CC'ing that list.

$sql = SELECT COUNT(*) FROM your_table;

  






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



[PHP-DB] Re: A little SQL help

2008-01-31 Thread Peter Westergaard

Bastien,

I think it would help if you described what result you were expecting, 
what version of SQL you're using, and where your error is occurring. 

I'm going to assume you're looking for a list of tours (including event 
start and end dates, event name, and result) for a specific angler (in 
this case, angler 1). 

I personally would avoid putting the CASE logic into the SQL statement.  
Just pull angler_results.result from the query and use PHP logic to 
output N/A instead of the results if it's NULL, at output time, 
especially if that's where you're having your problem.


What problem are you actually encountering though?

-P




Hi All,
 
Got myself stuck in a little sql here and can't seem to work out what I am doing wrong
 
SELECT 
  DISTINCT (tour.record_id), tour.event_start_date, tour.event_end_date, tour.event_name,CASE WHEN result is NULLTHEN 'N/A'ELSE angler_results.resultEND CASE 
FROM 
  tourLEFT OUTER JOIN angler_results 
ON angler_results.tour_id = tour.record_idWHERE angler_results.angler_id =1
 
where the table TOUR is as above in the primary part of the select and table ANGLER_RESULTS is (record_id, tour_id, angler_id, result)
 
 
Any ideas?
 
Bastien
 
  


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



[PHP-DB] Re: php-db Digest 14 Jan 2008 19:48:27 -0000 Issue 3947

2008-01-14 Thread Peter Westergaard

Miguel -

MD5() is a hash function, not an encryption function. A hash function 
cannot be reversed. 

One of the reasons some sites use MD5() for passwords is so that the 
passwords are never even stored on the server, only the hash.   So even 
the site's database admin can't figure out the passwords of users. 

A hash is a little like a checksum.  Two files can have the same 
checksum even if they're completely different files.  But good luck to 
you if you want to CREATE a file with a specific checksum. 


-Peter





Is there a function opposite to md5()??

  


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



[PHP-DB] Content Management

2005-03-22 Thread Peter Westergaard
So I was looking at PHP products the other day, and I realized there are a
few areas of web development in which I'm utterly ignorant. The most
important, right now, is Content Management.

(i.e. You design a site so that the client can manage it after you leave,
even if they don't know HTML, and preferably can even farm out
sub-sections of the site to other team members).

I've heard that PHP-Nuke and PostNuke are powerful and free (free is good
here) but fairly complex. I've also seen good reviews of SubDreamer, less
powerful than the *Nukes but also less complicated and easier for clients
to understand.

I'm helping to provide a community website for a condo, with mostly-static
content (regulations, by-laws, forms, etc) and frequent-update content
(committee events, board of directors' meeting minutes, newsletters, home
tips, area news, etc), so my needs aren't very complicated.

Anyone have any practical experience to share?

Apologies if this has been rehearsed a thousand times before, I see
discussions pop up in the archive but they never seem to come to a
concensus so I'm going to risk asking again...

-P


-- 
Peter @ westergaard .ca

A byte walks into a bar and orders a pint. Bartender asks him What's
wrong? Byte says Parity error. Bartender nods and says Yeah, I thought
you looked a bit off.

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



[PHP-DB] Re: PHP Max execution time

2004-07-15 Thread Peter Westergaard

Lisi [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am running a script (called through a browser) that checks entries in a
 table one at a time. As the table has grown, the script takes longer to
run
 than is allowed - 30 seconds.

Of course, I have to ask... is there absolutely no way to optimize your
table so as to use an index or two, or to add a few extra columns to handle
requisite calculations so that you don't need to process each row every
time?

-P

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



[PHP-DB] Re: Restrict account access to single user

2004-07-15 Thread Peter Westergaard
 In other words, how do we prevent two users from using the same password
to access the same account at the same time?

There are a few strategies I'd consider... each has plusses and minuses.

1) Lock to one IP.  Keep a table with the most recent IP address, and the
most recent access time.  Any requests coming in within (x) minutes of the
last request, but with a new IP address are blocked.  Downside, people with
rotating IP addresses (doesn't AOL do this?) will be virtually unable to use
the system.  Also, people who switch connections in less time than (x)
minutes will have to wait for their login to expire before re-connecting,
unless they explicitly log out.

2) Lock to a GUID in a session variable.  Keep some sort of GUID in a
session variable open with the logged in user's session.  Tag that user's
account with the GUID (or even, I suppose, with the session identifier?) and
the last access time.  If a new request comes in with a different session
identifier, within a (x) minutes of the last request, block it.  Downside,
people who switch connections (or who close and reopen their browsers) in
less time than (x) minutes will have to wait for their login to expire
before re-connecting, unless they explicitly log out.

3) Prevent flip-flops.  Choose either of the above two methods, and if the
user's data changes, track that in a table which tracks the 3 (or 5, or
whatever) most recent distinct connections.  If a PREVIOUS connection
attempts to interact within a certain time window, lock out one or both for
a certain period.  Advantage - allows a user to recover from an inadvertent
disconnection gracefully.  Disadvantage - malicious users who manage to
somehow steal the connection information could deny service and can inject
transactions until the existing connection attempts a new action.

I'd probably go with 3, but it is more work.

Very curious to hear what others are thinking, though.
-P


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



[PHP-DB] Re: session_start

2004-07-15 Thread Peter Westergaard
Steve Butzel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 It appears that Apache/PHP still thinks the session.save_path is /tmp,
even
 though I changed this in php.ini-recommended and php.ini-dist. **What am I
 doing wrong?**

Have you changed it in the version of php.ini which was copied to your
windows system folder?

That's the version which matters.  php.ini-recommended and php.ini-dist are
just the templates you can use as a starting point to create your system
php.ini.

-P

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



Re: [PHP-DB] Mysql and rollbacks

2004-07-14 Thread Peter Westergaard
 I was about to suggest the same, the latest builds of MySQL have theese
 functions from what I knew... I think youll find what you need there.

Thanks, Kim.

Any stable and fairly affordable hosts out there using these latest builds?
Mine is back a few, no transactional functionality that I can discern yet...
but having said that, let me disclaim that I haven't finished my reading on
the subject.

-P

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



[PHP-DB] Re: Hold System

2004-07-14 Thread Peter Westergaard
Could I get a plain-language explanation of the process of a 'hold'?  I'm
not entirely clear what is happening, and what an 'expiry' means in the
context of the hold and what a '#1 position' would represent for a student.

-P

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



Re: [PHP-DB] Re: Hold System

2004-07-14 Thread Peter Westergaard
I guess I'm still not grasping...

Who creates the temporary I'm-trying-to-place-you link between
coordinator and student?  The system automatically, or the coordinator
manually?

What is a #1 position?  How does a student get there?  Who or what
places them there?  How do they leave that position?

-P

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



Re: [PHP-DB] mysql auto increment

2004-07-13 Thread Peter Westergaard
I've done exactly this for a really cheap-and-dirty instance where two
people were doing bulk data entry into two different instances of a mysql
table which would eventually be stitched together.  by giving one a higher
range, the data migration afterwords was very easy.

Other than that, can't imagine a use for this approach.

-P

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



[PHP-DB] Mysql and rollbacks

2004-07-13 Thread Peter Westergaard
I'm developing a site where I anticipate the need to make several updates to
several forms, and I'll want to commit them all at once (i.e. if there's a
failure with any of the transactions, I'd like to be able to back out to
before I started).

Is there a decent way to do this with PHP and Mysql?  Obviously start with
ignoring user interrupt, and I was thinking a fairly easy way to reduce the
risk is to perform numerous tests before attempting any activity, but that
means at least doubling my database activity - does that pose more
performance issues than it solves?

Or has someone else got a good strategy for dealing with this? Perhaps
writing temp-rows, and then executing some sort of stored procedure to move
all the temp-rows to the real tables in one fell swoop?  Or, really, any
wisdom to impart?

-P

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



[PHP-DB] Re: Mysql and rollbacks

2004-07-13 Thread Peter Westergaard
... or, am I barking up the wrong tree with Mysql, and should I change
database platforms?  (You'll never convince me to give up PHP though.
muahaha. Except for sql-level stored procedures where necessary, that is).

-P

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



[PHP-DB] Re: Column Help Needed

2004-07-09 Thread Peter Westergaard
It seems very easy to me, Chris.

Just set up a counter before the loop where you fetch your queries.  Then
output your HTML table structure depending on whether the counter is odd
or even.  You can use modulo arithmethic ($value%2) to determine that.

Something like:

$result = mysql_query(blah blah blah...);
$num-entries = 0;
echo table;
while ($item = mysql_fetch_array($result))
{
  $num-entries++;
  if ($num-entries%2 == 1)
  {
// This is an odd item.
echo trtd;
echo blah; // Whatever you need to output for your result
echo /td;
  } else {
// This is an even item.
echo td;
echo blah; // Whatever you need to output for your result
echo /td/tr;
  }
}
// and finally, if the result ended on a half-row:
if ($num-entries%2 == 1)
  echo tdnbsp;/td/tr;
// now close the table.
echo /table;
// and we're done!

 note, I didn't test this code.  But it should do what you want.

-- 
Peter Westergaard
[EMAIL PROTECTED]

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



Re: [PHP-DB] fetch row DISTINCT

2004-07-09 Thread Peter Westergaard
Lars,

One idea that occurs to me, and it's a tradeoff from Torsten's idea (which
is to read the whole database, and parse out the unique rows), is to first
execute your SELECT DISTINCT distinct_col FROM table, and then walk
through that, and for each one issue a SELECT * FROM table WHERE
distinct_col = {value} LIMIT 1  (For some reason I can't remember the
'LIMIT' syntax right now, so it might be LIMIT 0,1).  More transactions with
the database, but less data actually retrieved from the database.  And if
it's indexed by distinct_col, you should be fine.

Added benefit:  you can apply arbitrary ORDER BY mechanisms to the
individual queries... so it will only show you the most recent, or the
first, or a random entry... all up to you.

-P

 Original Message
Lars Hilsebein [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Sorry, but it's not truly what I am searching for:
The result is not unique.
What I mean is: every entry in the distinct_col should only be delivered
once.
As it would happen when I do the query SELECT DISTINCT distinct_col FROM
table.
But I need to fetch the whole row.

Lars

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



[PHP-DB] PHP Processing

2004-01-05 Thread Peter Westergaard
I'm sorry, I feel dense coming to the list for this, because I'm 
SURE I've read about this in the PHP or Mysql docs, but I can't seem 
to locate where.

Let's say users submit a form which is processed by a PHP page which 
performs a number of MySQL INSERT, UPDATE, and/or DELETE commands.
.

What happens if the user hits Stop or Refresh in their browser 
before the transaction is complete - is there a possibility that 
only some of the MySQL commands will complete?   Not a problem if 
the services are all running well, but I'm thinking if things are 
getting thrashed on the server for whatever reason, it might take 
several seconds to complete the various SQL commands, also increasing 
the likelihood of the user getting bored enough to start playing 
bull in a browser shop.

And since MySQL has no rollback feature that I'm aware of, how would 
you best handle this dangerous potentiality?  Suggestions?  A humble 
request:  Responses which begin with: Don't use MySQL, please include 
a good affordable alternative?

-P

Peter Westergaard
[EMAIL PROTECTED] ###   ICQ#: 10294457
http://www.westergaard.ca/   ###   http://courtly.livejournal.com 
--
'Alright, you guys start coding.  I'll go find out what the customer 
wants.'




===
EASY and FREE access to your email anywhere: http://Mailreader.com/
===

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



[PHP-DB] Cookies with fopen

2003-12-10 Thread Peter Westergaard
Hi all,

Attempting to use PHP to navigate a foreign website, to collect data.  This is thus 
only tangentially related to databases, so I apologize if some feel it's too off-topic.

Is there any way to do something similar to fopen() except to also have PHP present a 
cookie to the foreign webserver as credentials during the HTTP GET?  Anyone done 
something similar? 

-P

Peter Westergaard
ICQ#: 10294457
[EMAIL PROTECTED]
http://www.westergaard.ca
http://courtly.livejournal.com 

---TECHNOLOGY---
Human history becomes more and more a race between education and catastrophe.
- H.G. Wells

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



[PHP-DB] Date Pulldown

2003-11-02 Thread Peter Westergaard
Sorry for what is probably going to be a late reply.  I'm waiting to pick 
someone up at the airport, and the plane was delayed, so I wanted to try my 
hand at answering your question.

First I had to figure out what method you used to pick those dates in the 
first place.  It seems to be...

Today, Yesterday, then 1 day back for a total of 14 days (2 weeks)
Then going 1 week back for a total of 8 weeks (56 days)
Then I'm stumped how you came up with the jump from 9/14 to 8/31 to 
8/1 unless the rule is go back 2 weeks then go back 30 days...
Is there a reason the next rule can't be: go 1 month back for a total of 11 
months?

Here's a little piece of PHP code which will do just about exactly what 
you're looking for, with the rule modification I suggested.  Perhaps it 
will do the trick?  (And, since I'm no guru myself, I welcome comments on 
my suggestion).  It basically works around mktime and date.  Both are 
very good functions to accomplish what you're trying to accomplish.  Read 
up on those and you should be able to handle it.

form name=foo
select name=bdate
?php
	output_date_option ( mktime(0,0,0, date(m), date(d), date(Y)) , 
Today , SELECTED );
	output_date_option ( mktime(0,0,0, date(m), date(d)-1, date(Y)) , 
Yesterday );
	for ($days = 2; $days = 14; $days++) {
	output_date_option ( mktime(0,0,0, date(m), date(d)-$days, 
date(Y)) );
	}
	for ($weeks = 3; $weeks = 7; $weeks++) {
	output_date_option ( mktime(0,0,0, date(m), date(d)-($weeks*7), 
date(Y)) );
	}
	for ($months = 2; $months = 11; $months++) {
	output_date_option ( mktime(0,0,0, date(m)-$months, date(d), 
date(Y))  );
	}

function output_date_option($current_date, $date_string = , $xparams = ) {
	if (!isset($date_string) or $date_string == ) {
		$date_string = date ( D m/d , $current_date );
	}
	echo ( 'OPTION VALUE='.date ( m/d/Y , $current_date ).' 
'.$xparams.''.$date_string );
}
?
/select
/form

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


[PHP-DB] Re: foreach() db brainiacs please help?

2003-09-10 Thread Peter Westergaard
I have a database full of names. each name could be linked to any 
number of
sub-names, each sub-name could be linked to any number of sub-sub-
names, to
infinity (unlikely but possible).

I need to iterate through this nest of names starting with a main 
name; lets
call the main name Peter. Peter could have John, Tim  Mike working 
for him.
Tim could have Greg working for him.


Recursion is your friend.

If you're looking to just export a list of names, then try a function 
which does not return anything, but instead:
- is passed the id of the top
- selects all direct associations to the top
- loops through them (if any):
--- outputting their name
--- invoking the same function with their name as 'top'
- exits.

So, if Andrew has Bob, Cathy, Danielle, and Edward working for him,
and Bob has Frank, Gertrude, and Hector working for him,
and Cathy has Ian and Jill working for her,
and nobody else has any employees:

The first call would be function_name(Peter)
- returns Bob, Cathy, Danielle, Edward
- outputs Bob
- calls function_name(Bob)
--- returns Frank, Gertrude, Hector
--- ouputs Frank
--- calls function_name(Frank)
- returns nothing
--- outputs Gertrude
--- calls function_name(Gertrude)
- returns nothing
--- outputs Hector
--- calls function_name(Hector)
- returns nothing
- outputs Cathy
- calls function_name(Cathy)
--- returns Ian, Jill
--- outputs Ian
--- calls function_name(Ian)
- returns nothing
--- outputs Jill
--- calls function_name(Jill)
- returns nothing
- outputs Danielle
- calls function_name (Danielle)
--- returns nothing
- outputs Edward
- calls function_name (Edward)
--- returns nothing

Make sense?
 




Peter Westergaard
[EMAIL PROTECTED] ###   ICQ#: 10294457
http://www.westergaard.ca/   ###   http://courtly.livejournal.com 
--
'Alright, you guys start coding.  I'll go find out what the customer 
wants.'




===
EASY and FREE access to your email anywhere: http://Mailreader.com/
===

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



[PHP-DB] PHP errors - strange variables causing form corruption?

2003-07-30 Thread Peter Westergaard
I cobbled together a really quick and dirty PHP to run a dice-rolling 
simulator. 

Sometimes, it works great.  Other times, it gets into some weird 
state, when strange extra characters are injected into variable values 
and/or variable NAMES even!  

You can see an uploaded version at http://www.westergaard.ca/dierolling.
php - if you key in something like 30d100+40 k20 (by which I mean 
roll 30 100-sided dice, keep the best 20, and add 40 to the resulting 
sum), then click roll a few times, you'll probably notice that 
at some point, the string +/- in the help text disappears.  The 
next time you click Roll the system will stop giving roll results,
will reset to rolling 3d6, and will ignore input.

I've struggled with this till I'm red in the face.  I'm stumped. 
Please, Help! :)
 
I've also uploaded the source at http://www.westergaard.ca/dierolling.
phpsrc

The webserver at westergaard.ca is Linux, but I've also tested this 
on a Win2000 IIS webserver, and have the exact same results.  

If anyone has any clue what is going on, I'd really appreciate a 
suggestion.  

Thanks!

Peter Westergaard
[EMAIL PROTECTED] ###   ICQ#: 10294457
http://www.westergaard.ca/   ###   http://courtly.livejournal.com 
--
'Our response to being bored and rich is not to discard our possessions 
and live more simply, 
but to buy more stuff to reduce the space in which we might contemplate 
our shame.'
- Stuart Jeffries Robots without a cause




===
EASY and FREE access to your email anywhere: http://Mailreader.com/
===



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



[PHP-DB] (Addendum)

2003-07-30 Thread Peter Westergaard
I guess the .phpsrc is being interpreted as PHP anyhow, so let me 
just include the body of the page, below:

---

?php

# (DEBUG) -- foreach ($HTTP_POST_VARS as $key = $value) print ($key 
= $value br);
# (DEBUG) -- foreach ($HTTP_SERVER_VARS as $key = $value) print 
($key = $value br);
# (DEBUG) -- foreach ($HTTP_ENV_VARS as $key = $value) print ($key 
= $value br);
print (!-- Die Roller for {$HTTP_POST_VARS['roll']} --);

if (isset($roll)) {
mt_srand ((double) microtime() * 100);  # Seed the random number 
generator
$x = 0;
$roll = strtolower($roll);
if (!(strpos($roll,'d')===false)) {
$number = substr($roll,0,strpos($roll,'d'));
if (!$number || $number == 0) $number =1;
$rest = substr(strstr($roll,'d'),1);
if (!(strpos($rest,'-')===false)) {
$highnumber=substr($rest,0,strpos($rest,'-'));
$rest = strstr($roll,'-');
if (!(strpos($roll,'k')===false)) { 
# user has used the keep method
$bonus = substr($rest,0,strpos($rest,'k'));
$keep = substr(strstr($rest,'k'),1);
} else {
$bonus=substr($rest,strpos($rest,'-'));
}
} else if (!(strpos($rest,'+')===false)) {
$highnumber=substr($rest,0,strpos($rest,'+'));
$rest = strstr($roll,'+');
if (!(strpos($roll,'k')===false)) { 
# user has used the keep method
$bonus = substr($rest,0,strpos($rest,'k'));
$keep = substr(strstr($rest,'k'),1);
} else {
$bonus=substr($rest,strpos($rest,'+'));
}
} else {
$bonus = '+0';
if (!(strpos($roll,'k')===false)) { 
# user has used the keep method
$highnumber = substr($rest,0,strpos($rest,'k'));
$keep = substr(strstr($rest,'k'),1);
} else {
$highnumber=substr($rest,strpos($rest,'+'));
}
} 
if (!(strpos($roll,'k')===false)) { 
# user has used the keep method
$keep = trim(substr(strstr($roll,'k'),1));
}
if ($keep == null) {
$keep = $number;
}
if ($keep  $number or !is_numeric($keep)) {
$keep = $number;
echo (bInvalid value for 'k'/b. Keeping all dice rolled. 
p);
}
} else { 
print (Invalid entry. Please use the format: 
i[number]/idi[number]/i(+/-
i[number]/i). brii.e. 3d6+3 or 1d8-1/ip);
$number = 1;
$highnumber = 6;
$bonus = '+0';
$keep = 1;
}

print (number, highnumber, bonus, keep: {$number}, {$highnumber},
{$bonus}, {$keep} p);
echo (Rolling {$number}d{$highnumber}{$bonus}:br\n);
if ($keep  $number) {
echo (Keeping best {$keep} br\n);
}
echo (TABLE BORDER=1\n\tTR\n\t\tTHDie 
#/th\n\t\tTHValue/TH\n\t/TR\n);

$x = 0;
while (++$x = $number) {
$die[$x] = mt_rand(1,$highnumber);
echo 
(\n\tTR\n\t\ttd{$x}/td\n\t\tTD{$die[$x]}/TD\n\t/tr\n);

}
sort($die);
$x = trim($keep);
while ($x++  $number) {
array_shift($die);
}
$total = array_sum($die) + $bonus;
echo (/TABLE\n\n);
if ($bonus  0) echo (BBonus:/b {$bonus} BR);
if ($bonus  0) echo (BPenalty:/b {$bonus} BR);
echo (PFONT SIZE=5BTotal:/b {$total}/font);
} else {
$number = 3; $highnumber = 6; $keep = 3;
}

?

FORM ACTION= METHOD=POST
Roll dice:input type=text size=30 name=roll value=?php 
echo ($number.'d'.$highnumber); 
if ($bonus  0) echo $bonus;  
if ($keep != $number) echo k{$keep}; 
? br
input type=submit name=submit value=Roll
/form

Enter the dice as follows: inum/i d inum/i (+/- inum/i) 
(k inum/i) p uExplanation:/u The first three parameters 
are self-explanatory, br and the fourth number ('k') is an option 
to keep the best (inum/i) rolls.  br Obviously k (if it is 
specified) must be less than the total number of dice rolled.p
uExamples/u: 4d6 k3   4d10-3 ... 1d8+3 ... 2d20 ... (etc.) p




===
EASY and FREE access to your email anywhere: http://Mailreader.com/

[PHP-DB] Re: php-db Digest 11 Dec 2002 07:34:07 -0000 Issue 1566

2002-12-11 Thread Peter Westergaard
At 07:34 AM 12/11/2002 +, you wrote:


I understand that the column name does not normally need quotes, but
without quotes on the column name I get a mysql error message about no
column named 'id'.  Unfortunately, I cannot even get the UPDATE statement
working outside of PHP through an direct SQL statement.  Everything looks
like it should work, but the affected columns is always zero, and obviously
the atime column is not getting the timestamp.
This is quite frustrating.  Thanks again for the help.  Hopefully
someone will come up with something to help me get this working.


hyphen (-) is a funny character in a column.  If you quote the column name 
with BACKQUOTES, you should be okay though.

i.e. SELECT * FROM `hyphen-table` WHERE `hyphen-column` = 1

If you check out the SQL generated by recent versions PHPMyAdmin, you'll 
see what I mean.

-Peter


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



[PHP-DB] Complex (for me) table join - help please?

2002-04-19 Thread Peter Westergaard

I'm trying to perform a join that seems like it should be simple, but I'm just 
ending up in a morass.  Hopefully someone who's standing a step or two back from the 
problem can help me solve this one...

What I have:

Table A (Category): with a 3-tier category structure:
-Nature
-Category
-Sub-Category

Table B (Responsibility): with a reference to Table A, and a client id, and the id of 
a person responsible for that Sub-category for that client.
-TableA-id
-Client-id
-Person-id

So, what I want is a simple select which will fetch for me all rows in (Category) with 
the relevant person from (Responsibility) if there is one for a specific Client, but 
with a blank in that column if there isn't one. 

ie. (Category) has 10 entries (let's call them Ca-Cj), and (Responsibility) has 5 
entries for Client 1 (Ca,Cb,Cc,Cd,Ce) and 3 entries for Client 2 (Cd,Ce,Cf).

When I run the select for Client 1, I'd like to see... 
Ca - person
Cb - person
Cc - person
Cd - person
Ce - person
Cf - 
Cg - 
Ch - 
Ci - 
Cj - 

And when I run the same select for Client 2 I'd like to see:

Ca - 
Cb - 
Cc - 
Cd - person
Ce - person
Cf - person
Cg - 
Ch - 
Ci -
Cj - 

I tried a basic outer join type select, and of course for Client 1 I miss Cf, and 
when I use it for Client 2 I miss Ca-Cc.  

Anyone able to sort me out here?

I need to use a basic Select (instead of building a temp table or using variables in a 
PHP script) because another database process that I don't control needs to do the same 
thing.  

Think it's possible, or am I going to have to go and insert records into 
Responsibility for every entry in Category for every Client, resulting in 
(#Categories x #Clients) rows?  (The latter idea sure doesn't make me happy, but it 
would be 'easier' to build, if not to maintain.  (And, as you can appreciate, since 
I'm not the one maintaining it, I'm like THAT CLOSE from just going that way and 
saying 'screw em'!)

Hopefully,
-Peter Westergaard



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




[PHP-DB] RE: phpMyAdmin - blank screen?

2002-01-14 Thread Peter Westergaard


hallo guys!

i'm a newbie in php..I've installed phpMyAdmin on my pc, together with MySQL
and Apache with PHP 4 on Win98.

the index.php page is blank! any ideas/suggestions from u ppl?

gracias!

Can you post some of the code from your index.php?
Have you installed it all correctly, ie placed index.php in your document 
root and configured Apache to work with PHP?  I've personally had it all 
running on Win98 before so I know it's doable. just might take some tweaking!

Cheers,
-Peter


-- 
PHP Database 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-DB] RE: permissions for writing file

2002-01-14 Thread Peter Westergaard


I'm trying to use PHP and MySQL to query a table and write the contents to a
new file. When run the command to outfile it tells me I don't have
permissions. This is on a Unix machine.

I haven't run this on Unix myself, but I think this answer might be 
useful.  Someone please correct me if I'm out to lunch.

Check which user account is actually running the PHP process (or the Apache 
process if it's not the CGI).  Then ensure that it (the PHP user) has the 
rights to create files in the specified directory.

Be careful here though, because you will be giving malicious visitors more 
tools to work with.

Cheers,
-Peter



-- 
PHP Database 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-DB] RE: LIMIT and get_num_rows

2002-01-14 Thread Peter Westergaard


but presumably if i'm doing a SELECT count(*) FROM Designs WHERE Keywords
LIKE %sport%
followed by a SELECT * FROM Designs WHERE Keywords LIKE %sport% LIMIT 0,20

it's still using nearly as much processing time as just returning all the
designs and just using a get_num_rows and then only using the first 20?

I absolutely think it will not.

After all, the table record count should be able to reference the index, 
(you are running this query against an indexed 'Keywords' column yes?), 
while assembling the table of returned data will take quite a bit more 
memory, which is what you're really trying to cut down, I think.

Cheers,
-Peter


-- 
PHP Database 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-DB] RE: Pulling a long list of data stalls PHP

2002-01-10 Thread Peter Westergaard

At 08:03 AM 1/9/2002 -0800, Max wrote:


Just curious, but which version of PHP are you using, the ISAPI or CGI.
I've tried the isapi version before and had problems like this.  PHP
would crash and leave orphaned instances of php.  If your using the
isapi version try the cgi and see if it works for you.

Actually, this was using the CGI version.  I haven't had a single problem 
since I went back to php-ini-dist.  Lightning fast response too.
Anyone know what setting might have caused the weirdness?  Someday I'll go 
through and figure it out.

-P


-- 
PHP Database 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-DB] Re: Pulling a long list of data stalls PHP (SOLVED!)

2002-01-09 Thread Peter Westergaard

Thanks to Miles!

The problem, for anyone who is going through this themselves lay 
(in my case) with my php.ini file - evidently my fat fingers copied 
the 'recommended' php.ini file, instead of the 'distro' php.ini file.


The 'Recommended' file contains a few optimizations and security 
patches, recommended for a live-on-the-internet application.  I don't 
know what about that setup was incompatible with my application, 
but something was.  Maybe some day when I have a clue I'll figure 
it out.  

For now, I'm back up and running.  
Thanks, Miles.
-Peter 



===
EASY and FREE access to your email anywhere: http://Mailreader.com/
===



-- 
PHP Database 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-DB] Re: Insert data selected from drop down list into mySQL table

2002-01-09 Thread Peter Westergaard

George, 


When you use:


pre
OPTION value=$prd$prd/OPTION 
/pre


Why not use the Product ID in the VALUE tag, and use the Product 
NAME between the OPTION /OPTION tags?
That way, the VALUE is what is selected, and you can then use an 
SQL INSERT or UPDATE command to push that into the destination table.



One less check against the database, right?

-Peter 



===
EASY and FREE access to your email anywhere: http://Mailreader.com/
===



-- 
PHP Database 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-DB] RE: query and count

2002-01-09 Thread Peter Westergaard

It seems like what you're looking for is first to do a SELECT DISTINCT 
.. to find all the unique topic names in the system.  

This, in your case, would present you with Billie, Bill, Bret, ... etc.

Then, in a loop as you traverse this result, create a query for the 
count of each of these specifically.  

That's how I would approach it.  Don't forget to index your database 
based on the topic names, if it has very many records.  

Cheers,
-- Peter





===
EASY and FREE access to your email anywhere: http://Mailreader.com/
===



-- 
PHP Database 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-DB] Re: Pulling a long list of data stalls PHP

2002-01-08 Thread Peter Westergaard

Miles, you wrote:
 Is your table indexed on the field your query is based on? That will
 greatly speed up the query.
 
 Miles Thompson

I'm afraid in my case, the query needs to be pretty much a complete table dump.

Even if I filter a subset the data, my relational DB experience (not deep,
admittedly, and only with enterprise products like Oracle and ... ugh...
MSSql) tells me that indices on tables less than a few thousand entires
cost more in upkeep than they gain in response.  And this is only about 
300-400 rows... and more to the point, this happens when I pull more than 
30 of them or so!  I feel that something MUST be wrong!

But all of that aside, the problem isn't just that it takes a long 
time... the
problem seems to be that it literally *crashes* the instance of PHP! (The
webpage never finishes loading, and the CPU meter drops back down to idle
levels, and if I cancel the webpage, I leave an orphaned instance of
PHP.exe running, which I cannot kill even from my Win2000 Task Manager).

I mean, I'm a newbie and I'll admit that, but that just Don't seem Right.

Does ANYONE have any idea what might be happening and how I can fix it?
Please? :)

-P


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




Re: [PHP-DB] Re: Pulling a long list of data stalls PHP [_SOLVED_]

2002-01-08 Thread Peter Westergaard

Thanks to Miles!

The problem, for anyone who is going through this themselves lay (in my 
case) with my php.ini file - evidently my fat fingers copied the 
'recommended' php.ini file, instead of the 'distro' php.ini file.

The 'Recommended' file contains a few optimizations and security patches, 
recommended for a live-on-the-internet application.  I don't know what 
about that setup was incompatible with my application, but something 
was.  Maybe some day when I have a clue I'll figure it out.

For now, I'm back up and running.
Thanks, Miles.
-Peter


-- 
PHP Database 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-DB] Pulling a long list of data stalls PHP

2002-01-07 Thread Peter Westergaard

Hi,

I'm attempting to pull about 300 rows from a mysql database, (all rows in 
the table).
I can pull the first 10, the first 20, the first 30, no problem.  (using 
LIMIT (start), (10|20|30)... in the SQL statement)

But if I attempt to pull all of them (no LIMIT clause), or even the first 
(x) where (x) is much more than 30, using a simple while 
(mysql_fetch_row($sql,$db))... construction, IE just idles, tells me it is 
loading the page, and never displays anything.   When I press STOP, I 
have a hung PHP process in my Task Manager, which I cannot kill!

Does anyone know what could cause this behaviour?  It seems so simple, what 
I'm trying to do, that I'm going insane.
Very frustrated.

Please, someone help a poor newbie out!
-P


-- 
PHP Database 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-DB] Re: Is this kind of querry possible in MySQL?

2002-01-07 Thread Peter Westergaard

Assuming that c.province is the province name, and c.province_id is the 
province code, and U.province_id is the province code from the User table, 
I don't see where in your statement you have filtered the search down to 
just the province_id for the CURRENT USER.

I think you need something like ... and U.user_id = (current user_id).

Yes?
-Peter 


-- 
PHP Database 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-DB] RE: Formated Results

2002-01-07 Thread Peter Westergaard

Barry,

Since you're posting to an HTML page, you need BR and/or P to produce 
formatting.
I'm guessing that if you look at the SOURCE for the web page you've 
produced, you'll see all the formatting.

So, you can either fetch the lyrics and replace all line-ends with BR, or 
else use the tags PRE/PRE or something similar to include the text in 
raw form on the webpage.  The PRE tag is going to be easier, but probably 
quite a bit uglier.

Hope that's what you were looking for?
-P


-- 
PHP Database 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]