Re: [PHP-DB] Question about databases and foreign keys

2008-09-15 Thread Philip Thompson

On Sep 15, 2008, at 10:03 AM, Jason Pruim wrote:


On Sep 15, 2008, at 10:59 AM, Micah Gersten wrote:


Use 2 tables.  You never know what the app might grow into and you
should do it right the first time.


That's what I was thinking too... Just wanted to hear it from  
someone else... NOW I get to learn about foreign keys and how to  
update things with them!


So if anyone knows of a good resource I'd appreciate it... Until  
then, I'm off to search the web and figure this stuff out!


I'm sure Google will probably be your best resource for what you need  
to find out. ;)


I'll throw this out there though. When dealing with foreign keys and  
multiple tables, remember to index appropriately. For example:


Table `users`:
user_id int(10) primary key
-- other fields here --
clock_id int(10)

Table `clocking`:
clock_id int(10) primary key
clock_in int(10)
clock_out int(10)

In table `clocking`, clock_id is already indexed because it's primary.  
Be sure to index clock_id in `users` so that when you join on the two,  
you'll have optimal speed!


ALTER TABLE `users` ADD INDEX (`clock_id`);

And an example query...

SELECT `u`.`user_id`, `c`.`clock_in`, `c`.`clock_out` FROM `users` `u`  
INNER JOIN `clocking` `c` ON `u`.`clock_id` = `c`.`clock_id` WHERE  
(`u`.`user_id` = '$user_id' AND `c`.`clock_in`  'sometime' AND  
`c`.`clock_out`  'someothertime');


Something along those lines. I always find it useful to have unique  
names throughout the database, so if you reference a name, you know  
where it originated. Because of this, I can just look at `users` and  
determine that `clock_id` is a foreign key.


Hope that helps a little!

~Philip

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



Re: [PHP-DB] Question about databases and foreign keys

2008-09-15 Thread Thodoris




On Sep 15, 2008, at 10:59 AM, Micah Gersten wrote:


Use 2 tables.  You never know what the app might grow into and you
should do it right the first time.


That's what I was thinking too... Just wanted to hear it from someone 
else... NOW I get to learn about foreign keys and how to update things 
with them!


So if anyone knows of a good resource I'd appreciate it... Until then, 
I'm off to search the web and figure this stuff out!



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]






This for mysql only but it can give some info you may find useful.

This is a very enlightening article for starters in order to see the sql 
part.


http://articles.techrepublic.com.com/5100-10878_11-6035435.html

The mysql manual could also give you an idea on that.

http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html

--
Thodoris


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



Re: [PHP-DB] Question about databases and foreign keys

2008-09-15 Thread Micah Gersten
You'll actually want to have the User Id in the clocking table, not the
other way around.  User Id is the foreign key because it has a many to
one relationship with the time logging.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Philip Thompson wrote:


 I'll throw this out there though. When dealing with foreign keys and
 multiple tables, remember to index appropriately. For example:

 Table `users`:
 user_id int(10) primary key
 -- other fields here --
 clock_id int(10)

 Table `clocking`:
 clock_id int(10) primary key
 clock_in int(10)
 clock_out int(10)

 In table `clocking`, clock_id is already indexed because it's primary.
 Be sure to index clock_id in `users` so that when you join on the two,
 you'll have optimal speed!

 ALTER TABLE `users` ADD INDEX (`clock_id`);

 And an example query...

 SELECT `u`.`user_id`, `c`.`clock_in`, `c`.`clock_out` FROM `users` `u`
 INNER JOIN `clocking` `c` ON `u`.`clock_id` = `c`.`clock_id` WHERE
 (`u`.`user_id` = '$user_id' AND `c`.`clock_in`  'sometime' AND
 `c`.`clock_out`  'someothertime');

 Something along those lines. I always find it useful to have unique
 names throughout the database, so if you reference a name, you know
 where it originated. Because of this, I can just look at `users` and
 determine that `clock_id` is a foreign key.

 Hope that helps a little!

 ~Philip


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



Re: [PHP-DB] Question about databases and foreign keys

2008-09-15 Thread Philip Thompson

On Sep 15, 2008, at 2:12 PM, Micah Gersten wrote:

You'll actually want to have the User Id in the clocking table, not  
the

other way around.  User Id is the foreign key because it has a many to
one relationship with the time logging.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


Yes, I agree with that. That was just a quick example that I whipped  
up (and obviously didn't think enough about). ;) So, follow Micah's  
advice, people. =D


~Philip



Philip Thompson wrote:



I'll throw this out there though. When dealing with foreign keys and
multiple tables, remember to index appropriately. For example:

Table `users`:
user_id int(10) primary key
-- other fields here --
clock_id int(10)

Table `clocking`:
clock_id int(10) primary key
clock_in int(10)
clock_out int(10)

In table `clocking`, clock_id is already indexed because it's  
primary.
Be sure to index clock_id in `users` so that when you join on the  
two,

you'll have optimal speed!

ALTER TABLE `users` ADD INDEX (`clock_id`);

And an example query...

SELECT `u`.`user_id`, `c`.`clock_in`, `c`.`clock_out` FROM `users`  
`u`

INNER JOIN `clocking` `c` ON `u`.`clock_id` = `c`.`clock_id` WHERE
(`u`.`user_id` = '$user_id' AND `c`.`clock_in`  'sometime' AND
`c`.`clock_out`  'someothertime');

Something along those lines. I always find it useful to have unique
names throughout the database, so if you reference a name, you know
where it originated. Because of this, I can just look at `users` and
determine that `clock_id` is a foreign key.

Hope that helps a little!

~Philip



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



innerHTML is a string. The DOM is not a string, it's a hierarchal  
object structure. Shoving a string into an object is impure and  
similar to wrapping a spaghetti noodle around an orange and calling it  
lunch.



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



Re: [PHP-DB] Question about access rights in php/mysql

2008-08-26 Thread Dan Shirah

 Hi Everyone,

 I am attempting to wrap my head around an issue and wanted to see if I was
 thinking right.

 I am attempting to setup a pURL site, one where they go to something like:
 example.com/purl.php?purl=jason1234 and the site says Welcome Jason. I
 have that part of it working, and it's pulling the info from the database
 just fine, what I'm wondering about is locking it down a little bit more so
 that they can't just edit the info in the main page, but they have to
 specifically hit a button to edit the info.

 Is it better to have 2 connections to the database with 2 separate logins?
 One for the initial load which just has select privileges and a second for
 when they hit edit which then gives them update privileges?

 Or, should i just do 1 login with select, and update privileges?

 Any ideas or suggestions?

 Thanks!



Jason,

I would assume you have some kind of login page, correct? Or can anyone type
in the direct URL and access someone else's page?

If they have already logged in, I would use some simple javascript to
enable/disable the editing of form objects. By setting all of the form
objects to disabled they will appear grayed out but the text is still
legible.  Then when they click on your Edit button just have a Javascript
function set them all to enabled. You could do something similar to
show/hide div's.

Or, you could bypass all the javascript and just add an edit flag to your
page? So once they click on the Edit button/link it would update a variable
and you could do something like:

if ($edit ==Y) {
  type=Submit name=save value=Save
}

Add in the option to save only if Edit has been selected?

As for your database logins, I don't see a problem with doing it either way.
I personally prefer to use a single login, but doing a include() for a
second login is no big deal either.


Re: [PHP-DB] Question about access rights in php/mysql

2008-08-26 Thread Jason Pruim


On Aug 26, 2008, at 8:32 AM, Dan Shirah wrote:


Hi Everyone,

I am attempting to wrap my head around an issue and wanted to see if  
I was thinking right.


I am attempting to setup a pURL site, one where they go to something  
like: example.com/purl.php?purl=jason1234 and the site says Welcome  
Jason. I have that part of it working, and it's pulling the info  
from the database just fine, what I'm wondering about is locking it  
down a little bit more so that they can't just edit the info in the  
main page, but they have to specifically hit a button to edit the  
info.


Is it better to have 2 connections to the database with 2 separate  
logins? One for the initial load which just has select privileges  
and a second for when they hit edit which then gives them update  
privileges?


Or, should i just do 1 login with select, and update privileges?

Any ideas or suggestions?

Thanks!


Jason,

I would assume you have some kind of login page, correct? Or can  
anyone type in the direct URL and access someone else's page?


If they have already logged in, I would use some simple javascript  
to enable/disable the editing of form objects. By setting all of the  
form objects to disabled they will appear grayed out but the text  
is still legible.  Then when they click on your Edit button just  
have a Javascript function set them all to enabled. You could do  
something similar to show/hide div's.


Or, you could bypass all the javascript and just add an edit flag  
to your page? So once they click on the Edit button/link it would  
update a variable and you could do something like:


if ($edit ==Y) {
  type=Submit name=save value=Save
}

Add in the option to save only if Edit has been selected?

As for your database logins, I don't see a problem with doing it  
either way. I personally prefer to use a single login, but doing a  
include() for a second login is no big deal either.


Hi Dan,

Thanks for the info! the page will not actually require a login, it is  
a new direct mail technique where they get a piece of mail with the  
pURL on it, and then go there to follow up on the web.


I think though that I will go with the 1 login, with a simple variable  
like to described.


Thanks Dan!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]






Re: [PHP-DB] Question on PHP connect MS SQL 2005

2008-06-11 Thread Dan Shirah
Alice,

In regards to:

Call to undefined function mssql_connect() in
/home/TDC/Desktop/create_new_entry_master.php on line 20

Do you have the MSSQL extension uncommented in your PHP.ini?

Dan


RE: [PHP-DB] Question on PHP connect MS SQL 2005

2008-06-11 Thread Wei, Alice J.
Hi,

  This may sound really stupid, but I installed Fedora and checked on the box 
for web development to allow PHP and other web scripts on the platform. 
Therefore, I could run PHP scripts fine, and the mentioning of this file, would 
you be able to offer me suggestions on where it might be?

Thanks for your help.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

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



RE: [PHP-DB] Question on PHP connect MS SQL 2005

2008-06-11 Thread Wei, Alice J.
Hi, Dan:

 Thanks for the information, and my PHP has been installed, and  I have 
commented out everything from the PHP ini regarding to MS SQL connections.
 However, I am still having issues with seeing the same error as I have in the 
previous email.

Are there other things I have to try?
Thanks for your help.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

From: Dan Shirah [EMAIL PROTECTED]
Sent: Wednesday, June 11, 2008 9:43 AM
To: Wei, Alice J.
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Question on PHP connect MS SQL 2005

Alice,

In regards to:

Call to undefined function mssql_connect() in 
/home/TDC/Desktop/create_new_entry_master.php on line 20

Do you have the MSSQL extension uncommented in your PHP.ini?

Dan

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



Re: [PHP-DB] Question on PHP connect MS SQL 2005

2008-06-11 Thread Ken Keefe
I know the package you need is called php-sybase in ubuntu. It's
probably something similar in Fedora. Know that this package will only
let you do a subset of the mssql function calls. If you are just
connecting and doing a normal query, it will suffice. If you need to
do prepared statements for stored procedures, you will likely have to
compile a php-mssql package manually. I just did this last night on my
ubuntu server to get some stored procedures working. Hope that helps.

Ken

On Wed, Jun 11, 2008 at 8:52 AM, Wei, Alice J. [EMAIL PROTECTED] wrote:
 Hi,

  This may sound really stupid, but I installed Fedora and checked on the box 
 for web development to allow PHP and other web scripts on the platform. 
 Therefore, I could run PHP scripts fine, and the mentioning of this file, 
 would you be able to offer me suggestions on where it might be?

 Thanks for your help.

 Alice
 ==
 Alice Wei
 MIS 2009
 School of Library and Information Science
 Indiana University Bloomington
 [EMAIL PROTECTED]

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





-- 

Naturally, the common people don't want war, but they can always be
brought to the bidding of the leaders. Tell them they are being
attacked, and denounce the pacifists for lack of patriotism and
endangering the country. It works the same in every country.

--- Herman Goering, Hitler's Reichsmarschall, At the Nuremberg Trials

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



Re: [PHP-DB] Question about database design

2007-10-24 Thread Tim McGeary

Hi Jason,

There are a couple ways you could do this.  Yes, this would make it a 
relational database.


If you go with a second table, you'll want to be sure to include the UID 
from the main address table in the SnowBirds table so that they are 
linked.  The UID in the second table would actually be a foreign key 
that links it to the main address table.  It could also act as the 
primary key of the SnowBirds table since it will be unique.  The other 
importance for this relationship of the UID is that if you delete a 
person and their address from the main table, you'll probably want to 
delete their seasonal address, too.


You may also want to have a binary column in your main address table to 
indicate to your PHP script whether or not to look for another address 
in the SnowBirds tables.  I would do this so that you aren't wasting an 
SQL query if it isn't needed.  May not be a big deal if you have limited 
tables, but as list of queries increase, there is no need for extra queries.


You could add a start date and end date column the SnowBirds database. 
 Sounds like for your purposes that is a good idea.


If you I missed anything or you have more specific questions, feel free 
to email me on or off list.


Cheers,
Tim

Tim McGeary '99, '06G
Senior Systems Specialist
Lehigh University
610-758-4998
[EMAIL PROTECTED]


Jason Pruim wrote:
I sent this to the MySQL list but didn't receive any response, 
My apologies if you have already received this.



Hi Everyone,

So having learned my lesson with the last application, I am trying to
plan out the addition of a feature to my database application.
Basically, some of my customers go south for the winter (Snow
Birds) what I would like to do is have away of storing both their
addresses in the database, and have it so that the people
administering the list can choose between wether they are up north or
down south without having to erase the old address.

For that I was thinking creating a second table SnowBirds and list
their southern addresses in there and then when the list admin clicks
on the edit button for their name, it would also be able to pull up a
list of the the addresses stored and associated with that person.

I'm also considering adding a date range for the addresses so that if
they know they'll be south from November to March it will check the
date and switch between the record accordingly BEFORE exporting to
excel.

Now... I haven't really asked a question yet but gave some background
into what I want to do. So... Here's the question, does anyone
have any advice on the best way to do it? Am I right in thinking that
a second table is required? Would it be called a Relational database?
Or have I missed the terminology?

Any help would be greatly appreciated!

Thanks for looking!

ohhh... and in case it makes a difference it's MySQL 5.* and I'll be
writing the stuff to access that database with php 5.

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





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



RE: [PHP-DB] Question about database design

2007-10-24 Thread Bastien Koert

I would approach this by having a main people table (with a unique id of 
course) and then create a second addresses table which uses the people Id key 
as the foreign key to this table...then you can have multiple (more than two) 
addresses for those users, you could add a season in the addresses to be able 
to pull the correct one based on date
 
bastien To: php-db@lists.php.net From: [EMAIL PROTECTED] Date: Wed, 24 Oct 
2007 09:06:29 -0400 Subject: [PHP-DB] Question about database design  
I sent this to the MySQL list but didn't receive any  response, My 
apologies if you have already received this.   Hi Everyone,  So having 
learned my lesson with the last application, I am trying to plan out the 
addition of a feature to my database application. Basically, some of my 
customers go south for the winter (Snow Birds) what I would like to do is 
have away of storing both their addresses in the database, and have it so that 
the people administering the list can choose between wether they are up north 
or down south without having to erase the old address.  For that I was 
thinking creating a second table SnowBirds and list their southern addresses 
in there and then when the list admin clicks on the edit button for their 
name, it would also be able to pull up a list of the the addresses stored and 
associated with that person.  I'm also considering adding a date range for 
the addresses so that if they know they'll be south from November to March it 
will check the date and switch between the record accordingly BEFORE exporting 
to excel.  Now... I haven't really asked a question yet but gave some 
background into what I want to do. So... Here's the question, does anyone 
have any advice on the best way to do it? Am I right in thinking that a second 
table is required? Would it be called a Relational database? Or have I missed 
the terminology?  Any help would be greatly appreciated!  Thanks for 
looking!  ohhh... and in case it makes a difference it's MySQL 5.* and I'll 
be writing the stuff to access that database with php 5.  --  Jason Pruim 
Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 
49424 www.raoset.com [EMAIL PROTECTED]  
_
Express yourself with free Messenger emoticons. Get them today!
http://www.freemessengeremoticons.ca/?icid=EMENCA122

Re: [PHP-DB] Question about database design

2007-10-24 Thread Jason Pruim

Hi Tim,

Right now the customer I have has about 1,000 records which I know  
isn't alot for MySQL to handle, but if people like the application we  
could end up with 15 to 20 all having around 1,000 or more records  
which would add up more on the database. Although right now I plan to  
have a database per customer, easier to keep the info separate. I'm  
just beginning with MySQL and PHP (Although I know and understand PHP  
more then MySQL)


So just to double check I understand what you are saying, you would  
set up a database with 2 tables, on the first one would be something  
like name, address, city, state, zip, Primary Key. And then on the  
second table it would have Name, address, city, state, zip, foreign  
key?  and the foreign key someone links the 2 records?


Like I said, I'm still learning MySQL :) Know of any good articles  
that describe it for a beginner?



On Oct 24, 2007, at 9:28 AM, Tim McGeary wrote:


Hi Jason,

There are a couple ways you could do this.  Yes, this would make it  
a relational database.


If you go with a second table, you'll want to be sure to include  
the UID from the main address table in the SnowBirds table so  
that they are linked.  The UID in the second table would actually  
be a foreign key that links it to the main address table.  It could  
also act as the primary key of the SnowBirds table since it will  
be unique.  The other importance for this relationship of the UID  
is that if you delete a person and their address from the main  
table, you'll probably want to delete their seasonal address, too.


You may also want to have a binary column in your main address  
table to indicate to your PHP script whether or not to look for  
another address in the SnowBirds tables.  I would do this so that  
you aren't wasting an SQL query if it isn't needed.  May not be a  
big deal if you have limited tables, but as list of queries  
increase, there is no need for extra queries.


You could add a start date and end date column the SnowBirds  
database.  Sounds like for your purposes that is a good idea.


If you I missed anything or you have more specific questions, feel  
free to email me on or off list.


Cheers,
Tim

Tim McGeary '99, '06G
Senior Systems Specialist
Lehigh University
610-758-4998
[EMAIL PROTECTED]


Jason Pruim wrote:
I sent this to the MySQL list but didn't receive any  
response, My apologies if you have already received this.

