Re: [PHP-DB] Some data manipulation

2002-10-06 Thread Hatem Ben

i was trying to do it with preg_replace, but this is much better

thanks a lot,
Hatem

- Original Message -
From: Rasmus Lerdorf [EMAIL PROTECTED]
To: Hatem Ben [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Sunday, October 06, 2002 3:09 AM
Subject: Re: [PHP-DB] Some data manipulation


 So loop through and check the last char.  Am I missing something that
 makes this harder than the obvious:

   foreach($arr as $key=$val) {
 $end = $val[strlen($val)-1];
 switch($end) {
case '1':  $arr[$key] = substr($val,0,-1); break;
case '2':
case '3':  $arr[$key] = substr($val,0,-1) . ((int)$end + 4); break;
 }
   }

 Not sure if you always want to add 4 to the last char when it ends in 2 or
 3, but that was the only info you gave.

 -Rasmus

 On Sun, 6 Oct 2002, Hatem Ben wrote:

  hey all
 
  i have a database of arrays like this :
  Array
  (
  [0] = 2-
  [1] = 8b2
  [2] = 8#c3
  [3] = 8b2
  [4] = 8#f2
  [5] = 4a2
  [6] = 8a1
  [7] = 8a2
  [8] = 4a2
  [9] = 4a2
  [10] = 4a2
  
  )
 
  i just need to change in every string the last value when it is equal to
1,2
  or 3
  ex ::
   [0] = 2-won't be changed  [0] = 2-
   [1] = 8b2  will be changed to [1] = 8b6
   [2] = 8#c3 will be changed to[2] = 8#c7
   [6] = 8a1   will be changed to[6] = 8a
 
  and so on
 
  Thanks for any help
  Hatem
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


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




[PHP-DB] passing array to next page

2002-10-06 Thread Smita Manohar

hello all,

im having variable $item_id_v = 100
when i want to pass this value to the page item_maint.php i use the 
statement :
?php echo  A HREF=\item_maint.php?item_id=$item_id_v\ Click /A ?

i need to pass array using such way. but i dont know how to do that.
can anyone pls help me out for this.
thnx in advance

smita.



_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




RE: [PHP-DB] passing array to next page

2002-10-06 Thread John W. Holmes

Look at the serialize() function or use sessions.

www.php.net/serialize

---John Holmes...

 -Original Message-
 From: Smita Manohar [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, October 06, 2002 6:33 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] passing array to next page
 
 hello all,
 
 im having variable $item_id_v = 100
 when i want to pass this value to the page item_maint.php i use the
 statement :
 ?php echo  A HREF=\item_maint.php?item_id=$item_id_v\ Click /A
?
 
 i need to pass array using such way. but i dont know how to do that.
 can anyone pls help me out for this.
 thnx in advance
 
 smita.
 
 
 
 _
 Join the world's largest e-mail service with MSN Hotmail.
 http://www.hotmail.com
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




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




RE: [PHP-DB] Some data manipulation

2002-10-06 Thread John W. Holmes

Write a function to do whatever you want to each element, then use
array_walk().

---John Holmes...

 -Original Message-
 From: Hatem Ben [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, October 05, 2002 6:49 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Some data manipulation
 
 hey all
 
 i have a database of arrays like this :
 Array
 (
 [0] = 2-
 [1] = 8b2
 [2] = 8#c3
 [3] = 8b2
 [4] = 8#f2
 [5] = 4a2
 [6] = 8a1
 [7] = 8a2
 [8] = 4a2
 [9] = 4a2
 [10] = 4a2
 
 )
 
 i just need to change in every string the last value when it is equal
to
 1,2
 or 3
 ex ::
  [0] = 2-won't be changed  [0] = 2-
  [1] = 8b2  will be changed to [1] = 8b6
  [2] = 8#c3 will be changed to[2] = 8#c7
  [6] = 8a1   will be changed to[6] = 8a
 
 and so on
 
 Thanks for any help
 Hatem
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




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




Re: [PHP-DB] $_POST And $_REQUEST

2002-10-06 Thread Marco Tabini

$_REQUEST is an associative array consisting of the contents of $_GET,
$_POST, $_COOKIE, and $_FILES

Also, they are not function but arrays, as Hatem said. 
You can usa $_REQUEST as a catch-all that provides you with both what
was passed to your page through the URL query ($_GET) and what was
posted to the webserver through HTTP ($_POST). IMHO, it's always better
to use the more specific arrays ($_GET or $_POST), because that makes
your pages more accurate and, therefore, less open to possible attacks.


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




RE: [PHP-DB] passing array to next page

2002-10-06 Thread Marco Tabini

Also, if you decide to use serialize() and unserialize() through the
post variables (I'd recommend against using it in the query URL because
some browsers have a limit as to how much data they can fit into it),
you should consider encrypting it in some way or at least appending an
encrypted CRC to it. This is to prevent a malicious user from modifying
the contents of the array in a way that may be dangerous to PHP or to
your code.

Take a look at these functions:

http://www.php.net/manual/sk/printwn/function.crc32.php

Calculates a CRC

http://ca.php.net/manual/en/ref.mcrypt.php

Family of extensions that provide encryption capabilities (not available
on Win32, I believe)





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




[PHP-DB] Noob error question

2002-10-06 Thread Noah Smith

This may be a rather noob question, but:

I make several requests against a mysql db roughly of the form:
mysql_connect
mysql_select_db
mysql_query
mysql_close

This will work for several connections (and sometimes all connections 
over the course of the script)

On occassion, the script will be unable to connect at all, and sometimes 
it is not able to connect randomly within the script:

Thanks,

Noah


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




[PHP-DB] possible Error in Querydefiniton

2002-10-06 Thread Ruprecht Helms

Hi,

I've some trouble with the following querydefinition

?
  mysql_connect(localhost,root);
  mysql_db_query(finace,INSERT INTO buchung (Bezeichnung) VALUES ('b'))
  or die (Query ungültig);
?

and this is the tablestructur

+-+--+--+-+-++--
| Field   | Type | Null | Key | Default | Extra  |
Privileges  |
+-+--+--+-+-++-
| ID  | int(11)  |  | PRI | | auto_increment |...
| Bezeichnung | varchar(30)  | YES  | | ||
| Art | char(1)  | YES  | | ||
| Brutto  | char(1)  | YES  | | ||
| Betrag  | decimal(8,2) | YES  | | ||
| Steuer  | int(11)  |  | | 0   ||
+-+--+--+-+-++--

By execution the script says that the query die. I don't know why.


Ruprecht Helms   IT-Service und Softwareentwicklung

Tel/Fax:  +49[0]7621 16 99 16
email:  [EMAIL PROTECTED]
Homepage:  http://www.rheyn.de

-

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




RE: [PHP-DB] possible Error in Querydefiniton

2002-10-06 Thread John W. Holmes

You can find out why with mysql_error(), but it's probably because you
haven't selected a database with mysql_select_db().

---John Holmes...

 -Original Message-
 From: root@linux [mailto:root@linux] On Behalf Of Ruprecht Helms
 Sent: Sunday, October 06, 2002 3:25 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] possible Error in Querydefiniton
 
 Hi,
 
 I've some trouble with the following querydefinition
 
 ?
   mysql_connect(localhost,root);
   mysql_db_query(finace,INSERT INTO buchung (Bezeichnung) VALUES
 ('b'))
   or die (Query ungültig);
 ?
 
 and this is the tablestructur
 

+-+--+--+-+-++--
--
 --
 | Field   | Type | Null | Key | Default | Extra  |
 Privileges  |

+-+--+--+-+-++--
--
 -
 | ID  | int(11)  |  | PRI | | auto_increment
|...
 | Bezeichnung | varchar(30)  | YES  | | ||
 | Art | char(1)  | YES  | | ||
 | Brutto  | char(1)  | YES  | | ||
 | Betrag  | decimal(8,2) | YES  | | ||
 | Steuer  | int(11)  |  | | 0   ||

+-+--+--+-+-++--
--
 --
 
 By execution the script says that the query die. I don't know why.
 
 
 Ruprecht Helms   IT-Service und Softwareentwicklung
 
 Tel/Fax:  +49[0]7621 16 99 16
 email:  [EMAIL PROTECTED]
 Homepage:  http://www.rheyn.de
 
 -
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




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




RE: [PHP-DB] Noob error question

2002-10-06 Thread John W. Holmes

Is this on a live site, or one with just this test script running? You
may be running into the max_connections of mysql. 

You're not connecting for _every_ query on the page, are you? You should
have just one connect at the beginning, do all of your queries, then
close at the end of the script.

---John Holmes...

 -Original Message-
 From: Noah Smith [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, October 06, 2002 2:55 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Noob error question
 
 This may be a rather noob question, but:
 
 I make several requests against a mysql db roughly of the form:
 mysql_connect
 mysql_select_db
 mysql_query
 mysql_close
 
 This will work for several connections (and sometimes all connections
 over the course of the script)
 
 On occassion, the script will be unable to connect at all, and
sometimes
 it is not able to connect randomly within the script:
 
 Thanks,
 
 Noah
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




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




[PHP-DB] DBF question: column names?

2002-10-06 Thread suzerain.studios

Hi there.

I'm not familiar with DBF files, or the PHP dbase functions.  I've 
found (very) few code snippets on the Web about DBF files...a class 
on PHP classes and a couple of other brief mentions elsewhere.

I have a question:  I was given a DBF file that I don't know the 
structure of.  Is there any way to read the column names and find out 
what they are, or do I need to have someone send me a description of 
the table structure before I can work with their file?

I assumed I could just read the structure, and then print the column 
names out or smething, but I can't seem to find any examples of that.

-- 
Marc Antony Vose
http://www.suzerain.com/

Imagination is more important than knowledge.
-- Albert Einstein

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




[PHP-DB] a where clause question

2002-10-06 Thread Alex Shi

Hi,

I need a where clause in following situation:

Say I want to query two tables: A and B. In table A there is field Afn,
while in table B there ere 3 fields: Bfn1, Bfn2 and Bfn3. I want to
compose a query, in which the where clause can do this: 

if A.Afn=1, then check Bfn1, 
if A.Afn=2, then check Bfn2,
if A.Afn=3, then check Bfn3.

So how I compose a where clause to do this? Thanks in advance!

Alex Shi



-- 
---
TrafficBuilder Network: 
http://www.bestadv.net/index.cfm?ref=7029


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




[PHP-DB] Pedigree question

2002-10-06 Thread Russell Griechen

I need to develop a tree-like pedigree of animals up to 5 generations.
I know there are other attributes to the animal; but do I need anyother
tables...assuming that I can develop all the code to generate these
ancestors.
I have developed a CSS positioning code that will place these results in a
neat 5 generation tree.
Is there any other alternatives?

Animal
  ID
  Name

Foal
  ID
  SireID
  DamID

Russell Griechen
htttp://sportsmenafield.com
Russell Griechen


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




Re: [PHP-DB] Pedigree question

2002-10-06 Thread Mihail Bota

Yes, there are. There is a pretty good php code, called HTML Tree which
can make trees, dynamically.

Regarding the coding itself...you can have a simple table that records who
is ancestor of who. This is a solution. Another one, which is not so neat
is to create a table with 5 columns...one per generation.
Does this make sense?

Mihai
On Sun, 6 Oct 2002, Russell Griechen wrote:

 I need to develop a tree-like pedigree of animals up to 5 generations.
 I know there are other attributes to the animal; but do I need anyother
 tables...assuming that I can develop all the code to generate these
 ancestors.
 I have developed a CSS positioning code that will place these results in a
 neat 5 generation tree.
 Is there any other alternatives?

 Animal
   ID
   Name

 Foal
   ID
   SireID
   DamID

 Russell Griechen
 htttp://sportsmenafield.com
 Russell Griechen


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




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




Re: [PHP-DB] Pedigree question

2002-10-06 Thread Matt Neimeyer


I need to develop a tree-like pedigree of animals up to 5 generations.
I know there are other attributes to the animal; but do I need anyother
tables...assuming that I can develop all the code to generate these
ancestors.

Animal
   ID
   Name

Foal
   ID
   SireID
   DamID

Would it be any more difficult to make a self-referential table? Like So? 
If the information is unknown then the fields are blank otherwise the 
SireID and DamID point back to the ID of another record in the same table.

 Animal
   ID
   Name
   SireID
   DamID

I'm in the conceptual stage of a similar project for humans and this is the 
approach I'm leaning towards. I'm planning on using something like this...

 Person
ID
Name
MotherID
FatherID
SpouseID

The reason I chose this is that even though a lot of the Mother, Father and 
Spouse fields might be blank wasted space I figured I'd be doing joins on 
the two tables (three in my case with the additional one for spouse) so 
often I'd be saving data storage space at the expense of data processing 
power creating the joins on the fly every time I needed them.

Just a thought...

Matt

P.S. If anyone sees any evil inherent in my design I'd love to know...


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




Re: [PHP-DB] Pedigree question

2002-10-06 Thread Russell Griechen


Mihail Bota [EMAIL PROTECTED]wrote:


 Yes, there are. There is a pretty good php code, called HTML Tree which
 can make trees, dynamically.

I did a search in the Php Manual...but did not understand what I was looking
at.
http://www.php.net/manual/sv/printwn/ref.domxml.php
I will look closer...Is this the link you were referring to.

 Regarding the coding itself...you can have a simple table that records who
 is ancestor of who. This is a solution. Another one, which is not so neat
 is to create a table with 5 columns...one per generation.
 Does this make sense?

I must only enter an animal once ...and I want to have users update the
database...sort of a DMOZ directory...with an editor/moderator approach for
the different breeds/animals.
I would like to have someone comment on whether the 2 tables mentioned would
suffice and what functions...or code would be better to apply.
Michael Koifler  sp?  in a book is purported to have a solution for
heirarchical display...but I am over budget now on this project so if any
one has seen this book and could help I would appreciate the code...until I
can afford the book.
see the tables in the original post below.

Russell Griechen
htttp://sportsmenafield.com

 On Sun, 6 Oct 2002, Russell Griechen wrote:

  I need to develop a tree-like pedigree of animals up to 5 generations.
  I know there are other attributes to the animal; but do I need anyother
  tables...assuming that I can develop all the code to generate these
  ancestors.
  I have developed a CSS positioning code that will place these results in
a
  neat 5 generation tree.
  Is there any other alternatives?
 
  Animal
ID
Name
 
  Foal
ID
SireID
DamID



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




Re: [PHP-DB] Pedigree question

2002-10-06 Thread Russell Griechen

Thank you for your response.
see comments below...

- Original Message -
From: Matt Neimeyer [EMAIL PROTECTED]
 I need to develop a tree-like pedigree of animals up to 5 generations.
 I know there are other attributes to the animal; but do I need anyother
 tables...assuming that I can develop all the code to generate these
 ancestors.

 Animal
ID
Name
 
 Foal
ID
SireID
DamID

 Would it be any more difficult to make a self-referential table? Like So?
 If the information is unknown then the fields are blank otherwise the
 SireID and DamID point back to the ID of another record in the same table.

  Animal
ID
Name
SireID
DamID

 I'm in the conceptual stage of a similar project for humans and this is
the
 approach I'm leaning towards. I'm planning on using something like this...

  Person
 ID
 Name
 MotherID
 FatherID
 SpouseID

 The reason I chose this is that even though a lot of the Mother, Father
and
 Spouse fields might be blank wasted space I figured I'd be doing joins
on
 the two tables (three in my case with the additional one for spouse) so
 often I'd be saving data storage space at the expense of data processing
 power creating the joins on the fly every time I needed them.

 Just a thought...

 Matt

 P.S. If anyone sees any evil inherent in my design I'd love to know...

This is an interesting idea,
The spouse category interests me...Somehow I need to add a Litter enrollment
table which would document the various litters...sires and dams and the
whelping date.
Lets compare progress...huh?

Russell Griechen
htttp://sportsmenafield.com



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




Re: [PHP-DB] Pedigree question

2002-10-06 Thread John Coder

On Sun, 2002-10-06 at 21:21, Russell Griechen wrote:

 I would like to have someone comment on whether the 2 tables mentioned would
 suffice and what functions...or code would be better to apply.
 Michael Koifler  sp?  in a book is purported to have a solution for
 heirarchical display...but I am over budget now on this project so if any
 one has seen this book and could help I would appreciate the code...until I
 can afford the book.
 see the tables in the original post below.
the book is MySQL by Koffler and I think you can download most of his
code at his site which is www.Koffler.cc I beleive.

John Coder



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




Re: [PHP-DB] Pedigree question

2002-10-06 Thread Mihail Bota

No, that is not the link. I am using this code:
http://pear.php.net/package-info.php?pacid=77

There are many tree codes out there. Just try to use one.

On Sun, 6 Oct 2002, Russell Griechen wrote:


 Mihail Bota [EMAIL PROTECTED]wrote:


  Yes, there are. There is a pretty good php code, called HTML Tree which
  can make trees, dynamically.

 I did a search in the Php Manual...but did not understand what I was looking
 at.
 http://www.php.net/manual/sv/printwn/ref.domxml.php
 I will look closer...Is this the link you were referring to.

  Regarding the coding itself...you can have a simple table that records who
  is ancestor of who. This is a solution. Another one, which is not so neat
  is to create a table with 5 columns...one per generation.
  Does this make sense?

 I must only enter an animal once ...and I want to have users update the
 database...sort of a DMOZ directory...with an editor/moderator approach for
 the different breeds/animals.
 I would like to have someone comment on whether the 2 tables mentioned would
 suffice and what functions...or code would be better to apply.
 Michael Koifler  sp?  in a book is purported to have a solution for
 heirarchical display...but I am over budget now on this project so if any
 one has seen this book and could help I would appreciate the code...until I
 can afford the book.
 see the tables in the original post below.

 Russell Griechen
 htttp://sportsmenafield.com

  On Sun, 6 Oct 2002, Russell Griechen wrote:
 
   I need to develop a tree-like pedigree of animals up to 5 generations.
   I know there are other attributes to the animal; but do I need anyother
   tables...assuming that I can develop all the code to generate these
   ancestors.
   I have developed a CSS positioning code that will place these results in
 a
   neat 5 generation tree.
   Is there any other alternatives?
  
   Animal
 ID
 Name
  
   Foal
 ID
 SireID
 DamID






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