Re: [PHP-DB] several pointers to records in one field

2003-03-17 Thread CPT John W. Holmes
> Here's one explanation... search for others:
> http://threebit.net/tutorials/nestedset/tutorial1.html#t

Here's the example I was looking for... it took me a while to find it:

http://searchdatabase.techtarget.com/tip/1,289483,sid13_gci537290,00.html

It's good reading for anyone working with databases to give you a look at
alternate methods of designing your tables...

---John Holmes...


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



Re: [PHP-DB] several pointers to records in one field

2003-03-17 Thread CPT John W. Holmes
> Thank You. Tell me if I misunderstood or if I did not express me
> clearly.

Sounds like you got it! :)

You may also want to read up on nested sets for your database structure.
They work the parent_id and child_id differently and it may make queries
easier for your situation. For instance, with nested sets, you can easily
find out everyone that decended from a single person with one query. Doing
that with the parent_child solution can take many queries. However,
inserting is more demanding with nested sets, but if you're not going to do
a whole lot of inserting after the database is populated, then it may be for
you.

Here's one explanation... search for others:
http://threebit.net/tutorials/nestedset/tutorial1.html#t

---John Holmes...


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



Re: [PHP-DB] several pointers to records in one field

2003-03-17 Thread Alain Barthélemy
Le lundi 17 mars 2003, 15:19:07 ou environ May, Patrick <[EMAIL PROTECTED]> a écrit:

>The table structure I can imagine:
> 
>person
>
>personId
>name
>etc
> 
>relationship
>
>relationshipId
>description
> 
>personToPersonRelationship
>--
>fromPersonId
>toPersonId
>relationshipId
> 
>The flexibility in here is to let you model pretty much any
>relationship between two people.  I don't know your data, but this may
>be helpful (To be able to express step mothers, step fathers, nannies,
>etc)
> 
>~ Patrick

Thank you Patrick. I keep the proposition but I'll try the proposition
of Johh Holmes.

-- 
Alain Barthélemy
[EMAIL PROTECTED]
http://bartydeux.be

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



Re: [PHP-DB] several pointers to records in one field

2003-03-17 Thread Alain Barthélemy
Le lundi 17 mars 2003, 22:04:08 ou environ Ignatius Reilly <[EMAIL PROTECTED]> a écrit:
> The standard relational way is a relationship table:
> 
> children
> -
> FK_parentID (parent)
> FK_childrenID (child)
> PRIMARY KEY ( FK_parentID, FK_childrenID )
> 
> HTH
> >

> > I started to use PHP with MySQL last december.
> > Personal use: list of inhabitants of a town in the 15th century
> >
> > Problem is the following: one person has an arbitrary number of children.
> > It is heavy to have fields child1,child2,child3,...,childn containing the
> row
> > number of each child especially if the number of children is variable.
> >
> > When I played with Commodore VIC20 I used to put pointers to records in a
> > string in the form pointer1,pointer2,...,pointern in a string.
> >
> > I think of using explode and implode to put all the record numbers of the
> > children in one varchar field.
> >
> > If someone have a better idea?

Thank you. I thought of a relational database of course with what I
already worked a few years ago with Perl-TK/MySQL. I may have badly
understood but I'll still need a field per child to point toward the
record in the children table and the parent is a child too.

-- 
Alain Barthélemy
[EMAIL PROTECTED]
http://bartydeux.be

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



Re: [PHP-DB] several pointers to records in one field

2003-03-17 Thread Alain Barthélemy
Le lundi 17 mars 2003, 16:12:32 ou environ CPT John W. Holmes <[EMAIL PROTECTED]> a 
écrit:
> > I started to use PHP with MySQL last december.
> > Personal use: list of inhabitants of a town in the 15th century
> >
> > Problem is the following: one person has an arbitrary number of children.
> > It is heavy to have fields child1,child2,child3,...,childn containing the
> row
> > number of each child especially if the number of children is variable.
> >
> > When I played with Commodore VIC20 I used to put pointers to records in a
> > string in the form pointer1,pointer2,...,pointern in a string.
> >
> > I think of using explode and implode to put all the record numbers of the
> > children in one varchar field.
> >
> > If someone have a better idea?
> 
> NO!!! Don't do that... that's horrible database design. :)

I agree and that's why I sent this e-mail.