Hi Everyone,
So having learned my lesson with the last application, I am trying to
plan out the addition of a feature to my database application.
Basically, some of my customers go south for the winter (Snow
Birds) what I would like to do is have away of storing both their
addresses in the database, and have it so that the people
administering the list can choose between wether they are up north or
down south without having to erase the old address.
For that I was thinking creating a second table SnowBirds and list
their southern addresses in there and then when the list admin clicks
on the edit button for their name, it would also be able to pull up a
list of the the addresses stored and associated with that person.
I'm also considering adding a date range for the addresses so that if
they know they'll be south from November to March it will check the
date and switch between the record accordingly BEFORE exporting to
excel.
Now... I haven't really asked a question yet but gave some background
into what I want to do. So... Here's the question, does anyone
have any advice on the best way to do it? Am I right in thinking that
a second table is required? Would it be called a Relational database?
Or have I missed the terminology?
Any help would be greatly appreciated!
Thanks for looking!
ohhh... and in case it makes a difference it's MySQL 5.* and I'll be
writing the stuff to access that database with php 5.
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]


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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP-DB] Question about database design

2007-10-24 Thread Jason Pruim
I think I understand what you are saying here... On the main table  
just list the persons name and then on a second table use a 1 to many  
relationship on a foreign key to link all the addresses into the  
name? Or did I miss the mark? :)



On Oct 24, 2007, at 9:30 AM, Bastien Koert wrote:

I would approach this by having a main people table (with a unique  
id of course) and then create a second addresses table which uses  
the people Id key as the foreign key to this table...then you can  
have multiple (more than two) addresses for those users, you could  
add a season in the addresses to be able to pull the correct one  
based on date


bastien

 To: php-db@lists.php.net
 From: [EMAIL PROTECTED]
 Date: Wed, 24 Oct 2007 09:06:29 -0400
 Subject: [PHP-DB] Question about database design

 I sent this to the MySQL list but didn't receive any
 response, My apologies if you have already received this.


 Hi Everyone,

 So having learned my lesson with the last application, I am  
trying to

 plan out the addition of a feature to my database application.
 Basically, some of my customers go south for the winter (Snow
 Birds) what I would like to do is have away of storing both their
 addresses in the database, and have it so that the people
 administering the list can choose between wether they are up  
north or

 down south without having to erase the old address.

 For that I was thinking creating a second table SnowBirds and list
 their southern addresses in there and then when the list admin  
clicks
 on the edit button for their name, it would also be able to pull  
up a

 list of the the addresses stored and associated with that person.

 I'm also considering adding a date range for the addresses so  
that if

 they know they'll be south from November to March it will check the
 date and switch between the record accordingly BEFORE exporting to
 excel.

 Now... I haven't really asked a question yet but gave some  
background

 into what I want to do. So... Here's the question, does anyone
 have any advice on the best way to do it? Am I right in thinking  
that
 a second table is required? Would it be called a Relational  
database?

 Or have I missed the terminology?

 Any help would be greatly appreciated!

 Thanks for looking!

 ohhh... and in case it makes a difference it's MySQL 5.* and I'll be
 writing the stuff to access that database with php 5.

 --

 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 3251 132nd ave
 Holland, MI, 49424
 www.raoset.com
 [EMAIL PROTECTED]




Express yourself with free Messenger emoticons. Get them today!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP-DB] Question about database design

2007-10-24 Thread Tony Grimes
A second address table is definitely the way to go (the '*' signifies the
primary key):

People Table

*user_id
first_name
last_name
etc

Address Table (compound primary key)
=
*user_id (fk to People Table)
*address_id
*obs_no (you can skip this if you don't want to keep an address history)
active_ind (is the row currently active or deleted?)
effective_date
expiry_date
address_line_1
address_line_2
city
etc

So say a user lives in the north from Mar to Sept and in the South from Oct
to Feb, your two rows would look like this:

Row 1
=
*john_doe (I prefer natural keys to surrogate)
*north
*1
Y
2007-03-01
2007-10-01
blah
blah

Row 2
=
*john_doe
*south
*1
Y
2007-10-01
2007-03-01
blah
blah

If you want to keep a history of past addresses, just add a new row with an
obs_no of 2 and set the active_ind to 'N' for the old row. All your queries
will have to contain a where clause (active_ind = 'Y') to keep the old rows
from showing up.

I hope this helps.

Tony


On 10/24/07 7:30 AM, Bastien Koert [EMAIL PROTECTED] wrote:

 
 I would approach this by having a main people table (with a unique id of
 course) and then create a second addresses table which uses the people Id key
 as the foreign key to this table...then you can have multiple (more than two)
 addresses for those users, you could add a season in the addresses to be able
 to pull the correct one based on date

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



RE: [PHP-DB] Question about database design

2007-10-24 Thread Bastien Koert

Nope, you got it


Bastien

 CC: php-db@lists.php.net From: [EMAIL 
PROTECTED] Subject: Re: [PHP-DB] Question about database design Date: Wed, 24 
Oct 2007 15:18:05 -0400 To: [EMAIL PROTECTED] I think I understand what you 
are saying here... On the main table just list the persons name and then on a 
second table use a 1 to many relationship on a foreign key to link all the 
addresses into the name? Or did I miss the mark? :) On Oct 24, 2007, at 9:30 
AM, Bastien Koert wrote: I would approach this by having a main people table 
(with a unique id of course) and then create a second addresses table which 
uses the people Id key as the foreign key to this table...then you can have 
multiple (more than two) addresses for those users, you could add a season in 
the addresses to be able to pull the correct one based on date bastien To: 
php-db@lists.php.net From: [EMAIL PROTECTED] Date: Wed, 24 Oct 2007 
09:06:29 -0400 Subject: [PHP-DB] Question about database design I 
sent this to the MySQL list but didn't receive any response, My apologies if 
you have already received this. Hi Everyone, So having learned my 
lesson with the last application, I am trying to plan out the addition of a 
feature to my database application. Basically, some of my customers go south 
for the winter (Snow Birds) what I would like to do is have away of storing 
both their addresses in the database, and have it so that the people 
administering the list can choose between wether they are up north or down 
south without having to erase the old address. For that I was thinking 
creating a second table SnowBirds and list their southern addresses in 
there and then when the list admin clicks on the edit button for their name, 
it would also be able to pull up a list of the the addresses stored and 
associated with that person. I'm also considering adding a date range for 
the addresses so that if they know they'll be south from November to March it 
will check the date and switch between the record accordingly BEFORE 
exporting to excel. Now... I haven't really asked a question yet but gave 
some background into what I want to do. So... Here's the question, does 
anyone have any advice on the best way to do it? Am I right in thinking 
that a second table is required? Would it be called a Relational database? 
Or have I missed the terminology? Any help would be greatly 
appreciated! Thanks for looking! ohhh... and in case it makes a 
difference it's MySQL 5.* and I'll be writing the stuff to access that 
database with php 5. -- Jason Pruim Raoset Inc. Technology 
Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 
www.raoset.com [EMAIL PROTECTED]  
Express yourself with free Messenger emoticons. Get them today! -- Jason 
Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave 
Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED]

_
R U Ready for Windows Live Messenger Beta 8.5? Try it today!
http://entertainment.sympatico.msn.ca/WindowsLiveMessenger
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Question in js about frameset rows

2006-06-22 Thread suad

Hi,

It's working
Thanks
Suad

Bastien Koert wrote:

I have fixed values that I adjust to, but you basically need to give 
the frame an ID and then use .rows and.columns to adjust the size


function shrink() {
   top.document.getElementById(TOP).rows = 65,*,0,46,0;
}

function expand() {

   top.document.getElementById(TOP).rows = 65,*,200,46,0;
}


bastien


From: suad [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Question in js about frameset rows
Date: Wed, 21 Jun 2006 11:44:07 +0200

Hi,

I have this page:

html
head
titletitle1/title
/head
frameset cols=*,200pxframeset id=frameset1 
rows=10%,30%,10%,*
   frame src=/page1.phtml name=name1 frameborder=0 
scrolling=no /

   frame src=/page2.phtml name=name2 frameborder=0 /
   frame src=/page3.phtml name=name3 frameborder=0 
scrolling=no /

   frame src=/page4.phtml name=name4 frameborder=0 /
 /frameset
 frame src=/page5.phtml name=name5 frameborder=0 /   
/frameset   /html


And this is the content of the page page1.phtml:

html
head
titlename1/title
/head
body
span onclick=alert(window.parent.frames[1].name);change size of 
frame 2/span

/body
/html

How can I change (using js) the rows of the frameset to:
frameset rows=10%,10%,10%,*

Thanks
Suad

--
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] Question in js about frameset rows

2006-06-21 Thread J R

appologies to the list. i think this should not be asked here. anyway i'll
answer.

IMHO, there is no easy way to do what you like. what i would suggest is use
document.write() or inclosing your frameset in a container div then
dynamically change it using innerHTML

hth

On 6/21/06, suad [EMAIL PROTECTED] wrote:


Hi,

I have this page:

html
head
titletitle1/title
/head
frameset cols=*,200px
  frameset id=frameset1 rows=10%,30%,10%,*
frame src=/page1.phtml name=name1 frameborder=0 scrolling=no
/
frame src=/page2.phtml name=name2 frameborder=0 /
frame src=/page3.phtml name=name3 frameborder=0 scrolling=no
/
frame src=/page4.phtml name=name4 frameborder=0 /
  /frameset
  frame src=/page5.phtml name=name5 frameborder=0 /
/frameset
/html

And this is the content of the page page1.phtml:

html
head
titlename1/title
/head
body
span onclick=alert(window.parent.frames[1].name);change size of
frame 2/span
/body
/html

How can I change (using js) the rows of the frameset to:
frameset rows=10%,10%,10%,*

Thanks
Suad

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





--
GMail Rocks!!!


RE: [PHP-DB] Question in js about frameset rows

2006-06-21 Thread Bastien Koert
I have fixed values that I adjust to, but you basically need to give the 
frame an ID and then use .rows and.columns to adjust the size


function shrink() {
   top.document.getElementById(TOP).rows = 65,*,0,46,0;
}

function expand() {

   top.document.getElementById(TOP).rows = 65,*,200,46,0;
}


bastien


From: suad [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Question in js about frameset rows
Date: Wed, 21 Jun 2006 11:44:07 +0200

Hi,

I have this page:

html
head
titletitle1/title
/head
frameset cols=*,200pxframeset id=frameset1 
rows=10%,30%,10%,*
   frame src=/page1.phtml name=name1 frameborder=0 scrolling=no 
/

   frame src=/page2.phtml name=name2 frameborder=0 /
   frame src=/page3.phtml name=name3 frameborder=0 scrolling=no 
/

   frame src=/page4.phtml name=name4 frameborder=0 /
 /frameset
 frame src=/page5.phtml name=name5 frameborder=0 /   /frameset   
/html


And this is the content of the page page1.phtml:

html
head
titlename1/title
/head
body
span onclick=alert(window.parent.frames[1].name);change size of frame 
2/span

/body
/html

How can I change (using js) the rows of the frameset to:
frameset rows=10%,10%,10%,*

Thanks
Suad

--
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] Question regarding the scope of pg_prepare

2006-04-14 Thread chris smith
On 4/14/06, Will Chapman [EMAIL PROTECTED] wrote:
 I have a few different pg_prepare statements in my PHP script.  I was
 wondering what scope they lie in.  Im assuming they are not saved in the
 PSQL database, so it is just for the script?  They are inside of
 functions... does it only last until the function exists?  I just dont
 want to keep on calling it if I don't have to.  Or do I need to call it
 each time the function is called.

They are not stored in the database. They are only used to build the
queries to send to the database.

Reading the example(s) on the php page (http://www.php.net/pg_prepare)
you can use them anywhere, they are in the global scope as long as you
give them different names.

stmtname
The name to give the prepared statement. Must be unique
per-connection. If  is specified, then an unnamed statement is
created, overwriting any previously defined unnamed statement.

I guess the easiest way is to create a simple script :) Prepare some
statements before and inside a function..

--
Postgresql  php tutorials
http://www.designmagick.com/

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



RE: [PHP-DB] Question on CURDATE()

2005-09-14 Thread reclmaples




**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


GWAVAsigI am using mysql Ver 12.22 Distrib 4.0.16

Sorry for not including that.

Thanks
-Rich

-Original Message-
From: Micah Stevens [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 13, 2005 9:13 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Question on CURDATE()



What SQL server are you using? 

On Tuesday 13 September 2005 7:08 pm, reclmaples wrote:
 I am trying to write a statement that will basically do this:

 SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;

 But for some reason I can only use one CURDATE() reference in my sql
 statement, does anyone know why?  Is there a way I can get around this?


 Any help would be greatly appreciated.

 Thanks
 -Rich

-- 
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




**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


GWAVAsigAdmID:5DCB563F8D32B50D1F0808DDF15FF28D



**

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.


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

Re: [PHP-DB] Question on CURDATE()

2005-09-13 Thread Micah Stevens

What SQL server are you using? 

On Tuesday 13 September 2005 7:08 pm, reclmaples wrote:
 I am trying to write a statement that will basically do this:

 SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;

 But for some reason I can only use one CURDATE() reference in my sql
 statement, does anyone know why?  Is there a way I can get around this?


 Any help would be greatly appreciated.

 Thanks
 -Rich

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



RE: [PHP-DB] Question on CURDATE()

2005-09-13 Thread reclmaples
I am using mysql Ver 12.22 Distrib 4.0.16

Sorry for not including that.

Thanks
-Rich

-Original Message-
From: Micah Stevens [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 13, 2005 9:13 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Question on CURDATE()



What SQL server are you using? 

On Tuesday 13 September 2005 7:08 pm, reclmaples wrote:
 I am trying to write a statement that will basically do this:

 SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;

 But for some reason I can only use one CURDATE() reference in my sql
 statement, does anyone know why?  Is there a way I can get around this?


 Any help would be greatly appreciated.

 Thanks
 -Rich

-- 
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] Question on CURDATE()

2005-09-13 Thread Micah Stevens

What's the exact error you're getting, I am able to do this:

SELECT curdate( ) AS one, curdate( ) AS two;

which results in this: 

 one two
2005-09-13  2005-09-13

No error, there is no limit to the number of times you can issue a date call 
according to the MySQL documentation.. well, it doesn't directly say that, 
but it doesn't say there's a limit either. 

Are you sure it isn't a syntax error? The example you sent is missing 
parenthesis in the last curdate call. This should work:

SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE();

Better, but I'm not sure if that's just a typo or not.

-Micah 
On Tuesday 13 September 2005 7:20 pm, reclmaples wrote:
 I am using mysql Ver 12.22 Distrib 4.0.16

 Sorry for not including that.

 Thanks
 -Rich

 -Original Message-
 From: Micah Stevens [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 13, 2005 9:13 PM
 To: php-db@lists.php.net
 Subject: Re: [PHP-DB] Question on CURDATE()



 What SQL server are you using?

 On Tuesday 13 September 2005 7:08 pm, reclmaples wrote:
  I am trying to write a statement that will basically do this:
 
  SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;
 
  But for some reason I can only use one CURDATE() reference in my sql
  statement, does anyone know why?  Is there a way I can get around this?
 
 
  Any help would be greatly appreciated.
 
  Thanks
  -Rich

 --
 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] Question on CURDATE()

2005-09-13 Thread Jordan Miller

Rich,

Did you try putting WHERE twice?

try:
SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and WHERE END = CURDATE;

Jordan



On Sep 13, 2005, at 9:08 PM, reclmaples wrote:


I am trying to write a statement that will basically do this:

SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;

But for some reason I can only use one CURDATE() reference in my sql
statement, does anyone know why?  Is there a way I can get around  
this?



Any help would be greatly appreciated.

Thanks
-Rich

--
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] Question on CURDATE()

2005-09-13 Thread Micah Stevens

You can't do that in SQL, that would give you a big fat syntax error. 

On Tuesday 13 September 2005 7:45 pm, Jordan Miller wrote:
 Rich,

 Did you try putting WHERE twice?

 try:
 SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and WHERE END = CURDATE;

 Jordan

 On Sep 13, 2005, at 9:08 PM, reclmaples wrote:
  I am trying to write a statement that will basically do this:
 
  SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;
 
  But for some reason I can only use one CURDATE() reference in my sql
  statement, does anyone know why?  Is there a way I can get around
  this?
 
 
  Any help would be greatly appreciated.
 
  Thanks
  -Rich
 
  --
  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] Question on CURDATE()

2005-09-13 Thread Jordan Miller

Micah,
Oh, my bad. I was trying to remember how I did something like this  
before, stringing together a lot of WHEREs. You're right, though,  
it wasn't WHERE, it was OR.


Rich,
I think you need OR instead of AND, OR else I'm just totally out  
to lunch tonight:

SELECT * FROM WEEKS WHERE BEGIN = CURDATE() OR END = CURDATE();

The syntax error is that something cannot be = AND = the same thing  
at the same time!


I have had this problem before in the past. You say to yourself,  
well, I need all of the records, so that intuitively makes you choose  
AND when in SQL it should technically be OR  (you want the  
records that are true for each of these operators separately, NOT at  
the same time, which for most records is impossible).


Also, you may want to take away one of the = signs, or you may get  
something = to CURDATE() twice (not sure how SQL handles this).


Maybe try (taking out one of the =):
SELECT * FROM WEEKS WHERE BEGIN = CURDATE() OR END  CURDATE();

Maybe it's just late over here. Has anyone else run into this same  
thing?


Jordan



On Sep 13, 2005, at 10:36 PM, Micah Stevens wrote:



You can't do that in SQL, that would give you a big fat syntax error.

On Tuesday 13 September 2005 7:45 pm, Jordan Miller wrote:


Rich,

Did you try putting WHERE twice?

try:
SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and WHERE END =  
CURDATE;


Jordan

On Sep 13, 2005, at 9:08 PM, reclmaples wrote:


I am trying to write a statement that will basically do this:

SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;

But for some reason I can only use one CURDATE() reference in my sql
statement, does anyone know why?  Is there a way I can get around
this?


Any help would be greatly appreciated.

Thanks
-Rich

--
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] Question on CURDATE()

2005-09-13 Thread Micah Stevens
Hi Jordan,

Syntactically, there is no restriction on OR'ing or AND'ing conditions. You 
could very well do this:

Select somefield where otherfield = 1 and otherfield = 2;

Of course, otherfield would never be both 1 and 2, so this is a worthless 
select statement, however, my point is, there would be no syntax error. 

Same deal with this:
SELECT * FROM WEEKS WHERE BEGIN = CURDATE() AND END = CURDATE();

This means, give me everything that begins before today or today, and after 
today or today.  Which of course is silly, that can't happen. So you'll never 
get anything back. However, there's nothing syntactically wrong with the 
statement. 

Replacing it by 'OR' give you all results, so it's just as silly why even have 
the 'WHERE' condition in the first place? I think reclmaples needs to 
re-analyze what he's trying to accomplish, but again, there's nothing 
syntactically (stupid spellcheck) wrong with the statement. 

I'm going out on a limb here, but it seems what the point is to get everythign 
that's not today, in which case you'd just say that:

SELECT * FROM WEEKS WHERE BEGIN != CURDATE();

Or, if you only want today:
SELECT * FROM WEEKS WHERE BEGIN = CURDATE();

I hope that helps? not sure, I may as I said be missing the goal. 

-Micah 


On Tuesday 13 September 2005 9:14 pm, Jordan Miller wrote:
 Micah,
 Oh, my bad. I was trying to remember how I did something like this
 before, stringing together a lot of WHEREs. You're right, though,
 it wasn't WHERE, it was OR.

 Rich,
 I think you need OR instead of AND, OR else I'm just totally out
 to lunch tonight:
 SELECT * FROM WEEKS WHERE BEGIN = CURDATE() OR END = CURDATE();

 The syntax error is that something cannot be = AND = the same thing
 at the same time!

 I have had this problem before in the past. You say to yourself,
 well, I need all of the records, so that intuitively makes you choose
 AND when in SQL it should technically be OR  (you want the
 records that are true for each of these operators separately, NOT at
 the same time, which for most records is impossible).

 Also, you may want to take away one of the = signs, or you may get
 something = to CURDATE() twice (not sure how SQL handles this).

 Maybe try (taking out one of the =):
 SELECT * FROM WEEKS WHERE BEGIN = CURDATE() OR END  CURDATE();

 Maybe it's just late over here. Has anyone else run into this same
 thing?

 Jordan

 On Sep 13, 2005, at 10:36 PM, Micah Stevens wrote:
  You can't do that in SQL, that would give you a big fat syntax error.
 
  On Tuesday 13 September 2005 7:45 pm, Jordan Miller wrote:
  Rich,
 
  Did you try putting WHERE twice?
 
  try:
  SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and WHERE END =
  CURDATE;
 
  Jordan
 
  On Sep 13, 2005, at 9:08 PM, reclmaples wrote:
  I am trying to write a statement that will basically do this:
 
  SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;
 
  But for some reason I can only use one CURDATE() reference in my sql
  statement, does anyone know why?  Is there a way I can get around
  this?
 
 
  Any help would be greatly appreciated.
 
  Thanks
  -Rich
 
  --
  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] Question on CURDATE()

2005-09-13 Thread Micah Stevens

Hi,

I just noticed I was wrong, the original SQL statement would return rows, but 
only if BEGIN = CURDATE(). I stated it would never happen, and that's wrong. 
Sorry. :) 

-Micah 

On Tuesday 13 September 2005 9:42 pm, Micah Stevens wrote:
 Hi Jordan,

 Syntactically, there is no restriction on OR'ing or AND'ing conditions. You
 could very well do this:

 Select somefield where otherfield = 1 and otherfield = 2;

 Of course, otherfield would never be both 1 and 2, so this is a worthless
 select statement, however, my point is, there would be no syntax error.

 Same deal with this:
 SELECT * FROM WEEKS WHERE BEGIN = CURDATE() AND END = CURDATE();

 This means, give me everything that begins before today or today, and after
 today or today.  Which of course is silly, that can't happen. So you'll
 never get anything back. However, there's nothing syntactically wrong with
 the statement.

 Replacing it by 'OR' give you all results, so it's just as silly why even
 have the 'WHERE' condition in the first place? I think reclmaples needs to
 re-analyze what he's trying to accomplish, but again, there's nothing
 syntactically (stupid spellcheck) wrong with the statement.

 I'm going out on a limb here, but it seems what the point is to get
 everythign that's not today, in which case you'd just say that:

 SELECT * FROM WEEKS WHERE BEGIN != CURDATE();

 Or, if you only want today:
 SELECT * FROM WEEKS WHERE BEGIN = CURDATE();

 I hope that helps? not sure, I may as I said be missing the goal.

 -Micah

 On Tuesday 13 September 2005 9:14 pm, Jordan Miller wrote:
  Micah,
  Oh, my bad. I was trying to remember how I did something like this
  before, stringing together a lot of WHEREs. You're right, though,
  it wasn't WHERE, it was OR.
 
  Rich,
  I think you need OR instead of AND, OR else I'm just totally out
  to lunch tonight:
  SELECT * FROM WEEKS WHERE BEGIN = CURDATE() OR END = CURDATE();
 
  The syntax error is that something cannot be = AND = the same thing
  at the same time!
 
  I have had this problem before in the past. You say to yourself,
  well, I need all of the records, so that intuitively makes you choose
  AND when in SQL it should technically be OR  (you want the
  records that are true for each of these operators separately, NOT at
  the same time, which for most records is impossible).
 
  Also, you may want to take away one of the = signs, or you may get
  something = to CURDATE() twice (not sure how SQL handles this).
 
  Maybe try (taking out one of the =):
  SELECT * FROM WEEKS WHERE BEGIN = CURDATE() OR END  CURDATE();
 
  Maybe it's just late over here. Has anyone else run into this same
  thing?
 
  Jordan
 
  On Sep 13, 2005, at 10:36 PM, Micah Stevens wrote:
   You can't do that in SQL, that would give you a big fat syntax error.
  
   On Tuesday 13 September 2005 7:45 pm, Jordan Miller wrote:
   Rich,
  
   Did you try putting WHERE twice?
  
   try:
   SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and WHERE END =
   CURDATE;
  
   Jordan
  
   On Sep 13, 2005, at 9:08 PM, reclmaples wrote:
   I am trying to write a statement that will basically do this:
  
   SELECT * FROM WEEKS WHERE BEGIN = CURDATE() and END = CURDATE;
  
   But for some reason I can only use one CURDATE() reference in my sql
   statement, does anyone know why?  Is there a way I can get around
   this?
  
  
   Any help would be greatly appreciated.
  
   Thanks
   -Rich
  
   --
   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] Question about COUNT(*)

2005-07-07 Thread Erick Wellem
Thanks Rory,

This query solves the problem:

SELECT client.client_name, IFNULL( COUNT( sales.sale_id ) , 0 ) AS total
FROM CLIENT LEFT JOIN sales ON client.client_id = sales.client_id
GROUP BY client.client_name
ORDER BY total DESC

Also thanks to Nandar and Prabhu, but MySQL does not recognize '*='
operator. 

You guys is very helpful, thanks again :)



Erick Wellem


snip
You could also try something like this:

SELECT client.name, IFNULL(COUNT(sales.sale_id), 0) AS total
FROM client LEFT JOIN sales ON client.client_id = sales.client_id
GROUP BY client.name
ORDER BY total DESC

The left join forces every record in the left table of the join (client)
to be present in the result set whether or not there are matching
entries in the right table (sales). The IFNULL takes care fo your count
problem.
/snip

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



Re: [PHP-DB] Question about COUNT(*)

2005-07-06 Thread Nandar
try this

SELECT client_name, COUNT(sale.client_id) as total
FROM client, sale
WHERE client.client_id *= sale.client_id
GROUP BY client_name
ORDER BY total DESC

nandar

- Original Message -
From: [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Wednesday, July 06, 2005 1:11 PM
Subject: [PHP-DB] Question about COUNT(*)


 Hi,

 Let's say that I have 2 tables: client and sales
 ---
 | client_id | client_name |
 ---
 | 1 | John|
 | 2 | Mark|
 | 3 | Luke|
 | 4 | Matthew |
 ---

 -
 | sale_id | client_id | sale_item   |
 -
 |   1 | 1 | Book|
 |   2 | 1 | Pencil  |
 |   3 | 1 | Pen |
 |   4 |   2 | Ruler   |
 |   5 | 2 | Bag |
 |   6 | 3 | Hat |
 -

 How can I have total purchased items for each of the client like this
table
 below since COUNT(*) is only for non-NULL values?
 ---
 | client_name | total |
 ---
 | John| 3 |
 | Mark| 2 |
 | Luke| 1 |
 | Matthew | 0 |
 ---

 I've tried: SELECT client.name, COUNT(*) total
 FROM client, sales
 WHERE client.client_id = sales.client_id
 GROUP BY client.client_name
 ORDER BY total DESC

 and it returns:
 ---
 | client_name | total |
 ---
 | John| 3 |
 | Mark| 2 |
 | Luke| 1 |
 ---

 How can I have Matthew who does't purchase anything on the list?
 Your help is much appreciated. Thanks.


 Erick Wellem

 --
 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] Question about COUNT(*)

2005-07-06 Thread Rory McKinley
[EMAIL PROTECTED] wrote:
 Hi,
 
 Let's say that I have 2 tables: client and sales
 ---
 | client_id | client_name |
 ---
 | 1 | John|
 | 2 | Mark|
 | 3 | Luke|
 | 4 | Matthew |
 ---
 
 -
 | sale_id | client_id | sale_item   |
 -
 |   1 | 1 | Book|
 |   2 | 1 | Pencil  |
 |   3 | 1 | Pen |
 |   4 | 2 | Ruler   |
 |   5 | 2 | Bag |
 |   6 | 3 | Hat |
 -
 
 How can I have total purchased items for each of the client like this table
 below since COUNT(*) is only for non-NULL values?
snip

You could also try something like this:

SELECT client.name, IFNULL(COUNT(sales.sale_id), 0) AS total
FROM client LEFT JOIN sales ON client.client_id = sales.client_id
GROUP BY client.name
ORDER BY total DESC

The left join forces every record in the left table of the join (client)
to be present in the result set whether or not there are matching
entries in the right table (sales). The IFNULL takes care fo your count
problem.

HTH

Rory

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



Re: [PHP-DB] Question regarding how-to stop the form inputting empty data at end of the form that is empty due to a carriage return

2005-01-13 Thread Manjiri Mahajan

Hi Mike,

I would suggest that you look for [A-Z],[a-z] and
[0-9] characters and build up your string for Media ID
instead of replacing \r and \n. I have gone
through the same situation for bar code scanning.

Regards,
Manjiri




__ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250

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



RE: [PHP-DB] Question regarding how-to stop the form inputting empty data at end

2005-01-11 Thread Bastien Koert
if the media_ID field is an autonumber, then there is no need to do anything 
with it...mysql will take the null and generate the next id.

bastien
From: Mike Millner [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Question regarding how-to stop the form inputting empty 
data at end of the form that is empty due to a carriage return
Date: Tue, 11 Jan 2005 18:52:10 -0700

Hello everyone,
I have this form that we use for keeping track of tapes we send off site 
for storage where I work. The form works almost perfectly with the help of 
a few people.

We use a scanner to input the tape id's. The scanner automatically puts a 
carriage return at the end of each tape so they all go on seperate lines.

Anyway the question is this: After the last tape is scanned I end up with a 
line put into the mysql db that looks like this: (from mysql log file)

243 Query   INSERT INTO tape_tracking_test 
(media_id,retention,out_date,return_date,box_id) values 
('','7WK=%s','2005-01-11','2005-3-01','006455C5092800')

If you look closely you'll see the first field is '' Single quotes with 
nothing in between.

How can I get PHP to ignore that line that has empty data in the media_id 
field? I have checking in place to not allow empty fields but PHP/mysql 
think that last carriage return is not empty.

I don't want to tell users they have to backspace at the end of the last 
tape (which fixes the problem)

I hope I'm explaining this properly. If not I'm sure you guys will let me 
know :)

Here is the script:
Above here is javascript for a calendar
//--
/script
/head
Body
body onLoad=showCalendar('now')
?php
if (isset($_POST['submit'])) { // Handle the form.
   $message = NULL; // Create an empty new variable.
   }
// Check for MediaID.
   if (strlen($_POST['MediaID'])  0) {
   $MediaID = TRUE;
   } else {
   $MediaID = FALSE;
   $message .= 'pYou forgot to enter a Media ID!/p';
   }
// Set the page title and include the HTML header.
$page_title = 'submit!';
?
form action=?php echo $_SERVER['PHP_SELF']; ? method=post
fieldsetlegendEnter the Tape information into the form below:/legend
pbRetention:/bbr
Select name=Retention
   option value=4WK4 Weeks/option
   option value=7WK7 Weeks/option
   option value=1YR1 Year/option
   option value=2YR2 Years/option
/select/p
pbOut Date:
/bbr input type=text name=OutDate size=20 maxlength=40 
value=?php print date(Y-m-d); ? //p

pbReturn Date:/b
script type=text/javascript 
language=JavaScriptdoRCCalendar()/script

pbBox ID:/bbr input type=text name=BoxID size=20 
maxlength=40 value=?php if (!empty($_POST['BoxID'])) echo 
$_POST['BoxID']; ? //p

pbMedia ID:/bbr
textarea name=MediaID rows=6 cols=24
?php if (!empty($_POST['MediaID'])) echo $_POST['MediaID']; ?

/textarea
form name=submit action=
div align=centerinput type=submit name=date value=Submit 
//div
/form
/fieldset

?
$delimiter = \n;
$MediaID_ar = explode($delimiter,$_POST['MediaID']);
$len_ar['MediaID'] = count($MediaID_ar);
$len_ar['Retention'] = strlen($_POST['Retention']);
$len_ar['OutDate'] = strlen($_POST['OutDate']);
$len_ar['ReturnDate'] = strlen($_POST['calendarDate']);
$len_ar['BoxID'] = strlen($_POST['BoxID']);
if(($len_ar['MediaID'])  ($len_ar['OutDate'])  ($len_ar['ReturnDate']) 
 ($len_ar['BoxID'])) {

define ('DB_USER', 'mysql');
define ('DB_PASSWORD', 'mysql');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'tape_track_db');
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die 
(mysql_error());
mysql_select_db (DB_NAME);


for($i=0; $i  $len_ar['MediaID']; $i++) {
$MediaID_ar[$i] = str_replace(array(\r,\n),,$MediaID_ar[$i]);
mysql_query (INSERT INTO tape_tracking_test 
(media_id,retention,out_date,return_date,box_id) values 
('.$MediaID_ar[$i].','. $_POST['Retention'] .=%s','. $_POST['OutDate'] 
.','. $_POST['calendarDate'] .','. $_POST['BoxID'] .'));
echo mysql_error();

}
mysql_close();
} else {
echo font color = RedpYou have not entered all information for each 
box./p/font;
}
?

/form!-- End of Form --
/body
/html
--
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] Question regarding how-to stop the form inputting empty data at end of the form that is empty due to a carriage return

2005-01-11 Thread Rory McKinley
Mike Millner wrote:
Hello everyone,
I have this form that we use for keeping track of tapes we send off site 
for storage where I work. The form works almost perfectly with the help 
of a few people.

We use a scanner to input the tape id's. The scanner automatically puts 
a carriage return at the end of each tape so they all go on seperate lines.

Anyway the question is this: After the last tape is scanned I end up 
with a line put into the mysql db that looks like this: (from mysql log 
file)

243 Query   INSERT INTO tape_tracking_test 
(media_id,retention,out_date,return_date,box_id) values 
('','7WK=%s','2005-01-11','2005-3-01','006455C5092800')

If you look closely you'll see the first field is '' Single quotes with 
nothing in between.

How can I get PHP to ignore that line that has empty data in the 
media_id field? I have checking in place to not allow empty fields but 
PHP/mysql think that last carriage return is not empty.

I don't want to tell users they have to backspace at the end of the last 
tape (which fixes the problem)

I hope I'm explaining this properly. If not I'm sure you guys will let 
me know :)

Here is the script:
Above here is javascript for a calendar
//--
/script
/head
Body
body onLoad=showCalendar('now')
?php
if (isset($_POST['submit'])) { // Handle the form.
   $message = NULL; // Create an empty new variable.
   }
// Check for MediaID.
   if (strlen($_POST['MediaID'])  0) {
   $MediaID = TRUE;
   } else {
   $MediaID = FALSE;
   $message .= 'pYou forgot to enter a Media ID!/p';
   }
// Set the page title and include the HTML header.
$page_title = 'submit!';
?
form action=?php echo $_SERVER['PHP_SELF']; ? method=post
fieldsetlegendEnter the Tape information into the form below:/legend
pbRetention:/bbr
Select name=Retention
   option value=4WK4 Weeks/option
   option value=7WK7 Weeks/option
   option value=1YR1 Year/option
   option value=2YR2 Years/option
/select/p
pbOut Date:
/bbr input type=text name=OutDate size=20 maxlength=40 
value=?php print date(Y-m-d); ? //p

pbReturn Date:/b
script type=text/javascript 
language=JavaScriptdoRCCalendar()/script

pbBox ID:/bbr input type=text name=BoxID size=20 
maxlength=40 value=?php if (!empty($_POST['BoxID'])) echo 
$_POST['BoxID']; ? //p

pbMedia ID:/bbr
textarea name=MediaID rows=6 cols=24
?php if (!empty($_POST['MediaID'])) echo $_POST['MediaID']; ?

/textarea
form name=submit action=
div align=centerinput type=submit name=date value=Submit 
//div
/form
/fieldset

?
$delimiter = \n;
$MediaID_ar = explode($delimiter,$_POST['MediaID']);
$len_ar['MediaID'] = count($MediaID_ar);
$len_ar['Retention'] = strlen($_POST['Retention']);
$len_ar['OutDate'] = strlen($_POST['OutDate']);
$len_ar['ReturnDate'] = strlen($_POST['calendarDate']);
$len_ar['BoxID'] = strlen($_POST['BoxID']);
if(($len_ar['MediaID'])  ($len_ar['OutDate'])  
($len_ar['ReturnDate'])  ($len_ar['BoxID'])) {

define ('DB_USER', 'mysql');
define ('DB_PASSWORD', 'mysql');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'tape_track_db');
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die 
(mysql_error());
mysql_select_db (DB_NAME);


for($i=0; $i  $len_ar['MediaID']; $i++) {
$MediaID_ar[$i] = str_replace(array(\r,\n),,$MediaID_ar[$i]);
mysql_query (INSERT INTO tape_tracking_test 
(media_id,retention,out_date,return_date,box_id) values 
('.$MediaID_ar[$i].','. $_POST['Retention'] .=%s','. 
$_POST['OutDate'] .','. $_POST['calendarDate'] .','. $_POST['BoxID'] 
.'));
echo mysql_error();

}
mysql_close();
} else {
echo font color = RedpYou have not entered all information for each 
box./p/font;
}
?

/form!-- End of Form --
/body
/html
Hi Mike
I am not sure of the format of the media id, but can you not use a 
simple regex so that if mediaID is not of a certain pattern (e.g. all 
alphanumeric and a certain length), the relevant corrective action is taken?

Regards
--
Rory McKinley
Nebula Solutions
+27 21 555 3227 - office
+27 21 551 0676 - fax
+27 82 857 2391 - mobile
www.nebula.co.za

--
Rory McKinley
Nebula Solutions
+27 21 555 3227 - office
+27 21 551 0676 - fax
+27 82 857 2391 - mobile
www.nebula.co.za

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


Re: [PHP-DB] Question: For no results

2004-12-03 Thread graeme
You might want to use:
mysql_num_rows function.mysql-num-rows.html -- Get number of rows in 
result


Stuart Felenstein wrote:
I want to send back a message when no matches are
found on my search page.  Basically No matches
found.  I assumed that mysql_fetch_assoc would be the
determining factor on whether any rows will come back.
As you can see below I do a if ($row_rsCS == false). 
Apparently though (while the message is sharp and
centered ;)), it is not to right place, since it sends
the message and exits whether records / matches exist
or not.   Any suggestions ?

