Re: [PHP-DB] Question about databases and foreign keys
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` > '' AND `c`.`clock_out` < ''); 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 databases and foreign keys
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` > '' AND > `c`.`clock_out` < ''); > > 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
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
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` > '' AND `c`.`clock_out` < ''); 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
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] -- 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
Use 2 tables. You never know what the app might grow into and you should do it right the first time. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jason Pruim wrote: > Hi everyone, > > I just wanted to make sure that I am not making something more > complicated then it has to be. > > I am working on a time clock application to use at my company, and so > far, I have a login table, and with a foreign key that links to the > time table. The thinking being, that when someone logs in, they get > assigned there employee number, and then it adds a new record for that > employee ID. > > All I will be doing with the info, is grabbing the total amount of > time they were clocked in for each day, and then totaling for the week. > > I'm planning on using timestamps to store the actual time, hopefully > making the math part easier :) > > Do I need the foreign key and the 2 tables? Or should I just add the > column's into the database since it will be for a small company? > > Ideas? Suggestions? > > Thanks! > > > -- > > Jason Pruim > Raoset Inc. > Technology Manager > MQC Specialist > 11287 James St > 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 access rights in php/mysql
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") { } 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 about access rights in php/mysql
> > 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") { } 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 on PHP connect MS SQL 2005
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 on PHP connect MS SQL 2005
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
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
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 about database design
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 about database design
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
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
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
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
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 in js about frameset rows
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: title1 rows="10%,30%,10%,*"> scrolling="no" /> scrolling="no" /> And this is the content of the page page1.phtml: name1 change size of frame 2 How can I change (using js) the rows of the frameset to: 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
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: title1 rows="10%,30%,10%,*"> /> /> And this is the content of the page page1.phtml: name1 change size of frame 2 How can I change (using js) the rows of the frameset to: 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
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 "" then dynamically change it using "innerHTML" hth On 6/21/06, suad <[EMAIL PROTECTED]> wrote: Hi, I have this page: title1 And this is the content of the page page1.phtml: name1 change size of frame 2 How can I change (using js) the rows of the frameset to: 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 about Classes
Andrew Darby wrote: Hello, all. I have a sort of theoretical/sort of dumb question about PHP classes, which I haven't really worked with and don't entirely understand the purpose of, so here goes: Say i want to handle the add or update or delete of an item to a MySQL db, and instead of having three functions (function addItem, function updateItem, function deleteItem), it seems I could: a) have one function (modifyItem) with some sort of attribute saying which type it is, and then if/else through to the appropriate type of operation based on this flag, i.e., modifyItem($array_of_data, 'update') chooses the update switch b) have a modifyItem class, with the three possible functions inside c) stick with my three original functions Using any of these methods, how would you construct a query to actually run? Do you need to pass in the fieldnames and the data? eg: $data = array('newstitle' => $title, 'newscontent' => $data); How about which table to place this data in? It would get complicated I think.. I construct my queries elsewhere then hand it to my db class for processing. It has some basic functions: - Query (runs pg_query/mysql_query) - Fetch (runs pg_fetch_assoc/mysql_fetch_assoc) - Quote (runs pg_escape_string/mysql_escape_string) and so on. Is b) the sort of thing you might use a class for, or do I misunderstand? If not, what would be some "classic" uses of classes in our php/mysql world? OOP is good for API's. http://www.designmagick.com/article/18/PHP/Introduction-to-Object-Oriented-Programming -- 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 regarding the scope of pg_prepare
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()
** 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. <<<>>>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 ** 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. <<<>>>AdmID: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. <<<>>> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question on CURDATE()
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 "WHERE"s. 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()
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 "WHERE"s. 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()
Micah, Oh, my bad. I was trying to remember how I did something like this before, stringing together a lot of "WHERE"s. 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()
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()
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()
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()
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()
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 about COUNT(*)
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 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. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question about COUNT(*)
[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? 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 about COUNT(*)
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: 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 regarding how-to stop the form inputting empty data at end of the form that is empty due to a carriage return
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 of the form that is empty due to a carriage return
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 //--> 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 .= 'You forgot to enter a Media ID!'; } // Set the page title and include the HTML header. $page_title = 'submit!'; ?> Enter the Tape information into the form below: Retention: 4 Weeks 7 Weeks 1 Year 2 Years Out Date: " /> Return Date: doRCCalendar() Box ID: Media ID: $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 "You have not entered all information for each box."; } ?> 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 regarding how-to stop the form inputting empty data at end
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: 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 //--> 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 .= 'You forgot to enter a Media ID!'; } // Set the page title and include the HTML header. $page_title = 'submit!'; ?> Enter the Tape information into the form below: Retention: 4 Weeks 7 Weeks 1 Year 2 Years Out Date: " /> Return Date: doRCCalendar() Box ID: Media ID: $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 "You have not entered all information for each box."; } ?> -- 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
В сообщении от Среда 12 Январь 2005 04:52 Mike Millner написал(a): > 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') > > > How can I get PHP to ignore that line that has empty data in the media_id > field? Hi. May be check $MediaID_ar[$i], and if it empty just not write media_id? f.e. $query = "INSERT INTO tape_tracking_test ("; if ( ! empty( $MediaID_ar[$i] ) ){ $query .= "media_id, "; } $query.= "retention,out_date,return_date,box_id) values ("; if ( ! empty( $MediaID_ar[$i] ) ){ $query .= "'".$MediaID_ar[$i]."',"; } $query.= '". $_POST['Retention'] ."=%s','". $_POST['OutDate'] ."','". $_POST['calendarDate'] ."','". $_POST['BoxID'] ."')"; mysql_query( $query ); bla bla bla -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Question: For no results
--- "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) { >?> > No Matches > Found > 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: For no results
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) { > > 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) { ?> No Matches Found http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Question: For no results
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) { ?> > > 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
--- "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) { 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
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
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
--- 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. I'm not sure how to use the endif. Sutart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Question: For no results
> 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
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
You might want to use: mysql_num_rows -- 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) ?> //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 on the use of where statements
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 the use of where statements
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
--- 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
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
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
Does your tag have enctype="multipart/form-data" ? e.g. - 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, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]);
RE: [PHP-DB] Question: Copy and paste text into mysql text column
> 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
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
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
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; $i > This is how I am trying to get them into the database: > > $queries = array(); > for($i=0; $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
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; $i 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
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 "next page"; echo "".session_id(); } page 2: session_start(); if (isset($_SESSION["test"])) { echo $_SESSION["test"]; }else { echo "No sessionvariable found.."; } echo "".session_id().""; 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
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
> > > 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: "; // Add other form elements // ** OR ** echo "]\">"; // 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: Putting separate form elements into an array
See interspersed: --- Graham Cossey <[EMAIL PROTECTED]> wrote: > 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. > 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 ? > 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]? > 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 ! > Graham > > -- 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
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.) This would pass the form values as arrays which you can then iterate through in your script. $skills = $_POST['skill']; $skys = $_POST['sky']; $slus = $_POST['slu']; foreach($skills as $idx => $skill) { if ($skys[$idx]) { // Validate this sky element } if ($slus[$idx]) { // Validate this slu element } } You can just as easily store the arrays in your $_SESSION if the processing is to be done later. Note: Some form element types only pass a value if ticked/checked/selected. 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...) HTH Graham > -Original Message- > From: Stuart Felenstein [mailto:[EMAIL PROTECTED] > Sent: 16 October 2004 22:48 > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Question: Putting seperate form elements into an array > > > Right now this seems something like solving a rubic's > cube. While I process, I hope it's alright that i'm > asking here. I think my quantity of posts have been > high :) > > I have these form elements:(these are the names of the > elements) > > skill1sky1 slu1 > skill2sky2 slu2 > skill3sky3 slu3 > . ... > > They are being passed as sessions variables: > > $_SESSION['f411a'] = $_POST['skill1']; > $_SESSION['f411b'] = $_POST['sky1']; > $_SESSION['f411c'] = $_POST['slu1']; > $_SESSION['f412a'] = $_POST['skill2']; > $_SESSION['f412b'] = $_POST['sky2']; > $_SESSION['f412c'] = $_POST['slu2']; > $_SESSION['f413a'] = $_POST['skill3']; > $_SESSION['f413b'] = $_POST['sky3']; > $_SESSION['f413c'] = $_POST['slu3']; > > Perhaps instead of listing them out I should find a > way here to get them into an array. > Also, none of these are required fields, but if the > user put something in for Skill1 , then they should > input for sky1 and slu1. > > Now I need to sort them out for processing into the > database. I don't think it's wise to check each one. > When they go into the database, each "skill, sky , > slu" > is a new record. > > +-+--+-++ > | Record | Skill | Years | Used | > +-+--+-++ > | 1001| Skill1 | sky1 | slu1 | > +---+ > | 1002| Skill2 | sky2 | slu2 | > +---+ > > Someone partially wrote something out for me. But I > can't quite understand it. > > for($i=0; $i<5; $i++){ > echo ('-'[EMAIL PROTECTED]'f41'.($i+1).'a']); > if (!empty($HTTP_SESSION_VARS['f41'.($i+1).'a'])){ > $_SESSION('skil', $_SESSION['f41'.($i+1).'a']); > $_SESSION('yrs', $_SESSION['f41'.($i+1).'b']); > $_SESSION('used', $_SESSION['f41'.($i+1).'c']); > > > I see the increment , though I'm not sure why there is > an echo at the start. f41 comes from nowhere and it > looks like each field has 2 variables. > > Anyway I am seriously trying the figure this out, > apologies for sending it to the list. > > 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
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
$_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 on Registration Method
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
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
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
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
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
> 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
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
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 PROTECT
Re: [PHP-DB] Question on Registration Method
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
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
Re: [PHP-DB] Question on Registration Method
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
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
Re: [PHP-DB] Question on Registration Method
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
Re: [PHP-DB] Question on Registration Method
currently i do it the same way M Saleh EG does it ;) i have found that is the easiest way and works perfect. > On Sun, 26 Sep 2004 16:34:16 +0400, 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 > -- 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
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
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
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 about undices for inversed LIKE statesments.
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: [PHP-DB] question on
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 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 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 . I need to know how to capture what user selected and how to pass that around? I have used "onchange" attribute of the 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 Steps 1-4 </tt><br> <br> <tt><!--</tt><br> <br> <tt>function changeMenu()</tt><br> <br> <tt> {</tt><br> <br> <tt> document.fcountry.newcountry.value =<br> document.fcountry.country.options[document.fcountry.country.selectedInd ex].v<br> alue;</tt><br> <br> <tt>}</tt><br> <br> <tt>--></tt><br> <br> <tt> Countrty_buil.php has the following require_once("util.php"); echo ""; // // initialize or capture the country variable $country = !isset($_REQUEST['country'])? "Select a country": $_REQUEST['country']; $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; echo "$country"; $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 ) { echo"No data found"; }else{ // build the select list while($row = mysql_fetch_object($queryResultHandle)) { // grab a row echo "country\">$row->country"; } echo ""; } }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: RE: [PHP-DB] question on
Thanks everyone for all your help. I found some code that is using Java script and although it's not fully functional yet I am working on it. If anyone is interested here it is: .: Combobox :. <!-- select { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; font-style: normal; font-weight: bold; color: #00; background-color: #FF; height: 16px; width: 300px; border: 1px solid #00; } #left { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; font-style: normal; font-weight: bold; color: #00; background-color: #FF; text-align: right; vertical-align: middle; height: 16px; width: 150px; } #right { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 7pt; font-style: normal; font-weight: bold; color: #00; background-color: #FF; text-align: right; vertical-align: middle; height: 16px; width: 300px; } --> function getStates(what) { if (what.selectedIndex != '') { var country = what.value; document.location=('combobox.php?cSel=' + country); } } function getDistrict(what) { if (what.selectedIndex != '') { var country = document.myForm.cSelect.selectedIndex; var state = what.value; document.location=('combobox.php?cSel=' + country + '&sSel=' + state); } } function getCity(what) { if (what.selectedIndex != '') { var state = document.myForm.sSelect.selectedIndex; var district = what.value; document.location=('combobox.php?cSel=' + country + '&sSel=' + state + '&dSel=' + district); } } Select your Country: please, select your country $cNa"; } else { echo "$cNa"; } } ?> Select your State or Province: please, select your state or province $sNa, $sCu"; } else { echo "$sNa, $sCu"; } } } } ?> Select your District: please, select your district $dNa"; } } ?> Select your City: please, select your city $ctNa"; } } ?> -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 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 > > > 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
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): <!-- function changeMenu(pulldown,input) { input.value = pulldown.options[pulldown.selectedIndex].value; } --> Steps 1-4 "; // // initialize or capture the country variable $country = !isset($_REQUEST['country'])? "Select a country": $_REQUEST['country']; $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; $sretval .= "$country"; $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 .="No data found"; }else{ // build the select list while($row = mysql_fetch_object($queryResultHandle)) { // grab a row $sretval .="country\">$row->country"; } $sretval .= ""; 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 > 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 on
> 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
RE: [PHP-DB] question on
Here is the complete code. In the one line Java script that I have I am setting the value. So what am I missing? Quicksearch.php file has the following code Steps 1-4 <!-- function changeMenu() { document.fcountry.newcountry.value = document.fcountry.country.options[document.fcountry.country.selectedIndex].v alue; } --> Countrty_buil.php has the following "; // // initialize or capture the country variable $country = !isset($_REQUEST['country'])? "Select a country": $_REQUEST['country']; $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; echo "$country"; $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 ) { echo"No data found"; }else{ // build the select list while($row = mysql_fetch_object($queryResultHandle)) { // grab a row echo "country\">$row->country"; } echo ""; } }else{ // select echo mysql_error(); } }else{ //pconnect echo mysql_error(); } ?> -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 12, 2004 12:14 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] question on > 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 : > > > > > Well, there is no value assgined to $_POST['newcountry'] in your example. How are you getting a value to that form field? dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] question on
> 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 : > > > > > 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
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 : (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 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 > > > 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 > > 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 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 > > . I need to know how to capture what user selected > and how to > > pass > > that around? I have used "onchange" attribute of the 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 > > > > > > > > > > > > > > > > Steps 1-4 > > >
RE: [PHP-DB] question on
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 > > > 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 > > 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 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 > > . I need to know how to capture what user selected > and how to > > pass > > that around? I have used "onchange" attribute of the 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 > > > > > > > > > > > > > > > > Steps 1-4 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > <!-- > > > > function changeMenu() > > > > { > > > > document.fcountry.newcountry.value = > > > document.fcountry.country.options[document.fcountry.country.se > lectedInd >
RE: [PHP-DB] question on
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 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 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 > . I need to know how to capture what user selected and how to > pass > that around? I have used "onchange" attribute of the 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 > > > > > > > > Steps 1-4 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > <!-- > > function changeMenu() > > { > > document.fcountry.newcountry.value = > document.fcountry.country.options[document.fcountry.country.selectedInd > ex].v > alue; > > } > > --> > > > > > > Countrty_buil.php has the following > > > > > require_once("util.php"); > > > > echo " onchange=\"changeMenu()\">"; > > // > > // initialize or capture the country variable > > $country = !isset($_REQUEST['country'])? "Select a country": > $_REQUEST['country']; > > $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; > > echo "$country"; > > $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 ) { > > echo"No data > found"; > > }else{ > > // build the select list > > while($row = mysql_fetch_object($queryResultHandle)) > { // > grab a row > > echo " value=\"$row->country\">$row->country"; > > } > > echo ""; > > > > } > > }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
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 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 . I need to know how to capture what user selected and how to pass that around? I have used "onchange" attribute of the 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 Steps 1-4
Countrty_buil.php has the following require_once("util.php"); echo ""; // // initialize or capture the country variable $country = !isset($_REQUEST['country'])? "Select a country": $_REQUEST['country']; $countrySQL = !isset($_REQUEST['country'])? "*": $_REQUEST['country']; echo "$country"; $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 ) { echo"No data found"; }else{ // build the select list while($row = mysql_fetch_object($queryResultHandle)) { // grab a row echo "country\">$row->country"; } echo ""; } }else{ // select echo mysql_error(); } }else{ //pconnect echo mysql_error(); } ?>
Re: [PHP-DB] Question
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. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question
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 ""; echo ""; echo ""; } 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
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 - Asif -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question
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
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 > > // 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