> 
> You should/could have a separate table for children. It'll have 3 fields
> 
> 1: Unique ID for each child
> 2: ID of parent
> 3: Name of child
> 

Problem is that the child may be a parent too thus he should be at the
same time in the parent's table.

> plus whatever other information you decide to keep on children.
> 
> Notice how extensible this is. You can have an unlimited number of children
> for each parent.
> 
> You could treat this like a forum, too, and use a single table.
> 
> 1. Unique id for each person
> 2. ID of parent
> 3. Name
> etc...
> 
> Where, column 2 would be NULL (or empty) if the person is at the "top" of
> your chain (i.e. their parents aren't in the database). Everyone under them
> (their children, grandchildren, etc) would be in the same table and have
> column 2 as the ID of their parent (coming from the same table).
> 
> Confusing? I hope not, but ask away if it is... :)

I like this solution. It means, when I query the record of an individual
that I have to look at all the records of the table to see who has the
individual as parent to be able to reconstruct the family.
In fact I made a table with parent_ID and ten fields for children_ID
(bad solution I know). The parent_ID field (in fact mother_ID and
father_ID) already exists and I just have to retype my scripts to
reconstitute the family of a particular individual with backward looking
at him from individuals who have him as parent. 

Thank You. Tell me if I misunderstood or if I did not express me
clearly.

> 
> ---John Holmes...

-- 
Alain Barthélemy
[EMAIL PROTECTED]
http://bartydeux.be

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



RE: [PHP-DB] Server Error

2003-03-17 Thread Luke Woollard
This should read 'Your MySQL Database SERVER is down'

Thanks,

LW