Thank you 
Stuart

$query_limit_rsCS = sprintf(%s LIMIT %d, %d,
$query_rsCS, $startRow_rsCS, $maxRows_rsCS);
//print_r($query_limit_rsCS);
$rsCS = mysql_query($query_limit_rsCS, $Pmmodel) or
die(mysql_error());
//print_r($rsCS);
$row_rsCS = mysql_fetch_assoc($rsCS);
if ($row_rsCS == false)
?
p align=centerstrong?php print_r (No Matches
Found); ? /strong/p
?php
exit;
//print_r($row_rsCS);
if (isset($_GET['totalRows_rsCS'])) {
 $totalRows_rsCS = $_GET['totalRows_rsCS'];
} else {
 $all_rsCS = mysql_query($query_rsCS);
 $totalRows_rsCS = mysql_num_rows($all_rsCS);
}
$totalPages_rsCS =
ceil($totalRows_rsCS/$maxRows_rsCS)-1;
 



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 14:39, Stuart Felenstein wrote:

 I want to send back a message when no matches are
 found on my search page.  Basically No matches
 found.  I assumed that mysql_fetch_assoc would be the
 determining factor on whether any rows will come back.
  As you can see below I do a if ($row_rsCS == false).
 Apparently though (while the message is sharp and
 centered ;)), it is not to right place, since it sends
 the message and exits whether records / matches exist or not.   Any
 suggestions ? 
 
 Thank you
 Stuart
 
 $query_limit_rsCS = sprintf(%s LIMIT %d, %d,
 $query_rsCS, $startRow_rsCS, $maxRows_rsCS);
 //print_r($query_limit_rsCS);
 $rsCS = mysql_query($query_limit_rsCS, $Pmmodel) or
 die(mysql_error()); //print_r($rsCS);
 $row_rsCS = mysql_fetch_assoc($rsCS);
 
 if ($row_rsCS == false)
 ?

The closing ? of a PHP segment also implies an end-of-statement semicolon
-- so the above is equivalent to:

   if ($row_rsCS == false) ;
   ?

Which, of course, means that the scope of the if doesn't extend to anything
beyond this point.

You need to mark the block controlled by the if, using either {-} or
:-endif, according to your taste.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Stuart Felenstein
 The closing ? of a PHP segment also implies an
 end-of-statement semicolon
 -- so the above is equivalent to:
 
if ($row_rsCS == false) ;
?
 
 Which, of course, means that the scope of the if
 doesn't extend to anything
 beyond this point.
 
 You need to mark the block controlled by the if,
 using either {-} or
 :-endif, according to your taste.
 
The reason the close is there is because the next line
of code is the print_r , and I put some html in there.


Stuart

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 15:06, Stuart Felenstein wrote:

  The closing ? of a PHP segment also implies an
  end-of-statement semicolon
  -- so the above is equivalent to:
  
 if ($row_rsCS == false) ;
  ? 
  
  Which, of course, means that the scope of the if
  doesn't extend to anything
  beyond this point.
  
  You need to mark the block controlled by the if,
  using either {-} or
  :-endif, according to your taste.
  
 The reason the close is there is because the next line
 of code is the print_r , and I put some html in there.

Nothing wrong with having the closing ? there -- please re-read my
response.  If it's still unclear to you, please ask specific questions.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 15:16, Stuart Felenstein wrote:

 --- Stuart Felenstein [EMAIL PROTECTED] wrote:
 
  The reason the close is there is because the next
  line
  of code is the print_r , and I put some html in
  there.
  
 So this works great:
 
 if ($row_rsCS == false) {
 print_r (No Matches Found);
 exit;
 }
 
 But because I want to have some html formatting around
 the print_r, I closed the tags.

Yes, but you didn't include the { } to indicate the scope of the if -- so it
terminated at the ?.

  I'm not sure how to use the endif.

Well, your taste seems to be to use { }, so :-endif is irrelevant.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

 Well, your taste seems to be to use { }, so :-endif
 is irrelevant.
 
Alright it's Friday, I'm punchy but we're all in a
good mood !

Yes, I like the closing curlies

So, then where do these lovely ladies go here ?

if ($row_rsCS == false) {
p align=centerstrong?php print_r (No Matches
Found);? /strong/p
exit;
} 

Thank you 
Stuart

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 15:26, Stuart Felenstein wrote:

 --- Ford, Mike [EMAIL PROTECTED] wrote:
 
  Well, your taste seems to be to use { }, so :-endif is irrelevant.
  
 Alright it's Friday, I'm punchy but we're all in a
 good mood !
 
 Yes, I like the closing curlies
 
 So, then where do these lovely ladies go here ?
 
 if ($row_rsCS == false) {

?

 p align=centerstrong?php print_r (No Matches Found);?
 /strong/p

?php

 exit;
 }

Just put the PHP tags in as indicated and you'll be good to go.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 15:26, Stuart Felenstein wrote:

 --- Ford, Mike [EMAIL PROTECTED] wrote:
 
  Well, your taste seems to be to use { }, so :-endif is irrelevant.
  
 Alright it's Friday, I'm punchy but we're all in a
 good mood !
 
 Yes, I like the closing curlies
 
 So, then where do these lovely ladies go here ?
 
 if ($row_rsCS == false) {
 p align=centerstrong?php print_r (No Matches Found);?
 /strong/p exit;
 }

And, by the way, why on earth are you using a print_r an a straight literal
string?  Seems to me you could just put that text in as part of the HTML:

   if ($row_rsCS == false) {
   ?
 p align=centerstrongNo Matches Found/strong/p
   ?php
 exit;
   }

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

 And, by the way, why on earth are you using a
 print_r an a straight literal
 string?  Seems to me you could just put that text in
 as part of the HTML:
 
if ($row_rsCS == false) {
?
  p align=centerstrongNo Matches
 Found/strong/p
?php
  exit;
}
 
e...cause I have no idea what i'm doing :)
Not to be funny though, I'm at this 4 months , with no
previous experience with php, any database and html.  
I think I'm slowly catching on.  Code is no longer a
fuzzy mess of characters when I look at it.

Stuart

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



Re: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Stuart Felenstein
Sorry ..hit the wrong button
--- Stuart Felenstein [EMAIL PROTECTED] wrote:

 I posted this over on mysql list. Not trying to be
 redundant, but would like to get some feedback.
 
 Basically I'm wondering.
 I am creating a search form , dynamic query, that
 could potentially have in the area of 40+ where
 statements.
 
 i.e.   1- where x = y and
 2- cat = blue  and
 3- round = 1045...etc.  

Is there such a thing as where overload.  More
correctly too big of a sql statement.  I'm running on
a shared web host currently.  It's a decent machine,
but not a clustered itanium with load balancing.  

Interested in feedback.

Stuart

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



RE: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Bastien Koert
so...best to build the statement dynamically and execute it once only if the 
input box has a value in it...

$sql = select * from table where 1 ;
if (isset($_POST['field1'])){ $sql .=  and column1 = '.$_POST['field1']. 
';
...
if (isset($_POST['fieldN'])){ $sql .=  and columnN = '.$_POST['fieldN']. 
';

$result = mysql_query($sql);
...
bastien
From: Stuart Felenstein [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Question on the use of where statements
Date: Wed, 1 Dec 2004 07:28:24 -0800 (PST)
I posted this over on mysql list. Not trying to be
redundant, but would like to get some feedback.
Basically I'm wondering.
I am creating a search form , dynamic query, that
could potentially have in the area of 40+ where
statements.
i.3.   1- where x = y and
--
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] Question on the use of where statements

2004-12-01 Thread Stuart Felenstein
--- Bastien Koert [EMAIL PROTECTED] wrote:

 so...best to build the statement dynamically and
 execute it once only if the 
 input box has a value in it...
 

And that is the way I'm building it.  Just thinking
about the scenario that somone actually chooses 75% of
the options - would that potentially make a huge hit
on the system.

Stuart

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



RE: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Gryffyn, Trevor
I think you may hit the limit on the number of characters in the SELECT
statement before you hit the max number of WHERE items.

It's a good question though.Try doing a worst case scenario (pick
all the options, enter data that's the max character length for each
item, etc).  Either through your form or typing it all manually.  The
worst that'll happen is it'll say Sorry.. Too many characters or Too
many WHERE items or something.

Also, check the documentation for the database system you're using
(MySQL or whatever) and see if it says anything under the WHERE clause
or max length of SELECT statement.

If you find anything interesting, let us know.  Sorry couldn't give you
a better answer.

-TG

 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, December 01, 2004 10:56 AM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Question on the use of where statements
 
 
 --- Bastien Koert [EMAIL PROTECTED] wrote:
 
  so...best to build the statement dynamically and
  execute it once only if the 
  input box has a value in it...
  
 
 And that is the way I'm building it.  Just thinking
 about the scenario that somone actually chooses 75% of
 the options - would that potentially make a huge hit
 on the system.
 
 Stuart

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



RE: [PHP-DB] Question on the use of where statements

2004-12-01 Thread Bastien Koert
actually that would reduce it since a fewwer number of rows would 
potentially match the query...ensure that there is a composite index on a 
good selection of the columns to mkae the query quicker

bastien
From: Stuart Felenstein [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Question on the use of where statements
Date: Wed, 1 Dec 2004 07:55:35 -0800 (PST)
--- Bastien Koert [EMAIL PROTECTED] wrote:
 so...best to build the statement dynamically and
 execute it once only if the
 input box has a value in it...

And that is the way I'm building it.  Just thinking
about the scenario that somone actually chooses 75% of
the options - would that potentially make a huge hit
on the system.
Stuart
--
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] Question on FilesSessions

2004-11-19 Thread Gryffyn, Trevor
How are you storing the file in your PHP code?

If it'll fit in a variable, it should be able to be stored in $_SESSION.

This might mean using serialize() and unserialize().

Although someone may have a better way of doing this.  It seems to me
that storing an entire file in a variable is going to be cumbersome on
your server.  You might try storing the file name and path or something:

C:\somepath\somefilename.ext


Someone probably has a better way to do this, but those are my initial
thoughts.. Without much experience having to do something like this with
files and without knowing more about your situation.

-TG



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: Friday, November 19, 2004 11:46 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Question on FilesSessions
 
 
 Can you hold a file in a session?   I am trying to send a 
 file to a third page and it won't seem to work sending
 it in a session.   Does anyone know how to do this?
 
 Thanks
 
 
 Kathy A Wright | Keane Inc. | Suite: 
 Outside: 617-517-1706 | E-mail: [EMAIL PROTECTED]
 [ Mailing: 100 City Sq.  Charlestown, MA 02129 USA ]
 

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



RE: [PHP-DB] Question on FilesSessions

2004-11-19 Thread Bastien Koert
Better to save the file locally, the pass the name in a session variable. 
otherwise the overhead of holding a multi Kb or Mb file will be killer on 
the system.

What are you trying to do with the file?
Bastien

From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Question on FilesSessions
Date: Fri, 19 Nov 2004 11:45:45 -0500
Can you hold a file in a session?   I am trying to send a file to a third
page and it won't seem to work sending it in a session.   Does anyone know
how to do this?
Thanks
Kathy A Wright | Keane Inc. | Suite:
Outside: 617-517-1706 | E-mail: [EMAIL PROTECTED]
[ Mailing: 100 City Sq.  Charlestown, MA 02129 USA ]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Question

2004-11-09 Thread Norland, Martin
Does your form tag have enctype=multipart/form-data ?

e.g.
form action=?php echo($_SERVER['REQUEST_URI']) ? method=post
enctype=multipart/form-data

- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-Original Message-
From: Jacob Hackamack [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 08, 2004 11:54 PM
To: PHP Databases
Subject: [PHP-DB] Question


Hello,

I am using PostNuke and have decided to create a page for a local
basketball team.  I have this as the create team function:


//
/// Create a new Team for the given Tournament
///
/// Parameters:
/// 'cid' = Tournament ID
///'team' = Team name
/// 'contact' = name of the team representative
///   'email' = representative's email
///'homepage' = team's Homepage
//
function standings_admin_createteam($args)
{
// Get parameters from whatever input we need.
list($lid,$cid,$team,$city,$shorts,$tshirt,$shortsa,$tshirta,
 $contact,$phone,$paddress,$email,$homepage,$penpts,$picturet)
 = 
pnVarCleanFromInput('lid','cid','team','city','shorts','tshirt','shortsa
','t
shirta',
   
'contact','phone','paddress','email','homepage','penpts','picturet');

// Admin functions of this type can be called by other modules.
extract($args);

// Confirm authorisation code.
if (!pnSecConfirmAuthKey()) {
pnSessionSetVar('errormsg', _BADAUTHKEY);
pnRedirect(pnModURL('Standings', 'admin', 'viewteams',
array('lid' = $lid)));
return true;
}

$modid  = pnModGetIDFromName('Standings');
$modinfo= pnModGetInfo($modid);
$picenable  = pnModGetVar('Standings', 'picenable');

// Notable by its absence there is no security check here.  This is
because
// the security check is carried out within the API function and as
such we
// do not duplicate the work here

// Load API.
if (!pnModAPILoad('Standings', 'admin')) {
pnSessionSetVar('errormsg', _LOADFAILED);
return $output-GetOutput();
}

// The API function is called.
$tid = pnModAPIFunc('Standings','admin','createteam',
array('lid' = $lid,
  'team'= $team,
  'city'= $city,
  'shorts'  = $shorts,
  'tshirt'  = $tshirt,
  'shortsa' = $shortsa,
  'tshirta' = $tshirta,
  'contact' = $contact,
  'phone'   = $phone,
  'paddress'= $paddress,
  'email'   = $email,
  'homepage'= $homepage,
  'penpts'  = $penpts));

// The return value of the function is checked here
if ($tid != false) {
// Success
pnSessionSetVar('statusmsg', _STANDINGSTEAMCREATED);
}


/*
if ($picenable == 1) {
// manage picture Upload if there is a picture sent - Portrait if
($picture!=) { $picname = $_FILES['picture']['name'];

with:

if ($picenable == 1) {
// manage picture Upload if there is a picture sent
// make Portrait photo first
$picname = $_FILES['picturep']['name'];
if ($picname != ) {

*/
if ($picenable == 1) {
// manage picture Upload if there is a picture sent
// make Portrait photo first
   $picname = $_FILES['picturet']['name'];
   if ($picname != ) {
$pictype = $_FILES['picturet']['type'];
$picsize = $_FILES['picturet']['size'];
   $pictemp = $_FILES['picturet']['tmp_name'];
$picdest =
modules/.$modinfo['directory']./pnimages/photos/teams/team.$tid..jp
g;
   $picmax = pnModGetVar('Standings', 'picmaxt');
   $picwidth = pnModGetVar('Standings', 'xsizet');
   $picheight = pnModGetVar('Standings', 'ysizet');
   $picqual = pnModGetVar('Standings', 'picqualt');

   $picerror = ;
   // check if file is of the right type (jpg - gif - png) - Set in
config???
   if ($pictype != image/pjpeg) {
  $picerror = _STANDINGSPLAYERPICTERR1;
   }
   if ($picsize  $picmax) {
  $picerror = _STANDINGSPLAYERPICTERR2;
   }
   if ($picerror == ) {
  $g_is=getimagesize($pictemp);
  if(($g_is[0]-$picwidth)=($g_is[1]-$picheight)) {
  $g_iw=$picwidth;
  $g_ih=($picwidth/$g_is[0])*$g_is[1];
  } else {


  $g_ih=$picheight;
  $g_iw=($g_ih/$g_is[1])*$g_is[0];
  }

  $img_src = imageCreateFromJpeg($pictemp);
  $img_dst = imageCreateTrueColor($g_iw,$g_ih);
  imageCopyResampled($img_dst, $img_src, 0, 0, 

RE: [PHP-DB] Question: Copy and paste text into mysql text column

2004-10-19 Thread Ed Lazor
 I have a textarea field that will allow users to copy
 and paste text into , it might be plain text, or it
 might come out of word. 
 I'm wondering what type of validations I should
 perform on this field ?
 
 Any suggestions / ideas ?

Hi Stuart,

Check out the strip_tags and mysql_escape_string commands.  They allow you
to filter misc. code that might be imbedded in the data and also prepare the
data for insertion into the database (if you're going to store it).

Ed Lazor, President
http://RPGStore.com
Up to 50% off.  Over 20,000 items in stock 

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



RE: [PHP-DB] Question: Putting separate form elements into an array

2004-10-17 Thread Stuart Felenstein
Not exactly sure what I did here.  
there are 5 skill textfields name skill[]
then the years sky[]
then the last used slu[]

I was following the format of my other arrays, so
stored them list this:

if ( empty( $_SESSION['l_skill'] ) ) {
$_SESSION['l_skill']=array();
}

if ( is_array( $_REQUEST['skill'] ) ) {
$_SESSION['l_skill'] = array_unique(
array_merge( $_SESSION['l_skill'],
 $_REQUEST['skill'] )
);
}
if ( empty( $_SESSION['l_years'] ) ) {
$_SESSION['l_years']=array();
}

if ( is_array( $_REQUEST['sky'] ) ) {
$_SESSION['l_years'] = array_unique(
array_merge( $_SESSION['l_years'],
 $_REQUEST['sky'] )
);
}
if ( empty( $_SESSION['l_lastu'] ) ) {
$_SESSION['l_lastu']=array();
}

if ( is_array( $_REQUEST['slu'] ) ) {
$_SESSION['l_lastu'] = array_unique(
array_merge( $_SESSION['l_lastu'],
 $_REQUEST['slu'] )
);
}

I think that is all fine, but I think at the critical
moment (setup for database transaction is where my
problem is and it's probably slight)Read past the code
for my explanation.


if ( is_array( $_SESSION['l_skill'] ) ) {
foreach ( $_SESSION['l_skill'] as $s ) {
}
}
if ( is_array( $_SESSION['l_years'] ) ) {
foreach ( $_SESSION['l_years'] as $x ) {
}
}
if ( is_array( $_SESSION['l_lastu'] ) ) {
foreach ( $_SESSION['l_lastu'] 
as $z ) {
}
}

$query = INSERT INTO .)
VALUES ($, '$s', $x, $z);

At first I thought to nest all the if ( is_array
but that produced some funky loop.
So then I formatted as aboved.  Problem is all i'm
getting is the last element from each array into the
database.  
I'm thinking then, perhaps not nested , but the if is
arrays need to be formatted differently.

Stuart




--- Graham Cossey [EMAIL PROTECTED] wrote:

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



RE: [PHP-DB] Question: Putting separate form elements into an array

2004-10-17 Thread H. J. Wils
Hi everybody,
For quite a while i'm struggeled with my session. It doesn't seem to work, 
can anyone help me?

This is my code:
page 1:
session_start();
$_SESSION[test] = tryin...;
if (isset($_SESSION[test]))
{
  echo a href='session2.php'next page/a;
  echo br.session_id();
}
page 2:
session_start();
if (isset($_SESSION[test]))
{
  echo $_SESSION[test];
}else
{
  echo No sessionvariable found..;
}
echo br.session_id().br;
On page two, there's always the 'no sessionvariable found...'-message, 
further the session id also changes... i dont understand what i am doing 
wrong...

_
Play online games with your friends with MSN Messenger 
http://messenger.msn.nl/

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


RE: [PHP-DB] Question: Putting separate form elements into an array

2004-10-17 Thread Stuart Felenstein
Changed my direction somewhat but keep getting a parse
error and although I know where it is , I can't seem
to figure out what I need to do to make it syntax
correct:

This is how I am passing the arrays:

if ( empty( $_SESSION['l_skill'] ) ) {
$_SESSION['l_skill']=array();
}

if ( is_array( $_REQUEST['skill'] ) ) {
$_SESSION['l_skill'] = array_unique(
array_merge( $_SESSION['l_skill'],
 $_REQUEST['skill'] )
);
}

if ( empty( $_SESSION['l_sky'] ) ) {
$_SESSION['l_sky']=array();
}

if ( is_array( $_REQUEST['sky'] ) ) {
$_SESSION['l_sky'] = array_unique(
array_merge( $_SESSION['l_sky'],
 $_REQUEST['sky'] )
);
}

if ( empty( $_SESSION['l_slu'] ) ) {
$_SESSION['l_slu']=array();
}

if ( is_array( $_REQUEST['slu'] ) ) {
$_SESSION['l_slu'] = array_unique(
array_merge( $_SESSION['l_slu'],
 $_REQUEST['slu'] )
);
}

This is how I am trying to get them into the database:

$queries = array();
for($i=0; $icount($l_skill); $i++)
{
$queries[] = (' . $l_skill[$i] . ',  .
$l_sky[$i] . ,  . $l_slu[$i] . );
}

if(count($queries) == 0)
{
# Nothing passed
# exit
}

$query = INSERT INTO LurkProfiles_Skicerts
(ProfileID, SkilCerts, NumYear, Lused)
VALUES ($LUID . implode(, , $queries); 
  
//Above line is where I am having the problem.  There
is something between LUID and the implode statement. 
LUID is not passing into the insert generating a sql
error.


$result = mysql_query($query);
echo $query;







--- Stuart Felenstein [EMAIL PROTECTED] wrote:



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



RE: [PHP-DB] Question: Putting separate form elements into an array

2004-10-17 Thread Graham Cossey
Stuart, what does your echo($query) line output?

I would hazard a guess that your quotes are wrong and you are not getting
what you expect.

What is LUID?

I believe you will need to execute an INSERT query within each for($i=0;
$icount($l_skill); $i++) loop or increment  add $LUID within each
iteration, if this is the unique record ID for each record to be inserted.

Graham

[snip]

 This is how I am trying to get them into the database:

 $queries = array();
 for($i=0; $icount($l_skill); $i++)
 {
 $queries[] = (' . $l_skill[$i] . ',  .
 $l_sky[$i] . ,  . $l_slu[$i] . );
 }

 if(count($queries) == 0)
 {
 # Nothing passed
 # exit
 }

 $query = INSERT INTO LurkProfiles_Skicerts
 (ProfileID, SkilCerts, NumYear, Lused)
 VALUES ($LUID . implode(, , $queries);

 //Above line is where I am having the problem.  There
 is something between LUID and the implode statement.
 LUID is not passing into the insert generating a sql
 error.


 $result = mysql_query($query);
 echo $query;


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



RE: [PHP-DB] Question: Putting separate form elements into an array

2004-10-17 Thread Graham Cossey
Stuart, now I'm confused.

You seem to be posting slightly different versions of problems relating to
the same script(s) on 2 lists.

What is the current situation? Iterating through the 3 arrays or inserting
into MySQL?

Graham

 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
 Sent: 17 October 2004 16:14
 To: Stuart Felenstein; Graham Cossey; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Question: Putting separate form elements into an
 array


 Changed my direction somewhat but keep getting a parse
 error and although I know where it is , I can't seem
 to figure out what I need to do to make it syntax
 correct:

[snip]

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



RE: [PHP-DB] Question: Putting separate form elements into an array

2004-10-17 Thread Stuart Felenstein
Sorry about the two lists.  The echo's are fine.  The
problem was iterating through the 3 arrays.

Stuart
--- Graham Cossey [EMAIL PROTECTED] wrote:

 Stuart, now I'm confused.
 
 You seem to be posting slightly different versions
 of problems relating to
 the same script(s) on 2 lists.
 
 What is the current situation? Iterating through the
 3 arrays or inserting
 into MySQL?
 
 Graham
 
  -Original Message-
  From: Stuart Felenstein
 [mailto:[EMAIL PROTECTED]
  Sent: 17 October 2004 16:14
  To: Stuart Felenstein; Graham Cossey;
 [EMAIL PROTECTED]
  Subject: RE: [PHP-DB] Question: Putting separate
 form elements into an
  array
 
 
  Changed my direction somewhat but keep getting a
 parse
  error and although I know where it is , I can't
 seem
  to figure out what I need to do to make it syntax
  correct:
 
 [snip]
 
 
 

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



RE: [PHP-DB] Question: Putting separate form elements into an array

2004-10-16 Thread Graham Cossey

  Have you tried naming your form elements such as
  skill[], sky[] and slu[] ?
  (You could also use skill[1], skill[2], skill[3]
  etc... within your form.)

 Yes that makes sense.

Good.

This of course means you can build your form within a for loop (or similar).
So to place 10 skill text boxes in your form:
?php
for ($x=0; $x10; $x++)
{
  echo INPUT TYPE=\TEXT\ NAME=\skill[]\br/;
  // Add other form elements

  // ** OR **

  echo INPUT TYPE=\TEXT\ NAME=\skill[?=$x?]\br/;
  // Add other form elements
}
?

  You can just as easily store the arrays in your
  $_SESSION if the processing
  is to be done later.

 These are session , but put them into an array ?

$_SESSION['skills'] = $_POST['skill']; // Store the skill array
$_SESSION['skys'] = $_POST['sky']; // Store the sky array
$_SESSION['slus'] = $_POST['slu']; // Store the slu array


  Note: Some form element types only pass a value if
  ticked/checked/selected.

 The sky and slu are Dropdown Menu selects, so better
 with slu[1] or slu[x]?

Dropdown menus are fine (I believe) so you can simply use [] for your form
elements.


  This will present problems if naming your form
  elements with [], instead use
  [x], [y] etc to keep all relevant form elements
  together in the same array
  indexes. (Am I making sense?, No?, time for bed
  then...)
 

 Sort of , I need to process.  Have a good night !

Don't forget to use print_r() and echo to see what your PHP script is
receiving from the form, it will help understand how to code your script. It
took me a while to get to grips with how form arrays work. (Let's hope I
haven't c0cked up here or that last statement will come back to haunt me !!)

Now I'm off ...  ZZZzzz

Graham

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



Re: [PHP-DB] Question on Registration Method

2004-09-28 Thread Stuart Felenstein
Well, finally suceeding to get by activation page
working, where the 0 is flipped to 1 to mean actived,
I'm stuck on the login page.

Unfortunately I'm stuck :) with what I have below. 
It's part of an authentication system. This code
doesn't include the includes, but I thought maybe
significant enough to figure out where I can place a
line or two of code to throw an error on the
transaction if active != 1

Any ideas ?
Sorry if this is out of order.
Stuart 


//set the STARTER condition
$iLogin-registerTrigger(STARTER,'KT_TriggerSTARTER_Default',1,(isset($HTTP_POST_VARS['MM_Login'])
? $HTTP_POST_VARS['MM_Login'] : null));
//register the special Login Trigger
$iLogin-registerTrigger(AFTER,'KT_TriggerAFTER_LoginTrigger',1,'sessionvariable',(isset($HTTP_POST_VARS['RememberMe'])
? $HTTP_POST_VARS['RememberMe'] : null ));
// set the autogeneration information
$iLogin-generateSalt('xx');
$iLogin-setLoginTable('MemberTable');
$iLogin-passwordIsCryptedInDatabase(true);
$iLogin-setFields('MemberID','Username','password','level');
$iLogin-setValues((isset($HTTP_POST_VARS['username'])
? $HTTP_POST_VARS['username'] : null
),(isset($HTTP_POST_VARS['password']) ?
$HTTP_POST_VARS['password'] : null ));

// execute the transaction
$LurkerLogin-executeTransaction();

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



RE: [PHP-DB] Question on Registration Method

2004-09-26 Thread Oscar Rylin
Usergroups.
Most likely, you're dealing with an application where you'll want to have
different kinds of users (administrators, power users, users).

Just make a usergroup for accounts that haven't been activated yet.
Also, a separate table holding information on how to activate (something
along the lines of userid, tousergroup, activationcode).

/ rylin

-Original Message-
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
Sent: den 26 september 2004 13:46
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Question on Registration Method

Right now my registration / login system works like
this:

1-User goes to registration page and fills out form
2-User gets to choose username but password is
autogenerated by system
3-System encrypts password in database
4-Password is unencrypted and sent along with username
to registrant's email address
5-If email fails, insertion into registration database
is rolled back.

I have seen (as we all have) various types of reg
methods.  
While I'm okay with mine, not completely satisfied. 
I'd like to change it to the type where like above the
username and password is sent via email, but with the
addition of a link in the email whereby the user must
click on link to be activated.  You probably have
seen this, but to spell it out - even though they have
the user name and password it somehow is not good
enough to login with until this activation takes
place.

Basically I'm drawing a blank on the precise method
for this system.
Couple of thoughts - 
1-Perhaps there is another table that holds all new
registers until they are activated and then transfers
over the record(s) to the main reg table.
2-There is a column in the table that marks someone
registered ?
3-It's just governed by programming code 
4-Combination of database and PHP to make it work.

Alright , obviously I have no clue.
Appreciate some help, guidelines, pointers, etc.

Thank you,
Stuart

-- 
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] Question on Registration Method

2004-09-26 Thread Stuart Felenstein
Currently there are only 2 types of users planned 
Each has a basic access level.  I don't think this is
the same as a usergroup though.

If I don't have usergroups, but access levels, then
perhaps I should set the level to some less then what
is required login till activated.

Then it sounds like I have the system autogenerate an
activation code.

Not sure what you mean by :
 a separate table holding information on how to
 activate (something
 along the lines of userid, tousergroup,
 activationcode).


--- Oscar Rylin [EMAIL PROTECTED] wrote:

 Usergroups.
 Most likely, you're dealing with an application
 where you'll want to have
 different kinds of users (administrators, power
 users, users).
 
 Just make a usergroup for accounts that haven't been
 activated yet.
 Also, a separate table holding information on how to
 activate (something
 along the lines of userid, tousergroup,
 activationcode).
 
 / rylin
 

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread M Saleh EG
I'd do it this way...

I'd add two column in the users table. 1- activated, 2- activation-hash

once the registeration form is ubmited.. 
a-the username and user info will be saved in the users table.
b-an encrypted hash would be made n saved in activation-hash column
and sent along with the registeration info (username  pass) in the
form of a url (eg.
http://domain/activationpage.php?hash=ljk;lkj;lkjl;ksjfasdfa).

if the user is activated then the login function works for them if not
given a msg saying ur activation hasnt been done yet

the activatepage.php should then put 1, or on in the activated colum
in the users table on the row that has the hash passed to it.

simple enought aint it?


On Sun, 26 Sep 2004 05:02:07 -0700 (PDT), Stuart Felenstein
[EMAIL PROTECTED] wrote:
 Currently there are only 2 types of users planned
 Each has a basic access level.  I don't think this is
 the same as a usergroup though.
 
 If I don't have usergroups, but access levels, then
 perhaps I should set the level to some less then what
 is required login till activated.
 
 Then it sounds like I have the system autogenerate an
 activation code.
 
 Not sure what you mean by :
  a separate table holding information on how to
  activate (something
  along the lines of userid, tousergroup,
  activationcode).
 
 
 
 
 --- Oscar Rylin [EMAIL PROTECTED] wrote:
 
  Usergroups.
  Most likely, you're dealing with an application
  where you'll want to have
  different kinds of users (administrators, power
  users, users).
 
  Just make a usergroup for accounts that haven't been
  activated yet.
  Also, a separate table holding information on how to
  activate (something
  along the lines of userid, tousergroup,
  activationcode).
 
  / rylin
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



-- 
M.Saleh.E.G
97150-4779817

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread Stuart Felenstein
K...I've added the 2 columns, my names - activate and
activate_hash.

Upon registration, the activate_hash has a generated
string inserted.  activate column is default to 0.
I can compare it to the database - but not sure how to
flip the switch on the activate column 0-1
Is that done through an update mechanism ?

Stuart

--- Joseph Crawford [EMAIL PROTECTED] wrote:

 what i did is i used php to create a random string
 of numbers and
 letters about 15 chars long, then i store this in
 the db, and in the
 email i make the link
 page.php?code=RandomStringHere, then on the
 page.php i get the code and compare it to the ont in
 the database.  If
 they match activate the user otherwise show an
 error.
 
 
 
 
 On Sun, 26 Sep 2004 05:54:14 -0700 (PDT), Stuart
 Felenstein
 [EMAIL PROTECTED] wrote:
  Ok , I think this is along the lines of what I've
  started.  I added a column called active with a
  default to 0.  It's a tiny int since I'm think
  0=fales, 1=true.
  
  So can you explain a tad more about this hash
 stuff ?
  Is that specific to a sql field or just a name
 you've
  chose ?  I'm not sure what you mean in your last
  statement about the hash passing over to the
 activate
  column ?
  
  Stuart
  
  
  --- M Saleh EG [EMAIL PROTECTED] wrote:
  
   I'd do it this way...
  
   I'd add two column in the users table. 1-
 activated,
   2- activation-hash
  
   once the registeration form is ubmited..
   a-the username and user info will be saved in
 the
   users table.
   b-an encrypted hash would be made n saved in
   activation-hash column
   and sent along with the registeration info
 (username
pass) in the
   form of a url (eg.
  
 

http://domain/activationpage.php?hash=ljk;lkj;lkjl;ksjfasdfa).
  
   if the user is activated then the login function
   works for them if not
   given a msg saying ur activation hasnt been done
   yet
  
   the activatepage.php should then put 1, or on in
 the
   activated colum
   in the users table on the row that has the hash
   passed to it.
  
   simple enought aint it?
  
  
   On Sun, 26 Sep 2004 05:02:07 -0700 (PDT), Stuart
   Felenstein
   [EMAIL PROTECTED] wrote:
Currently there are only 2 types of users
 planned
Each has a basic access level.  I don't think
 this
   is
the same as a usergroup though.
   
If I don't have usergroups, but access levels,
   then
perhaps I should set the level to some less
 then
   what
is required login till activated.
   
Then it sounds like I have the system
 autogenerate
   an
activation code.
   
Not sure what you mean by :
 a separate table holding information on how
 to
 activate (something
 along the lines of userid, tousergroup,
 activationcode).
   
   
   
   
--- Oscar Rylin [EMAIL PROTECTED] wrote:
   
 Usergroups.
 Most likely, you're dealing with an
 application
 where you'll want to have
 different kinds of users (administrators,
 power
 users, users).

 Just make a usergroup for accounts that
 haven't
   been
 activated yet.
 Also, a separate table holding information
 on
   how to
 activate (something
 along the lines of userid, tousergroup,
 activationcode).

 / rylin

   
--
PHP Database Mailing List
 (http://www.php.net/)
To unsubscribe, visit:
   http://www.php.net/unsub.php
   
   
  
  
  
   --
   M.Saleh.E.G
   97150-4779817
  
  
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
  
  
 
 
 
 -- 
 Joseph Crawford Jr.
 Codebowl Solutions
 [EMAIL PROTECTED]
 802-558-5247
 
 For a GMail account
 contact me OFF-LIST
 
 -- 
 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] Question on Registration Method

2004-09-26 Thread Joseph Crawford
that is done when they click the link in thier email

if they are sent to domain.com/page.php?code=X4rfkj490T

the code in page.php will $_GET['code'] and compare it to the one in
the database, if they match, flip the switch if not show an error.



On Sun, 26 Sep 2004 06:35:59 -0700 (PDT), Stuart Felenstein
[EMAIL PROTECTED] wrote:
 K...I've added the 2 columns, my names - activate and
 activate_hash.
 
 Upon registration, the activate_hash has a generated
 string inserted.  activate column is default to 0.
 I can compare it to the database - but not sure how to
 flip the switch on the activate column 0-1
 Is that done through an update mechanism ?
 
 Stuart
 
 
 
 --- Joseph Crawford [EMAIL PROTECTED] wrote:
 
  what i did is i used php to create a random string
  of numbers and
  letters about 15 chars long, then i store this in
  the db, and in the
  email i make the link
  page.php?code=RandomStringHere, then on the
  page.php i get the code and compare it to the ont in
  the database.  If
  they match activate the user otherwise show an
  error.
 
 
 
 
  On Sun, 26 Sep 2004 05:54:14 -0700 (PDT), Stuart
  Felenstein
  [EMAIL PROTECTED] wrote:
   Ok , I think this is along the lines of what I've
   started.  I added a column called active with a
   default to 0.  It's a tiny int since I'm think
   0=fales, 1=true.
  
   So can you explain a tad more about this hash
  stuff ?
   Is that specific to a sql field or just a name
  you've
   chose ?  I'm not sure what you mean in your last
   statement about the hash passing over to the
  activate
   column ?
  
   Stuart
  
  
   --- M Saleh EG [EMAIL PROTECTED] wrote:
  
I'd do it this way...
   
I'd add two column in the users table. 1-
  activated,
2- activation-hash
   
once the registeration form is ubmited..
a-the username and user info will be saved in
  the
users table.
b-an encrypted hash would be made n saved in
activation-hash column
and sent along with the registeration info
  (username
 pass) in the
form of a url (eg.
   
  
 
 http://domain/activationpage.php?hash=ljk;lkj;lkjl;ksjfasdfa).
   
if the user is activated then the login function
works for them if not
given a msg saying ur activation hasnt been done
yet
   
the activatepage.php should then put 1, or on in
  the
activated colum
in the users table on the row that has the hash
passed to it.
   
simple enought aint it?
   
   
On Sun, 26 Sep 2004 05:02:07 -0700 (PDT), Stuart
Felenstein
[EMAIL PROTECTED] wrote:
 Currently there are only 2 types of users
  planned
 Each has a basic access level.  I don't think
  this
is
 the same as a usergroup though.

 If I don't have usergroups, but access levels,
then
 perhaps I should set the level to some less
  then
what
 is required login till activated.

 Then it sounds like I have the system
  autogenerate
an
 activation code.

 Not sure what you mean by :
  a separate table holding information on how
  to
  activate (something
  along the lines of userid, tousergroup,
  activationcode).




 --- Oscar Rylin [EMAIL PROTECTED] wrote:

  Usergroups.
  Most likely, you're dealing with an
  application
  where you'll want to have
  different kinds of users (administrators,
  power
  users, users).
 
  Just make a usergroup for accounts that
  haven't
been
  activated yet.
  Also, a separate table holding information
  on
how to
  activate (something
  along the lines of userid, tousergroup,
  activationcode).
 
  / rylin
 

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


   
   
   
--
M.Saleh.E.G
97150-4779817
   
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit:
  http://www.php.net/unsub.php
  
  
 
 
 
  --
  Joseph Crawford Jr.
  Codebowl Solutions
  [EMAIL PROTECTED]
  802-558-5247
 
  For a GMail account
  contact me OFF-LIST
  
  --
 
 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 



-- 
Joseph Crawford Jr.
Codebowl Solutions
[EMAIL PROTECTED]
802-558-5247

For a GMail account
contact me OFF-LIST

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread Stuart Felenstein
Nothing like sharing my pain ;) sorry!
It seems that in order to compare the code to the one
in the database, don't I need the userid or something?

or just that it exists in the database?

Thank you,
Stuart
--- Joseph Crawford [EMAIL PROTECTED] wrote:

 what i did is i used php to create a random string
 of numbers and
 letters about 15 chars long, then i store this in
 the db, and in the
 email i make the link
 page.php?code=RandomStringHere, then on the
 page.php i get the code and compare it to the ont in
 the database.  If
 they match activate the user otherwise show an
 error.
 
 
 
 
 On Sun, 26 Sep 2004 05:54:14 -0700 (PDT), Stuart
 Felenstein
 [EMAIL PROTECTED] wrote:
  Ok , I think this is along the lines of what I've
  started.  I added a column called active with a
  default to 0.  It's a tiny int since I'm think
  0=fales, 1=true.
  
  So can you explain a tad more about this hash
 stuff ?
  Is that specific to a sql field or just a name
 you've
  chose ?  I'm not sure what you mean in your last
  statement about the hash passing over to the
 activate
  column ?
  
  Stuart
  
  
  --- M Saleh EG [EMAIL PROTECTED] wrote:
  
   I'd do it this way...
  
   I'd add two column in the users table. 1-
 activated,
   2- activation-hash
  
   once the registeration form is ubmited..
   a-the username and user info will be saved in
 the
   users table.
   b-an encrypted hash would be made n saved in
   activation-hash column
   and sent along with the registeration info
 (username
pass) in the
   form of a url (eg.
  
 

http://domain/activationpage.php?hash=ljk;lkj;lkjl;ksjfasdfa).
  
   if the user is activated then the login function
   works for them if not
   given a msg saying ur activation hasnt been done
   yet
  
   the activatepage.php should then put 1, or on in
 the
   activated colum
   in the users table on the row that has the hash
   passed to it.
  
   simple enought aint it?
  
  
   On Sun, 26 Sep 2004 05:02:07 -0700 (PDT), Stuart
   Felenstein
   [EMAIL PROTECTED] wrote:
Currently there are only 2 types of users
 planned
Each has a basic access level.  I don't think
 this
   is
the same as a usergroup though.
   
If I don't have usergroups, but access levels,
   then
perhaps I should set the level to some less
 then
   what
is required login till activated.
   
Then it sounds like I have the system
 autogenerate
   an
activation code.
   
Not sure what you mean by :
 a separate table holding information on how
 to
 activate (something
 along the lines of userid, tousergroup,
 activationcode).
   
   
   
   
--- Oscar Rylin [EMAIL PROTECTED] wrote:
   
 Usergroups.
 Most likely, you're dealing with an
 application
 where you'll want to have
 different kinds of users (administrators,
 power
 users, users).

 Just make a usergroup for accounts that
 haven't
   been
 activated yet.
 Also, a separate table holding information
 on
   how to
 activate (something
 along the lines of userid, tousergroup,
 activationcode).

 / rylin

   
--
PHP Database Mailing List
 (http://www.php.net/)
To unsubscribe, visit:
   http://www.php.net/unsub.php
   
   
  
  
  
   --
   M.Saleh.E.G
   97150-4779817
  
  
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
  
  
 
 
 
 -- 
 Joseph Crawford Jr.
 Codebowl Solutions
 [EMAIL PROTECTED]
 802-558-5247
 
 For a GMail account
 contact me OFF-LIST
 
 -- 
 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] Question on Registration Method

2004-09-26 Thread Joseph Crawford
no you dont need a user id or anything, here is some sample code to
give you the idea

$result = mysql_query(SELECT fields FROM table WHERE code=.$_GET['code']);
if(mysql_num_rows($result)  0) {
  // we have a match, activate the account
  $result1 = mysql_query(UPDATE table SET activated=1 WHERE
code=.$_GET['code']);
  // show a page saying they are now activated
} else {
  // show an error
}


On Sun, 26 Sep 2004 07:18:54 -0700 (PDT), Stuart Felenstein
[EMAIL PROTECTED] wrote:
 Nothing like sharing my pain ;) sorry!
 It seems that in order to compare the code to the one
 in the database, don't I need the userid or something?
 
 or just that it exists in the database?
 
 Thank you,
 
 
 Stuart
 --- Joseph Crawford [EMAIL PROTECTED] wrote:
 
  what i did is i used php to create a random string
  of numbers and
  letters about 15 chars long, then i store this in
  the db, and in the
  email i make the link
  page.php?code=RandomStringHere, then on the
  page.php i get the code and compare it to the ont in
  the database.  If
  they match activate the user otherwise show an
  error.
 
 
 
 
  On Sun, 26 Sep 2004 05:54:14 -0700 (PDT), Stuart
  Felenstein
  [EMAIL PROTECTED] wrote:
   Ok , I think this is along the lines of what I've
   started.  I added a column called active with a
   default to 0.  It's a tiny int since I'm think
   0=fales, 1=true.
  
   So can you explain a tad more about this hash
  stuff ?
   Is that specific to a sql field or just a name
  you've
   chose ?  I'm not sure what you mean in your last
   statement about the hash passing over to the
  activate
   column ?
  
   Stuart
  
  
   --- M Saleh EG [EMAIL PROTECTED] wrote:
  
I'd do it this way...
   
I'd add two column in the users table. 1-
  activated,
2- activation-hash
   
once the registeration form is ubmited..
a-the username and user info will be saved in
  the
users table.
b-an encrypted hash would be made n saved in
activation-hash column
and sent along with the registeration info
  (username
 pass) in the
form of a url (eg.
   
  
 
 http://domain/activationpage.php?hash=ljk;lkj;lkjl;ksjfasdfa).
   
if the user is activated then the login function
works for them if not
given a msg saying ur activation hasnt been done
yet
   
the activatepage.php should then put 1, or on in
  the
activated colum
in the users table on the row that has the hash
passed to it.
   
simple enought aint it?
   
   
On Sun, 26 Sep 2004 05:02:07 -0700 (PDT), Stuart
Felenstein
[EMAIL PROTECTED] wrote:
 Currently there are only 2 types of users
  planned
 Each has a basic access level.  I don't think
  this
is
 the same as a usergroup though.

 If I don't have usergroups, but access levels,
then
 perhaps I should set the level to some less
  then
what
 is required login till activated.

 Then it sounds like I have the system
  autogenerate
an
 activation code.

 Not sure what you mean by :
  a separate table holding information on how
  to
  activate (something
  along the lines of userid, tousergroup,
  activationcode).




 --- Oscar Rylin [EMAIL PROTECTED] wrote:

  Usergroups.
  Most likely, you're dealing with an
  application
  where you'll want to have
  different kinds of users (administrators,
  power
  users, users).
 
  Just make a usergroup for accounts that
  haven't
been
  activated yet.
  Also, a separate table holding information
  on
how to
  activate (something
  along the lines of userid, tousergroup,
  activationcode).
 
  / rylin
 

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


   
   
   
--
M.Saleh.E.G
97150-4779817
   
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit:
  http://www.php.net/unsub.php
  
  
 
 
 
  --
  Joseph Crawford Jr.
  Codebowl Solutions
  [EMAIL PROTECTED]
  802-558-5247
 
  For a GMail account
  contact me OFF-LIST
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 



-- 
Joseph Crawford Jr.
Codebowl Solutions
[EMAIL PROTECTED]
802-558-5247

For a GMail account
contact me OFF-LIST

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread Stuart Felenstein
I'm getting an error using the
mysql_num_rows($result)

Warning: mysql_num_rows(): supplied argument is not a
valid MySQL result resource in
/home/lurkkcom/public_html/lurktivate.php on line 7

Why am I counting the number of rows in the table? 
Shouldn't I be looking to see if the code I was passed
exists within the table ?

Sorry and thank you,
Stuart




--- Joseph Crawford [EMAIL PROTECTED] wrote:

 no you dont need a user id or anything, here is some
 sample code to
 give you the idea
 
 $result = mysql_query(SELECT fields FROM table
 WHERE code=.$_GET['code']);
 if(mysql_num_rows($result)  0) {
   // we have a match, activate the account
   $result1 = mysql_query(UPDATE table SET
 activated=1 WHERE
 code=.$_GET['code']);
   // show a page saying they are now activated
 } else {
   // show an error
 }
 
 

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



RE: [PHP-DB] Question on Registration Method

2004-09-26 Thread Webmaster
 I'm getting an error using the
 mysql_num_rows($result)

 Warning: mysql_num_rows(): supplied argument is not a
 valid MySQL result resource in
 /home/lurkkcom/public_html/lurktivate.php on line 7

Did you happen to remember to change fields in the query string to your
table column names, and then table to your table name?

 Why am I counting the number of rows in the table? 
 Shouldn't I be looking to see if the code I was passed
 exists within the table ?

If a result is returned, i.e. the number of rows returned is greater than 0,
the page received a valid code and the user exists.

-JC

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread Jason Wong
On Sunday 26 September 2004 19:45, Stuart Felenstein wrote:

 While I'm okay with mine, not completely satisfied.
 I'd like to change it to the type where like above the
 username and password is sent via email, but with the
 addition of a link in the email whereby the user must
 click on link to be activated.  You probably have
 seen this, but to spell it out - even though they have
 the user name and password it somehow is not good
 enough to login with until this activation takes
 place.

Can someone please enlighten me on what extra security this method provides 
over and above the following more simple methods:

- Send user a system generated password with which they can login and 
subsequently change.

- Send user an activation link which once clicked on would activate them and 
allow them to choose a password.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Believe everything you hear about the world; nothing is too impossibly bad.
-- Honor'e de Balzac
*/

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread Stuart Felenstein
Unknown column 'a338265f' in 'where clause' is the
latest problem (and should be the last).  I had this
same error earlier while just doing a straight sql to
the database.  I corrected it then by putting
apostrophes around the column name.  That didn't help
here , not quotes , maybe double apostrophes?



$_GET['activate_hash])

This is where it's not picking the string correctly.

Stuart

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread Stuart Felenstein
How are they any different?

I'm seeing the same thing as your method.

Stuart
--- Jason Wong [EMAIL PROTECTED] wrote:

 On Sunday 26 September 2004 19:45, Stuart Felenstein
 wrote:
 
  While I'm okay with mine, not completely
 satisfied.
  I'd like to change it to the type where like above
 the
  username and password is sent via email, but with
 the
  addition of a link in the email whereby the user
 must
  click on link to be activated.  You probably
 have
  seen this, but to spell it out - even though they
 have
  the user name and password it somehow is not good
  enough to login with until this activation takes
  place.
 
 Can someone please enlighten me on what extra
 security this method provides 
 over and above the following more simple methods:
 
 - Send user a system generated password with which
 they can login and 
 subsequently change.
 
 - Send user an activation link which once clicked on
 would activate them and 
 allow them to choose a password.
 
 -- 
 Jason Wong - Gremlins Associates -
 www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet
 Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-db
 --
 /*
 Believe everything you hear about the world; nothing
 is too impossibly bad.
   -- Honor'e de Balzac
 */
 
 -- 
 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] Question on Registration Method

2004-09-26 Thread M Saleh EG
Stuart... u got the logic now. check ur syntax problems urself...
this is the only way ull learn it!

a hint... if ur database query is giving u errors... try echoing it
before sending it to mysql_query. ull find out the problem yourself
then ;)

another hint... mysql_query always returns arrays so u can check it
with is_array or count() or even with isset functions before getting
it in use. Having some error preventing mechanisms are always good.


On Sun, 26 Sep 2004 11:40:17 -0700 (PDT), Stuart Felenstein
[EMAIL PROTECTED] wrote:
 Unknown column 'a338265f' in 'where clause' is the
 latest problem (and should be the last).  I had this
 same error earlier while just doing a straight sql to
 the database.  I corrected it then by putting
 apostrophes around the column name.  That didn't help
 here , not quotes , maybe double apostrophes?
 
 $_GET['activate_hash])
 
 This is where it's not picking the string correctly.
 
 Stuart
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



-- 
M.Saleh.E.G
97150-4779817

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread Jason Wong
On Monday 27 September 2004 03:01, Stuart Felenstein wrote:
 How are they any different?

 I'm seeing the same thing as your method.

These two methods are separate:

  - Send user a system generated password with which
  they can login and
  subsequently change.

OR

  - Send user an activation link which once clicked on
  would activate them and
  allow them to choose a password.

What is the advantage in sending someone a password AND making them click on a 
link to activate?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
A countryman between two lawyers is like a fish between two cats.
-- Ben Franklin
*/

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



Re: [PHP-DB] Question on Registration Method

2004-09-26 Thread Joseph Crawford
$_GET['activation_hash] is missing the end '


On Mon, 27 Sep 2004 03:20:22 +0800, Jason Wong [EMAIL PROTECTED] wrote:
 On Monday 27 September 2004 03:01, Stuart Felenstein wrote:
  How are they any different?
 
  I'm seeing the same thing as your method.
 
 These two methods are separate:
 
   - Send user a system generated password with which
   they can login and
   subsequently change.
 
 OR
 
   - Send user an activation link which once clicked on
   would activate them and
   allow them to choose a password.
 
 What is the advantage in sending someone a password AND making them click on a
 link to activate?
 
 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-db
 --
 /*
 A countryman between two lawyers is like a fish between two cats.
 -- Ben Franklin
 
 
 */
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



-- 
Joseph Crawford Jr.
Codebowl Solutions
[EMAIL PROTECTED]
802-558-5247

For a GMail account
contact me OFF-LIST

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



Re: [PHP-DB] Question about undices for inversed LIKE statesments.

2004-05-31 Thread Daniel Clark
The index should still work normally.

Hello.
I have a question about behaviour of indices in queries with inversed LIKE
in MySQL. I mean something like this:

select foo from bar where '$some_string' LIKE some_field

where in the `some_field` I have a strings like 'symbols%' :)

Do you have some ideas?

WBR, Wicked

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



RE: RE: [PHP-DB] question on select

2004-05-13 Thread hengameh
; 
} 
} 
? 
/select 
/td 
/tr


tr 
td id=leftSelect your City: 
/td 

td id=right 
select name=ctSelect 
option value=please, select your city/option 
 
?php 
// City Select Box Populated with Values from 'city' table. 

// If and ELSE IF are if you have citys inside countrys (no states) Just
Delete it if its not needed. 
if ($dSel) { 
 // This is the SQL you should keep if you're gonna delete the IF, ELSE
IF. 
$city_sql = SELECT city,cityid, did FROM city WHERE did=$dSel ORDER BY
city; 
} 
//else if ($cSel  ($ctNoState == none)) { 
//$city_sql = SELECT city,cityid, did FROM city WHERE countryid=$cSel
ORDER BY city_name; 
//} 
if ($city_sql != ) { 
$city_qu = mysql_query($city_sql); 
while ($city_array = mysql_fetch_array($city_qu)) { 
$ctNa = $city_array[city]; 
$ctId = $city_array[cityid]; 
echo option value=$ctId$ctNa/option; 
} 
} 
? 
/select 
/td 
/tr 
tr 
td id=left/td 
td id=right/td 
/tr 
/table 
/form 
/body 
/html

-Original Message-
From: Neil Smith [MVP, Digital media] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 13, 2004 4:16 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re:RE: [PHP-DB] question on select

That *should* read :

document.fcountry.newcountry.value = 
document.fcountry.country[document.fcountry.country.selectedIndex].value;

Skip the 'options' object - I'm surprised you're not getting a javascript 
error, maybe you have error reporting turned off in your browser ? In any 
case, always 'alert' that value when you create it, so you know what you're 
actually submitting during testing.

At 04:06 13/05/2004 +, you wrote:
From: hengameh [EMAIL PROTECTED]
To: [EMAIL PROTECTED],
 [EMAIL PROTECTED]
Date: Wed, 12 May 2004 12:22:20 -0400
MIME-Version: 1.0
Content-Type: text/plain;
 charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] question on select

!--
function changeMenu()
   {
   document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedIndex].
v
alue;
  }
--
/script



CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

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



Re: [PHP-DB] question on select

2004-05-13 Thread Michael Forbes
Interesting idea.  Since I'm convinced that javascript is the bastard 
offspring of Bill Gates, Larry Ellison, and Baalzebub, can I sue too? :)

Hengameh wrote:

Well I am suing Java script to capture the selected item and make it the
value of my input box. But my problem is how to access this information from
this point on. Can someone please tell me how I can use the selected item in
my next SQL query?
-Original Message-
From: Tony S. Wu [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 11:07 AM
To: hengameh
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] question on select

sounds like a job for JavaScript.

Tony S. Wu
[EMAIL PROTECTED]
Look into the right places, you can find some good offerings.
http://homepage.mac.com/tonyswu/stw- The perfect business.
http://homepage.mac.com/tonyswu/tonyswu- My web page.
 
---



On May 12, 2004, at 7:02 AM, hengameh wrote:


Hello,

I am very new to php and mysql so please be patient with me. I don't  
even
know if I am using the right listing, but I hope someone can help me!



I need to create a select and the possible options are from my mysql
database ( so far so good, I was able to find code to do that).
Now I need to use the user selected option to drive the options of me  
next
select.  I need to know how to capture what user selected and how to  
pass
that around? I have used onchange attribute of the select to  
capture the
selected line but now how can I pass that to other php scripts?  ( I  
need to
get the name of the country so that I can show a list of possible
state/province. I setting the value of the newcountry input to the
selected country but when I do echo $newcountry in quicksearch.php,  
its
blank!!)

Please help!!



Thanks so much



Here is what I have so far:



Quicksearch.php file has the following code

br

table class='form'

 tr

   thSteps 1-4/th

 /tr



 trtd

   form name=fcountry method=post

 ?php  require(country_build.php);?

 input type=text name=newcountry value=



 /form



/td/tr

/table

!-- quicksearch.php   end --



script language=JavaScript

!--

function changeMenu()

 {

 document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedInd 
ex].v
alue;

}

--

/script



Countrty_buil.php has the following



?php

require_once(util.php);



echo SELECT name=\country\ class=\input\   
onchange=\changeMenu()\;

//

// initialize or capture the country variable

$country = !isset($_REQUEST['country'])? Select a country:
$_REQUEST['country'];
$countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];

echo option value='$countrySQL' SELECTED$country/option;

$query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country  
ASC;

// pconnect, select and query

if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME,  
DBPASSWORD))
{

 if ( mysql_select_db(DBNAME, $link_identifier)) {

   // run the query

$queryResultHandle = mysql_query($query, $link_identifier) or  
die(
mysql_error() );

$ctrRows = mysql_num_rows($queryResultHandle); // row counter

   // if data exists then $rows will be 1 or greater

   if( $ctrRows == 0 ) {

 echooption value='*'No data  
found/option/select;

   }else{

 // build the select list

 while($row = mysql_fetch_object($queryResultHandle))  
{ //
grab a row

   echo option
value=\$row-country\$row-country/option;
 }

 echo /SELECTbrbr;



   }

 }else{ // select

   echo mysql_error();

 }

}else{ //pconnect

 echo mysql_error();

}

?









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


Re: [PHP-DB] question on select

2004-05-12 Thread Tony S . Wu
sounds like a job for JavaScript.

Tony S. Wu
[EMAIL PROTECTED]
Look into the right places, you can find some good offerings.
http://homepage.mac.com/tonyswu/stw- The perfect business.
http://homepage.mac.com/tonyswu/tonyswu- My web page.
 
---



On May 12, 2004, at 7:02 AM, hengameh wrote:



Hello,

I am very new to php and mysql so please be patient with me. I don't  
even
know if I am using the right listing, but I hope someone can help me!



I need to create a select and the possible options are from my mysql
database ( so far so good, I was able to find code to do that).
Now I need to use the user selected option to drive the options of me  
next
select.  I need to know how to capture what user selected and how to  
pass
that around? I have used onchange attribute of the select to  
capture the
selected line but now how can I pass that to other php scripts?  ( I  
need to
get the name of the country so that I can show a list of possible
state/province. I setting the value of the newcountry input to the
selected country but when I do echo $newcountry in quicksearch.php,  
its
blank!!)

Please help!!



Thanks so much



Here is what I have so far:



Quicksearch.php file has the following code

br

table class='form'

  tr

thSteps 1-4/th

  /tr



  trtd

form name=fcountry method=post

  ?php  require(country_build.php);?

  input type=text name=newcountry value=



  /form



/td/tr

/table

!-- quicksearch.php   end --



script language=JavaScript

!--

function changeMenu()

  {

  document.fcountry.newcountry.value =
document.fcountry.country.options[document.fcountry.country.selectedInd 
ex].v
alue;

 }

--

/script



Countrty_buil.php has the following



?php

require_once(util.php);



echo SELECT name=\country\ class=\input\   
onchange=\changeMenu()\;

//

// initialize or capture the country variable

$country = !isset($_REQUEST['country'])? Select a country:
$_REQUEST['country'];
$countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];

echo option value='$countrySQL' SELECTED$country/option;

$query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country  
ASC;

// pconnect, select and query

if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME,  
DBPASSWORD))
{

  if ( mysql_select_db(DBNAME, $link_identifier)) {

// run the query

 $queryResultHandle = mysql_query($query, $link_identifier) or  
die(
mysql_error() );

 $ctrRows = mysql_num_rows($queryResultHandle); // row counter

// if data exists then $rows will be 1 or greater

if( $ctrRows == 0 ) {

  echooption value='*'No data  
found/option/select;

}else{

  // build the select list

  while($row = mysql_fetch_object($queryResultHandle))  
{ //
grab a row

echo option
value=\$row-country\$row-country/option;
  }

  echo /SELECTbrbr;



}

  }else{ // select

echo mysql_error();

  }

}else{ //pconnect

  echo mysql_error();

}

?











RE: [PHP-DB] question on select

2004-05-12 Thread hengameh
Well I am suing Java script to capture the selected item and make it the
value of my input box. But my problem is how to access this information from
this point on. Can someone please tell me how I can use the selected item in
my next SQL query?

-Original Message-
From: Tony S. Wu [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 11:07 AM
To: hengameh
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] question on select

sounds like a job for JavaScript.

Tony S. Wu
[EMAIL PROTECTED]

Look into the right places, you can find some good offerings.
http://homepage.mac.com/tonyswu/stw- The perfect business.
http://homepage.mac.com/tonyswu/tonyswu- My web page.
 
---



On May 12, 2004, at 7:02 AM, hengameh wrote:



 Hello,

 I am very new to php and mysql so please be patient with me. I don't  
 even
 know if I am using the right listing, but I hope someone can help me!



 I need to create a select and the possible options are from my mysql
 database ( so far so good, I was able to find code to do that).

 Now I need to use the user selected option to drive the options of me  
 next
 select.  I need to know how to capture what user selected and how to  
 pass
 that around? I have used onchange attribute of the select to  
 capture the
 selected line but now how can I pass that to other php scripts?  ( I  
 need to
 get the name of the country so that I can show a list of possible
 state/province. I setting the value of the newcountry input to the
 selected country but when I do echo $newcountry in quicksearch.php,  
 its
 blank!!)

 Please help!!



 Thanks so much



 Here is what I have so far:



 Quicksearch.php file has the following code

 br

 table class='form'

   tr

 thSteps 1-4/th

   /tr



   trtd

 form name=fcountry method=post

   ?php  require(country_build.php);?

   input type=text name=newcountry value=



   /form



 /td/tr

 /table

 !-- quicksearch.php   end --



 script language=JavaScript

 !--

 function changeMenu()

   {

   document.fcountry.newcountry.value =
 document.fcountry.country.options[document.fcountry.country.selectedInd 
 ex].v
 alue;

  }

 --

 /script



 Countrty_buil.php has the following



 ?php

 require_once(util.php);



 echo SELECT name=\country\ class=\input\   
 onchange=\changeMenu()\;

 //

 // initialize or capture the country variable

 $country = !isset($_REQUEST['country'])? Select a country:
 $_REQUEST['country'];

 $countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];

 echo option value='$countrySQL' SELECTED$country/option;

 $query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country  
 ASC;

 // pconnect, select and query

 if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME,  
 DBPASSWORD))
 {

   if ( mysql_select_db(DBNAME, $link_identifier)) {

 // run the query

  $queryResultHandle = mysql_query($query, $link_identifier) or  
 die(
 mysql_error() );

  $ctrRows = mysql_num_rows($queryResultHandle); // row counter

 // if data exists then $rows will be 1 or greater

 if( $ctrRows == 0 ) {

   echooption value='*'No data  
 found/option/select;

 }else{

   // build the select list

   while($row = mysql_fetch_object($queryResultHandle))  
 { //
 grab a row

 echo option
 value=\$row-country\$row-country/option;

   }

   echo /SELECTbrbr;



 }

   }else{ // select

 echo mysql_error();

   }

 }else{ //pconnect

   echo mysql_error();

 }

 ?










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