-Original Message-
From: Luke Woollard [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 18 March 2003 8:48 AM
To: Marie Osypian; php-db
Subject: RE: [PHP-DB] Server Error


Your MySQL Database is down.

'cd' to your mysql directory (probably /usr/local/mysql ) and type
./bin/safe_mysqld --user=mysql &





-Original Message-
From: Marie Osypian [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 18 March 2003 8:42 AM
To: php-db
Subject: [PHP-DB] Server Error


I was able to access my database for weeks and now I am getting this error.
Can anyone help?


Warning: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Thanks,

Marie


--
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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Server Error

2003-03-17 Thread Peter Beckman
Does /var/lib/mysql/mysql.sock exist?  Is it world unwritable?  Is it
writable by whatever user starts mysql?  Does it exist (did it get
deleted)?  Are you sure you want to use configi.inc.php and not
config.inc.php?

That's all I can think of.


On Mon, 17 Mar 2003, Marie Osypian wrote:

> I was able to access my database for weeks and now I am getting this error.
> Can anyone help?
>
>
> Warning: Can't connect to local MySQL server through socket
> '/var/lib/mysql/mysql.sock' (2) in
> /home/blah/public_html/includes/configi.inc.php on line 3
>
> Warning: MySQL Connection Failed: Can't connect to local MySQL server
> through socket '/var/lib/mysql/mysql.sock' (2) in
> /home/blah/public_html/includes/configi.inc.php on line 3
>
> Thanks,
>
> Marie
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



RE: [PHP-DB] Server Error

2003-03-17 Thread Luke Woollard
Your MySQL Database is down.

'cd' to your mysql directory (probably /usr/local/mysql ) and type
./bin/safe_mysqld --user=mysql &





-Original Message-
From: Marie Osypian [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 18 March 2003 8:42 AM
To: php-db
Subject: [PHP-DB] Server Error


I was able to access my database for weeks and now I am getting this error.
Can anyone help?


Warning: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Thanks,

Marie


--
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] Server Error

2003-03-17 Thread Marie Osypian
I was able to access my database for weeks and now I am getting this error.
Can anyone help?


Warning: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Thanks,

Marie 


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



Re: [PHP-DB] several pointers to records in one field

2003-03-17 Thread CPT John W. Holmes
> I started to use PHP with MySQL last december.
> Personal use: list of inhabitants of a town in the 15th century
>
> Problem is the following: one person has an arbitrary number of children.
> It is heavy to have fields child1,child2,child3,...,childn containing the
row
> number of each child especially if the number of children is variable.
>
> When I played with Commodore VIC20 I used to put pointers to records in a
> string in the form pointer1,pointer2,...,pointern in a string.
>
> I think of using explode and implode to put all the record numbers of the
> children in one varchar field.
>
> If someone have a better idea?

NO!!! Don't do that... that's horrible database design. :)

You should/could have a separate table for children. It'll have 3 fields

1: Unique ID for each child
2: ID of parent
3: Name of child

plus whatever other information you decide to keep on children.

Notice how extensible this is. You can have an unlimited number of children
for each parent.

You could treat this like a forum, too, and use a single table.

1. Unique id for each person
2. ID of parent
3. Name
etc...

Where, column 2 would be NULL (or empty) if the person is at the "top" of
your chain (i.e. their parents aren't in the database). Everyone under them
(their children, grandchildren, etc) would be in the same table and have
column 2 as the ID of their parent (coming from the same table).

Confusing? I hope not, but ask away if it is... :)

---John Holmes...


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



[PHP-DB] User Defined Function Problem

2003-03-17 Thread The Cossins Fam
Does anyone see anything I might be missing as to why this won't work?

From the file calling the function:


$round = "Round 1";
$region = "East";
include "check.php";
isAuthorized($_COOKIE['username'], $_COOKIE['password']);
include "checkEntry.php";
check4Entry($username, $round, $region);
...

From checkEntry.php:


function check4Entry($name, $reg, $rnd) {

   $connection = mysql_connect("localhost", "root") or 
die(mysql_error());

   $db = mysql_select_db("marchmadness", $connection) or 
die(mysql_error())
;

   $checking = "SELECT * FROM pick WHERE userID = \"$uname\" AND  round 
= \"$rnd\" AND region = \"$reg\"";

   $result = mysql_query($checking, $connection) or die(mysql_error());

   $numRows = mysql_num_rows($result) or die(mysql_error());

   if ($numRows > 0) {
   print(" Oops! There are 
already selections made for $uname in $reg - $rnd.  
$uname, if you'd like to modify your selections, please click here.");

   exit;

   }

}

?>

==

When I submit the form, I get a blank screen as a result.  There aren't any 
errors ouput to the screen.  I've compared this with another function I've 
created, and there doesn't appear to be anything different.  The latter 
works.

BTW, I bet you'll never guess what this is for...;-)

Thanks for your help!

--Joel

_
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.  
http://join.msn.com/?page=features/virus

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


[PHP-DB] several pointers to records in one field

2003-03-17 Thread Alain Barthélemy
Hello,

I started to use PHP with MySQL last december.
Personal use: list of inhabitants of a town in the 15th century

Problem is the following: one person has an arbitrary number of children.
It is heavy to have fields child1,child2,child3,...,childn containing the row
number of each child especially if the number of children is variable.

When I played with Commodore VIC20 I used to put pointers to records in a
string in the form pointer1,pointer2,...,pointern in a string.

I think of using explode and implode to put all the record numbers of the
children in one varchar field.

If someone have a better idea?

-- 
Alain Barthélemy
[EMAIL PROTECTED]
http://bartydeux.be

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



[PHP-DB] php_gd.dll

2003-03-17 Thread Natividad Castro
Hi to all,
I posted this question before, but I don't know if guys got it. If you did,
I'm sorry.

I just installed PHP 4.3.1 on a windows 2000 machine. Everything works fine
except for graphics. I can't generate graphics. I copy the php.ini to
C:\WINNT\system and uncommented the line for php_gd.dll library, but still I
can't make to work.
I keep getting the following error:
Call to undefined function: imagecreate() in
c:\inetpub\wwwroot\php\lines.php on line 22

below is the code that I'm working with

$height = 200;
$width = 200;
$im = ImageCreate($height, $width);

$white = ImageColorAllocate ($im, 255, 255, 255);
$black = ImageColorAllocate ($im, 0, 0, 0);

// draw on image
ImageFill($im, 0, 0, $black);
ImageLine($im, 0, 0, $width, $height, $white);
ImageString($im, 4, 50, 150, "Sales", $white);

// output image
Header ("Content-type: image/png");
ImagePng ($im);

// clean up
ImageDestroy($im);


Any help is greatly appreciate
Thanks
Nato
~~~
Nato Castro
Web Development
COmputing TechnologieS, Inc. (CoTs)
3028 Javier Road, Suite 400
Fairfax, VA 22031
Tel: 703.280.8800 ext.1205
~~~


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



Re: [PHP-DB] mysql_connect() problem

2003-03-17 Thread David Smith
You need to install the php-mysql rpm. You can get this on your RedHat CD,
or through apt-get:

apt-get install php-mysql

Get apt here: http://apt.freshrpms.net/

Does the PHP project ever plan to do something as impressive as CPAN so
users won't have to reinstall or recompile just to extend its
functionality?

--Dave


>
> Hi,
>
>   I am using Apache 2 in Linux 8 .Whenever in my php script I want to
> connect to mysql through mysql_connect() function a error occured.
>
> My script is like that
>   $linlid=mysql_connect("localhost","user1","user1")or
> die("Connections
> failed");
> print "Connected successfully";
>
> The script writes this.
> %
> Fatal error: Call to undefined function: mysql_connect()
>
> Please help me.I have installed Apache and php through RPM.
> Anybody can help me.
>
> Indrajit
>
>
>
>
>
> _
> Get more buddies in your list. Win prizes
> http://messenger.msn.co.in/promo
>
>
> --
> 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] Performance in MySQL Result Question

2003-03-17 Thread Brent Baisley
I know what you are trying to get at. A full select and a select with 
limit have the same query speed, but the full select has to transfer all 
of the selected data, where as a limit only transfers the number of 
records specified. The more records that match a search, the faster your 
limit select will be in relation to a full select.

As for improving performance, you would like to avoid re-executing a 
complex query just to get the next set of records. If you are using 
MySQL 4 with query caching enabled you don't have to worry. MySQL will 
be smart enough to cache the query result and won't rerun the exact same 
query on the database if no data has changed.

On Saturday, March 15, 2003, at 03:57 AM, Jan Bro wrote:

Now comes my question, what is better speaking of performance:
When users go on to the next page, is it better to
provide the select statement again with a different integer for
the limit?
Or is better to do a full select without a limitation on first page.
But than I don't know how to provide the result set for the
next, next, ... page?
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] mysql_connect() problem

2003-03-17 Thread Indrajit Paul
Hi,

 I am using Apache 2 in Linux 8 .Whenever in my php script I want to 
connect to mysql through mysql_connect() function a error occured.

My script is like that
 $linlid=mysql_connect("localhost","user1","user1")or die("Connections 
failed");
print "Connected successfully";

The script writes this.
%
Fatal error: Call to undefined function: mysql_connect()
Please help me.I have installed Apache and php through RPM.
Anybody can help me.
Indrajit





_
Get more buddies in your list. Win prizes http://messenger.msn.co.in/promo
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Apache, PHP+Informix on Windows NT 4.0 Server - memory allocation

2003-03-17 Thread Brzeziński Mariusz
Hello!

I run Apache in 1.3.22 version, PHP 4.3.1 with Informix module. 
I have it on two machines: 
a) Windows NT 4.0 Workstation + SP 6.0
b) Windows NT 4.0 Server + SP 6.0