RE: [PHP-DB] question on select

2004-05-12 Thread Hutchins, Richard
You'd have to take the value of the first select box in your form and pass
it to another script. You can do that by setting the form's ACTION property
to either GET or POST. Personally, I prefer POST.

In the script to which you submit your form, you can access the value of the
select object thusly: $_POST[varname] and insert it into your query
however you want (using the appropriate input sanitization methods).

The important concept to understand here is that you cannot use PHP to drive
the contents of your second select object without a round-trip to the
server. Since PHP is a server-side technology, it HAS to work that way.

To make a client-side solution possible, you'd have to send ALL POSSIBLE
data to the page all at the same time then manipulate it with JavaScript.

You can make it LOOK like a dynamic solution by repeatedly resubmitting the
page to itself and using a combo platter of JS and PHP functions on the page
to handle data as it is progressively requested/sent, but you're still doing
a round-trip each time. It only looks like a client-side solution because
you submit to the same page all the time until certain conditions are
satisfied or your user clicks on a specific link or button.

If you're truly in search of a completely client-side solution using
JavaScript, I suggest checking the Javascript Boutique or Javascript Source
or any one of the hundreds of JS repositories you'll find in a google
search. There are many great examples of this problem such as selecting a
State in one select box then having the major cities in that State show up
in a second select object.