The same PHP scripts on a) it works perfectly, but on b) when I try to
connect to Informix server (on Unix SCO) I got 

"Warning: ifx_connect(): E [SQLSTATE=IX 000 SQLCODE=-461] in c:\program
files\...\errors\choice.php on line 26"

Informix documentation describes "-461" error as 

"File open error. 

The database server could not open a file required to execute this
statement. Sometimes this is a general error, possibly referring to a
message file that the database server cannot find. At other times this error
occurs because the locator (blob) structure field loc_loctype was set to
LOCFNAME, but the database server could not open the file using the pathname
in loc_fname and the flags in loc_oflags. Any of the following conditions
can cause the database server to report this error:

*  An environment variable setting is missing.
*  Not enough disk space is available for opening the file.
*  A file permission problem exists.
*  The limit on the number of open files was reached.
*  The database server could not access a blob of type LOCFNAME.
*  The database server is on a different machine from the client.
*  The statement transfers a value between a file and a BYTE or TEXT
column.
*  The statement attempts to drop a database when a required file is not
available.

Make sure your environment variables and file permissions are set correctly.
For more information, check for any accompanying ISAM error code or
operating-system message."

I have enviroment variables and file permissions set on b) machine, have
enough of disk space.

What may be a reason?

Regards

Mariusz


Mariusz Brzeziński
IT Specialist
Business Development Department
e-mail [EMAIL PROTECTED]
tel. +48 61 856 53 57

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