Hope this helped.

Rich



 -Original Message-
 From: hengameh [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, May 12, 2004 11:34 AM
 To: 'Tony S. Wu'
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] question on select
 
 
 Well I am suing Java script to capture the selected item and 
 make it the
 value of my input box. But my problem is how to access this 
 information from
 this point on. Can someone please tell me how I can use the 
 selected item in
 my next SQL query?
 
 -Original Message-
 From: Tony S. Wu [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, May 12, 2004 11:07 AM
 To: hengameh
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] question on select
 
 sounds like a job for JavaScript.
 
 Tony S. Wu
 [EMAIL PROTECTED]
 
 Look into the right places, you can find some good offerings.
 http://homepage.mac.com/tonyswu/stw- The perfect business.
 http://homepage.mac.com/tonyswu/tonyswu- My web page.
 --
 -- 
 ---
 
 
 
 On May 12, 2004, at 7:02 AM, hengameh wrote:
 
 
 
  Hello,
 
  I am very new to php and mysql so please be patient with 
 me. I don't  
  even
  know if I am using the right listing, but I hope someone 
 can help me!
 
 
 
  I need to create a select and the possible options are 
 from my mysql
  database ( so far so good, I was able to find code to do that).
 
  Now I need to use the user selected option to drive the 
 options of me  
  next
  select.  I need to know how to capture what user selected 
 and how to  
  pass
  that around? I have used onchange attribute of the select to  
  capture the
  selected line but now how can I pass that to other php 
 scripts?  ( I  
  need to
  get the name of the country so that I can show a list of possible
  state/province. I setting the value of the newcountry input to the
  selected country but when I do echo $newcountry in 
 quicksearch.php,  
  its
  blank!!)
 
  Please help!!
 
 
 
  Thanks so much
 
 
 
  Here is what I have so far:
 
 
 
  Quicksearch.php file has the following code
 
  br
 
  table class='form'
 
tr
 
  thSteps 1-4/th
 
/tr
 
 
 
trtd
 
  form name=fcountry method=post
 
?php  require(country_build.php);?
 
input type=text name=newcountry value=
 
 
 
/form
 
 
 
  /td/tr
 
  /table
 
  !-- quicksearch.php   end --
 
 
 
  script language=JavaScript
 
  !--
 
  function changeMenu()
 
{
 
document.fcountry.newcountry.value =
  
 document.fcountry.country.options[document.fcountry.country.se
 lectedInd 
  ex].v
  alue;
 
   }
 
  --
 
  /script
 
 
 
  Countrty_buil.php has the following
 
 
 
  ?php
 
  require_once(util.php);
 
 
 
  echo SELECT name=\country\ class=\input\   
  onchange=\changeMenu()\;
 
  //
 
  // initialize or capture the country variable
 
  $country = !isset($_REQUEST['country'])? Select a country:
  $_REQUEST['country'];
 
  $countrySQL = !isset($_REQUEST['country'])? *: 
 $_REQUEST['country'];
 
  echo option value='$countrySQL' SELECTED$country/option;
 
  $query = SELECT country FROM . TABLECOUNTRY .  ORDER BY country  
  ASC;
 
  // pconnect, select and query
 
  if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME,  
  DBPASSWORD))
  {
 
if ( mysql_select_db(DBNAME, $link_identifier

RE: [PHP-DB] question on select

2004-05-12 Thread hengameh
Thanks so much but I am so new to all this so need more explanation please.
I think at this point I don't mind the round trip to the server side till I
find a better way. But for now I think I have what you are suggesting but
then why my echo is not retuning anything :
form name=fcountry method=post action=$PHP_SELF
?php  require(country_build.php);?
input type=text name=newcountry value=
?php echo $_POST['newcountry'];?
/form
(country_build.php creates the select and its options)


-Original Message-
From: Hutchins, Richard [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 11:45 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] question on select

You'd have to take the value of the first select box in your form and pass
it to another script. You can do that by setting the form's ACTION property
to either GET or POST. Personally, I prefer POST.

In the script to which you submit your form, you can access the value of the
select object thusly: $_POST[varname] and insert it into your query
however you want (using the appropriate input sanitization methods).

The important concept to understand here is that you cannot use PHP to drive
the contents of your second select object without a round-trip to the
server. Since PHP is a server-side technology, it HAS to work that way.

To make a client-side solution possible, you'd have to send ALL POSSIBLE
data to the page all at the same time then manipulate it with JavaScript.

You can make it LOOK like a dynamic solution by repeatedly resubmitting the
page to itself and using a combo platter of JS and PHP functions on the page
to handle data as it is progressively requested/sent, but you're still doing
a round-trip each time. It only looks like a client-side solution because
you submit to the same page all the time until certain conditions are
satisfied or your user clicks on a specific link or button.

If you're truly in search of a completely client-side solution using
JavaScript, I suggest checking the Javascript Boutique or Javascript Source
or any one of the hundreds of JS repositories you'll find in a google
search. There are many great examples of this problem such as selecting a
State in one select box then having the major cities in that State show up
in a second select object.

Hope this helped.

Rich



 -Original Message-
 From: hengameh [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, May 12, 2004 11:34 AM
 To: 'Tony S. Wu'
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] question on select
 
 
 Well I am suing Java script to capture the selected item and 
 make it the
 value of my input box. But my problem is how to access this 
 information from
 this point on. Can someone please tell me how I can use the 
 selected item in
 my next SQL query?
 
 -Original Message-
 From: Tony S. Wu [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, May 12, 2004 11:07 AM
 To: hengameh
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] question on select
 
 sounds like a job for JavaScript.
 
 Tony S. Wu
 [EMAIL PROTECTED]
 
 Look into the right places, you can find some good offerings.
 http://homepage.mac.com/tonyswu/stw- The perfect business.
 http://homepage.mac.com/tonyswu/tonyswu- My web page.
 --
 -- 
 ---
 
 
 
 On May 12, 2004, at 7:02 AM, hengameh wrote:
 
 
 
  Hello,
 
  I am very new to php and mysql so please be patient with 
 me. I don't  
  even
  know if I am using the right listing, but I hope someone 
 can help me!
 
 
 
  I need to create a select and the possible options are 
 from my mysql
  database ( so far so good, I was able to find code to do that).
 
  Now I need to use the user selected option to drive the 
 options of me  
  next
  select.  I need to know how to capture what user selected 
 and how to  
  pass
  that around? I have used onchange attribute of the select to  
  capture the
  selected line but now how can I pass that to other php 
 scripts?  ( I  
  need to
  get the name of the country so that I can show a list of possible
  state/province. I setting the value of the newcountry input to the
  selected country but when I do echo $newcountry in 
 quicksearch.php,  
  its
  blank!!)
 
  Please help!!
 
 
 
  Thanks so much
 
 
 
  Here is what I have so far:
 
 
 
  Quicksearch.php file has the following code
 
  br
 
  table class='form'
 
tr
 
  thSteps 1-4/th
 
/tr
 
 
 
trtd
 
  form name=fcountry method=post
 
?php  require(country_build.php);?
 
input type=text name=newcountry value=
 
 
 
/form
 
 
 
  /td/tr
 
  /table
 
  !-- quicksearch.php   end --
 
 
 
  script language=JavaScript
 
  !--
 
  function changeMenu()
 
{
 
document.fcountry.newcountry.value =
  
 document.fcountry.country.options[document.fcountry.country.se
 lectedInd 
  ex].v

RE: [PHP-DB] question on select

2004-05-12 Thread dpgirago
 Thanks so much but I am so new to all this so need more explanation 
please.
 I think at this point I don't mind the round trip to the server side 
till I
 find a better way. But for now I think I have what you are suggesting 
but
 then why my echo is not retuning anything :
 form name=fcountry method=post action=$PHP_SELF
?php 
require(country_build.php);?
input type=text 
name=newcountry value=
?php echo 
$_POST['newcountry'];?
/form


Well, there is no value assgined to $_POST['newcountry'] in your example. 
How are you getting a value to that form field?

dave

RE: [PHP-DB] question on select

2004-05-12 Thread hengameh
Sorry that. I was trying to be modular! I also understand that everyone is
busy and I highly appreciate any help.
Anyway I cleaned it up a bit I hope its clear now ( all I am trying to do is
to show a list of countries from my database and then according to the
selected country make another select for the state/province and then pass
all that for further search):


script language=JavaScript
!--
function changeMenu(pulldown,input)
  {
input.value = pulldown.options[pulldown.selectedIndex].value;
 } 
-- 
/script

?php require_once(util.php);?

br
table class='form'
trthSteps 1-4/th/tr
trtd
form name=fcountry method=post action=$PHP_SELF
?php  getcountry();?
input type=text name=newcountry value=
?php echo $_POST['newcountry'];?
  /form
  /td/tr
/table
!-- quicksearch.php   end --

?php
function getcountry()
{
$sretval = SELECT name=\country\ class=\input\
onchange=\changeMenu(document.fcountry.country,document.fcountry.newcountry
)\;
//
// initialize or capture the country variable
$country = !isset($_REQUEST['country'])? Select a country:
$_REQUEST['country'];
$countrySQL = !isset($_REQUEST['country'])? *: $_REQUEST['country'];
$sretval .= option value='$countrySQL' SELECTED$country/option;
$query = SELECT * FROM . TABLECOUNTRY .  ORDER BY country ASC;
// pconnect, select and query
if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD))
{
if ( mysql_select_db(DBNAME, $link_identifier)) {
// run the query
   $queryResultHandle = mysql_query($query, $link_identifier) or
die( mysql_error() );
   $ctrRows = mysql_num_rows($queryResultHandle); // row counter
// if data exists then $rows will be 1 or greater
if( $ctrRows == 0 ) {
$sretval .=option value='*'No data
found/option/select;
}else{
// build the select list
while($row = mysql_fetch_object($queryResultHandle))
{ // grab a row
$sretval .=option
value=\$row-country\$row-country/option;
}
$sretval .= /SELECTbrbr;
echo $sretval;  
}
}else{ // select
echo mysql_error();
}
}else{ //pconnect
echo mysql_error();
}
}
?


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 12:41 PM
To: hengameh; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] question on select

 Here is the complete code. In the one line Java script that I have I am
 setting the value. So what am I missing?

For the sake of the listers trying to help you, and for your own clarity 
of concept, I'd suggest starting out by putting all your code into one 
file. It's quite hard to follow as you've presented it. 

Also, it may make it easier if you try concatenating all your output to 
one $variable, then print/echoing it out.

Don't mean to be difficult, but we all have our own projects to work on. 

dave 

-- 
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] Question

2004-02-09 Thread Fedde van Feggelen
Heyaz,

You've got some unclosed statements. Try using tabs for each statement to 
make it easier on yourself
like:
if ($iusetabs == true){
echo  like this ;
}

And in your code.. things go wrong here:
==
echo /table;
echo input type='submit' value='See how you did' name='submit';
echo /form;
} elseif ($submit) {
{
$score = 0;
$total = mysql_num_rows($result);

good luck to you

laters,

Fedde

~= The sum of the intelligence on the planet is a constant; the population 
is growing. =~


Re: [PHP-DB] Question

2004-02-09 Thread John W. Holmes
From: [EMAIL PROTECTED]

 Parse error: parse error, unexpected $end in C:\webroot\display.php on
line
 131

I'm not going to go through all of your code, but this error means you
missed a quote or bracket somewhere, i.e. you didn't supply a closing
bracket for an IF() condition.

?php
if($condition == 1)
{
  dothis();
?

---John Holmes...

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



RE: [PHP-DB] Question

2004-02-08 Thread Peter Lovatt
Hi

I think it may be the { and } which are used in php

if they are part of the data you are saving then try adding  a \ =  \{ and
\} if not remove them.

Peter


---
Excellence in internet and open source software
---
Sunmaia
Birmingham
UK
www.sunmaia.net
tel. 0121-242-1473
International +44-121-242-1473
---







-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 07 February 2004 19:37
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Question


Dear friends,

On submitting form to mysql database I get a parse error,There is no problem
with connection code, Problem is some where around create the sql statement
Can any one figure out where is the precise error, please.
Following is the code from php file

?php
// open the connection
$conn = mysql_connect(localhost, , );

// pick the database to use
mysql_select_db(testDB,$conn);

// create the SQL statement
$sql = INSERT INTO testtable values ('{$_POST[testField]}','
{$_POST[testFielda]}','{$_POST[testFieldb]}','{$_POST[testFieldd]}','
{$_POST[testFieldc]}','{$_POST[testFielde]}');



// execute the SQL statement
if (mysql_query($sql, $conn)) {
echo record added!;
} else {
echo something went wrong;
}
?

-
Asif

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



Re: [PHP-DB] Question

2004-02-07 Thread Ignatius Reilly
Quotes:
$_POST['testField']

_
- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, February 07, 2004 20:36
Subject: [PHP-DB] Question


 Dear friends,

 On submitting form to mysql database I get a parse error,There is no
problem
 with connection code, Problem is some where around create the sql
statement
 Can any one figure out where is the precise error, please.
 Following is the code from php file

 ?php
 // open the connection
 $conn = mysql_connect(localhost, , );

 // pick the database to use
 mysql_select_db(testDB,$conn);

 // create the SQL statement
 $sql = INSERT INTO testtable values ('{$_POST[testField]}','
 {$_POST[testFielda]}','{$_POST[testFieldb]}','{$_POST[testFieldd]}','
 {$_POST[testFieldc]}','{$_POST[testFielde]}');



 // execute the SQL statement
 if (mysql_query($sql, $conn)) {
 echo record added!;
 } else {
 echo something went wrong;
 }
 ?
 --
---
 Asif


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



Re: [PHP-DB] Question

2004-02-07 Thread Remember14a
Dear friend,

I changed 
$_POST['testField']
 instead of
 $_post[testField]
Before it was returning parse error now it doesnt return any error nor writes 
to mysql database, however  I used following sql staatement which wrote to 
database before


// create the SQL statement
$sql = INSERT INTO testTable values ('', '$_POST[testField]');

Now I have added more columns to database and form and made similar changes 
in the php script, now it doesnt write with this sql statement to database

// create the SQL statement
 $sql = INSERT INTO testtable values ('{$_POST[testField]}','
 {$_POST[testFielda]}','{$_POST[testFieldb]}','{$_POST[testFieldd]}','
 {$_POST[testFieldc]}','{$_POST[testFielde]}');

Any advice, please.

Asif


Re: [PHP-DB] question about '

2003-07-19 Thread David Robley
In article [EMAIL PROTECTED], 
[EMAIL PROTECTED] says...
 Hi there,
 
 The problem is the data is already in the DB, it was mass-added with the '
 already there, what I need is a way to retrieve the ' that is already in the
 DB.
 
 Thanks
 
 Chris
 
  yes, by adding stripslashes it will somewhat escape those quotes ('),
  but when displaying the results there will not be any need to do so.
  unless it is your wish to actually store the backslash into the db.
 
 
  Jerry wrote:
 
  I think you should use addslashes to store the text in the database and
  then stripslashes when displaying the text.  I think that should work,
  but I'm new to PHP so I might be wrong.
  
  Jerry
  
  -Original Message-
  From: Chris Payne [mailto:[EMAIL PROTECTED]
  Sent: Saturday, July 12, 2003 2:11 PM
  To: php
  Subject: [PHP-DB] question about '
  
  
  Hi there everyone,
  
  I am having alittle problem.  I am calling some text that has a ' in it
  in the DB, but when it is being displayed on the screen the ' becomes a
  ? any ideas?  I'm displaying just with a ?=$ctitle? and everything
  works great except that.  I just read about addslashes and stripslashes
  etc . but not sure if that's relevant to this being that the data in
  the DB has a single ' already there.
  
  Anyway help would be appreciated :-)

Is it possible that this is one of the Microsoft Word 'smart quote' things 
and you are displaying it in other than IE? You may need to track down the 
ascii value for it/them and run a conversion on your data prior to 
display.

I have found this happens where people copy/paste data from MS Word to 
input forms.

-- 
Quod subigo farinam

$email =~ s/oz$/au/o;


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



RE: [PHP-DB] question about '

2003-07-11 Thread Jerry
I think you should use addslashes to store the text in the database and
then stripslashes when displaying the text.  I think that should work,
but I'm new to PHP so I might be wrong.

Jerry

-Original Message-
From: Chris Payne [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 12, 2003 2:11 PM
To: php
Subject: [PHP-DB] question about '


Hi there everyone,

I am having alittle problem.  I am calling some text that has a ' in it
in the DB, but when it is being displayed on the screen the ' becomes a
? any ideas?  I'm displaying just with a ?=$ctitle? and everything
works great except that.  I just read about addslashes and stripslashes
etc . but not sure if that's relevant to this being that the data in
the DB has a single ' already there.

Anyway help would be appreciated :-)

Regards

Chris


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



Re: [PHP-DB] question about '

2003-07-11 Thread Shahmat Dahlan
yes, by adding stripslashes it will somewhat escape those quotes ('), 
but when displaying the results there will not be any need to do so. 
unless it is your wish to actually store the backslash into the db.

Jerry wrote:

I think you should use addslashes to store the text in the database and
then stripslashes when displaying the text.  I think that should work,
but I'm new to PHP so I might be wrong.
Jerry

-Original Message-
From: Chris Payne [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 12, 2003 2:11 PM
To: php
Subject: [PHP-DB] question about '

Hi there everyone,

I am having alittle problem.  I am calling some text that has a ' in it
in the DB, but when it is being displayed on the screen the ' becomes a
? any ideas?  I'm displaying just with a ?=$ctitle? and everything
works great except that.  I just read about addslashes and stripslashes
etc . but not sure if that's relevant to this being that the data in
the DB has a single ' already there.
Anyway help would be appreciated :-)

Regards

Chris

 



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


Re: [PHP-DB] question about '

2003-07-11 Thread Chris Payne
Hi there,

The problem is the data is already in the DB, it was mass-added with the '
already there, what I need is a way to retrieve the ' that is already in the
DB.

Thanks

Chris

 yes, by adding stripslashes it will somewhat escape those quotes ('),
 but when displaying the results there will not be any need to do so.
 unless it is your wish to actually store the backslash into the db.


 Jerry wrote:

 I think you should use addslashes to store the text in the database and
 then stripslashes when displaying the text.  I think that should work,
 but I'm new to PHP so I might be wrong.
 
 Jerry
 
 -Original Message-
 From: Chris Payne [mailto:[EMAIL PROTECTED]
 Sent: Saturday, July 12, 2003 2:11 PM
 To: php
 Subject: [PHP-DB] question about '
 
 
 Hi there everyone,
 
 I am having alittle problem.  I am calling some text that has a ' in it
 in the DB, but when it is being displayed on the screen the ' becomes a
 ? any ideas?  I'm displaying just with a ?=$ctitle? and everything
 works great except that.  I just read about addslashes and stripslashes
 etc . but not sure if that's relevant to this being that the data in
 the DB has a single ' already there.
 
 Anyway help would be appreciated :-)
 
 Regards
 
 Chris
 
 
 
 




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



Re: [PHP-DB] Question about replacing large textfields

2003-02-14 Thread Doug Thompson
http://www.hotscripts.com/PHP/

One example:
http://www.hotscripts.com/Detailed/9026.html

Good luck,
Doug

On Fri, 14 Feb 2003 16:09:34 +0100, Ingen, Wart van wrote:

Hi there,
 
I'm looking for a way to let people without any knowledge of coding replace
large fields of text and images on their website.
Is there anyone who knows some way to do this with MySQL and PHP ? Maybe
someone knows where I can find an online 
tutorial about this?
 
Thanks a bunch




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




Re: [PHP-DB] question about access

2003-02-10 Thread Doug Thompson
If your client's friend wants to do learning/development, let him load
PHPTriad, FoxServ, or one of the other trinity setups onto his
computer.

It is truly remarkable that you/your company would even consider such a
request for longer than it takes to say: Never in a million years.

Also, if I were running security at your site, I would closely monitor
that client's activities on the system assuming that's how you are set
up.  That is a loose cannon out there.

Doug

On Mon, 10 Feb 2003 10:29:18 -0600, Terry Romine wrote:

I'd like to get some opinions from the list.

We run php/mysql on our linux servers located behind a firewall. Many 
of our clients have scripts that access their databases via php running 
on the hosting server, and the general access is set up as:

   $hostname = localhost;
   $database  = clientsDB;
   $username = client;
   $password = ;

   etc..

One of our clients has a friend who wants to do some php/mysql and has 
asked for access to the database. We gave them the information above, 
and he complains that localhost is insufficient. We think that if he 
is requesting servername.domain.net:accessPort that that gives him 
access through the firewall. Instead, he should upload his scripts 
using ftp and use localhost, as all our other clients do.

What is the general consensus?

If giving an outsider this kind of access just asking for trouble?

Terry



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




Re: [PHP-DB] Question on the port PHP uses to connect to remote MySQL

2003-01-29 Thread Matt Vos
In a default setup, I believe the port is 3306.
Check your MySQL config files, as this can be changed.

Matt
- Original Message - 
From: Louis Feng [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 28, 2003 10:34 PM
Subject: [PHP-DB] Question on the port PHP uses to connect to remote MySQL


 Here is my problem. I have PHP running on one machine, mysql on another 
 one. Everything works fine till I put a firewall on the PHP machine, 
 which blocks pretty much every port there is except port 80. Now, PHP 
 can't connect to the mysql database anymore. If I disable the firewall 
 on the PHP machine it works again. So I eliminate the reasons down to 
 that PHP must uses some port for mysql return the query. The question is 
 which port does PHP use for the connection? I'm NOT talking about 3306 
 which is used by Mysql. Anyone could help? Thanks in advance.
 
 Louis
 
 
 -- 
 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] Question on the port PHP uses to connect to remote MySQL

2003-01-29 Thread Jeffrey_N_Dyke

it IS 3306(in a default setup) that you'll need to allow traffic through
the firewall for this scenario.  I have similar needs and that is the port
we open.


   
 
Matt Vos 
 
vos@techcomne   To: Louis Feng [EMAIL PROTECTED], 
[EMAIL PROTECTED]   
t.com   cc:   
 
 Subject: Re: [PHP-DB] Question on the 
port PHP uses to connect to  
01/29/2003remote MySQL 
 
09:29 AM   
 
   
 
   
 




In a default setup, I believe the port is 3306.
Check your MySQL config files, as this can be changed.

Matt
- Original Message -
From: Louis Feng [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 28, 2003 10:34 PM
Subject: [PHP-DB] Question on the port PHP uses to connect to remote MySQL


 Here is my problem. I have PHP running on one machine, mysql on another
 one. Everything works fine till I put a firewall on the PHP machine,
 which blocks pretty much every port there is except port 80. Now, PHP
 can't connect to the mysql database anymore. If I disable the firewall
 on the PHP machine it works again. So I eliminate the reasons down to
 that PHP must uses some port for mysql return the query. The question is
 which port does PHP use for the connection? I'm NOT talking about 3306
 which is used by Mysql. Anyone could help? Thanks in advance.

 Louis


 --
 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] Question on the port PHP uses to connect to remote MySQL

2003-01-29 Thread Louis Feng
Thanks for reply, I'm going to try that, but how could this be? I just 
want to make sure I was clear that there is no problem to connect to the 
remote MySQL server and there is nothing blocking that machine. It's the 
PHP machine that's blocking any incoming traffic from the MySQL machine. 
How could PHP use a port number that is also used by MySQL?

Louis

[EMAIL PROTECTED] wrote:

it IS 3306(in a default setup) that you'll need to allow traffic through
the firewall for this scenario.  I have similar needs and that is the port
we open.


   
   Matt Vos  
   vos@techcomne   To: Louis Feng [EMAIL PROTECTED], [EMAIL PROTECTED]   
   t.com   cc:
Subject: Re: [PHP-DB] Question on the port PHP uses to connect to  
   01/29/2003remote MySQL  
   09:29 AM
   
   




In a default setup, I believe the port is 3306.
Check your MySQL config files, as this can be changed.

Matt
- Original Message -
From: Louis Feng [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 28, 2003 10:34 PM
Subject: [PHP-DB] Question on the port PHP uses to connect to remote MySQL


 

Here is my problem. I have PHP running on one machine, mysql on another
one. Everything works fine till I put a firewall on the PHP machine,
which blocks pretty much every port there is except port 80. Now, PHP
can't connect to the mysql database anymore. If I disable the firewall
on the PHP machine it works again. So I eliminate the reasons down to
that PHP must uses some port for mysql return the query. The question is
which port does PHP use for the connection? I'm NOT talking about 3306
which is used by Mysql. Anyone could help? Thanks in advance.

Louis


--
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] Question on the port PHP uses to connect to remote MySQL

2003-01-29 Thread Louis Feng
Hi Jeff,

Thanks for your help. The machine [A] is running MySQL is Not behind a 
firewall, therefore all connection to [A] works fine (including 3306). 
The machine [B] running PHP/apache is behind a firewall, and only port 
80 is open on [B]. If I want to do some query on MySQL of [A] from [B] 
where PHP resides, then the problem occurs (from other machines without 
firewall to do the query on [A] work fine). Basically PHP can send out 
query to [A] (since [A] is open), but when [A] returns the result to 
PHP, it's blocked by the firewall on [B], because I believe PHP uses 
certain port for MySQL return the result. Is it clear?

I attached a picture and hopefully helps. Thanks!

Louis

[EMAIL PROTECTED] wrote:

 
loius.  how do you know it's the mysql host that can not get to the 
php host? i may have misunderstood.  port 3306 needs to be enabled to 
allow traffic though the firewall and into the mysql host, since that 
connection has been established the data is returned back to the php 
host.   the mysql host shouldn't be able to connect to the php host in 
the same way, only through a connection originating through port 3306. 
 then you can also limit to domain names that are allowed to enter the 
mysql host on 3306.

don't know if this helps, but i think this is your scenario.  let me 
know.  i'm definitely interested.  Hopefully i explained it correctly, 
i'm definitely not a firewall guy...but i try to pay attention.

Jeff
*Louis Feng [EMAIL PROTECTED]*
01/29/2003 07:11 PM

To: [EMAIL PROTECTED]
cc: Matt Vos [EMAIL PROTECTED], Louis Feng [EMAIL PROTECTED], 
[EMAIL PROTECTED]
bcc:
Subject: Re: [PHP-DB] Question on the port PHP uses to connect to 
remote MySQL


Thanks for reply, I'm going to try that, but how could this be? I just
want to make sure I was clear that there is no problem to connect to the
remote MySQL server and there is nothing blocking that machine. It's the
PHP machine that's blocking any incoming traffic from the MySQL machine.
How could PHP use a port number that is also used by MySQL?

Louis

[EMAIL PROTECTED] wrote:

it IS 3306(in a default setup) that you'll need to allow traffic through
the firewall for this scenario.  I have similar needs and that is the 
port
we open.



Matt Vos
vos@techcomne   To: Louis Feng 
[EMAIL PROTECTED], [EMAIL PROTECTED]
t.com   cc:
 Subject: Re: [PHP-DB] 
Question on the port PHP uses to connect to
01/29/2003remote MySQL
09:29 AM






In a default setup, I believe the port is 3306.
Check your MySQL config files, as this can be changed.

Matt
- Original Message -
From: Louis Feng [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 28, 2003 10:34 PM
Subject: [PHP-DB] Question on the port PHP uses to connect to remote 
MySQL




Here is my problem. I have PHP running on one machine, mysql on another
one. Everything works fine till I put a firewall on the PHP machine,
which blocks pretty much every port there is except port 80. Now, PHP
can't connect to the mysql database anymore. If I disable the firewall
on the PHP machine it works again. So I eliminate the reasons down to
that PHP must uses some port for mysql return the query. The question is
which port does PHP use for the connection? I'm NOT talking about 3306
which is used by Mysql. Anyone could help? Thanks in advance.

Louis


--
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


  1   2   >