RE: [PHP-DB] address info, forms, maintanance

2003-06-06 Thread chip . wiegand
John W. Holmes [EMAIL PROTECTED] wrote on 06/04/2003 05:24:22 
PM:

  Thanks to everyone for the suggestions. Got it fixed. Just added a
 couple
  lines of code -
  $sql1 = select * from endusers where name like '$name';
 $result1 = mysql_query($sql1);
   $count1 = mysql_num_rows($result1);
   if ($count1 == 0 )
 $sql = insert into endusers..blah blah blah
 
  Now it works fine, no more duplicate entries. 
 
 But now you're doing two queries for every insert. If you simply made
 your columns unique and let the database handle it, you'd only have to
 do one INSERT. Then check affected_rows() or mysql_error() to see if
 either no rows were affected (no rows inserted) or the error mentions
 duplicate. If either is the case, the row wasn't inserted because of a
 unique constraint. If there is an error but it's not duplicate or
 whatever, then it's another error and you should show it. 
 
 ---John W. Holmes...

Thanks for the tips, I'll work on that. In the meantime, this database is 
pretty
low useage, very specialized information for a small market segment, so 
for now
it will be okay. It'll never have hundreds or thousands of hits per day. 
But I 
will look into making the suggested changes.
Thanks,
Chip

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



[PHP-DB] address info, forms, maintanance

2003-06-05 Thread chip . wiegand
I need to modify some company web pages that include a form for asking the 
company departments questions, such as service dept, etc. As the forms are 
currently built there is some field validation but no cookies. This info 
is saved in a mysql database, problem is, there are duplicate entries, 
every time an  end-user posts a question. What kind of code do I need to 
add to these existing pages to prevent duplicate entries in the database? 
(Manually scanning through and deleting dupes is a real drag.) And what 
about cookies? Could I make use of these on these pages? I haven't worked 
with cookies yet, so am not sure where to start with that part.
Thanks,
--
Chip

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



Re: [PHP-DB] address info, forms, maintanance

2003-06-05 Thread Dan Brunner
Hello!!

Are talking about the same Post Question???

On another words, what is being duplicated??

If not, you can use auto_increment.

Dan





On Wednesday, June 4, 2003, at 03:13  PM, [EMAIL PROTECTED] wrote:

I need to modify some company web pages that include a form for asking 
the
company departments questions, such as service dept, etc. As the forms 
are
currently built there is some field validation but no cookies. This 
info
is saved in a mysql database, problem is, there are duplicate entries,
every time an  end-user posts a question. What kind of code do I need 
to
add to these existing pages to prevent duplicate entries in the 
database?
(Manually scanning through and deleting dupes is a real drag.) And what
about cookies? Could I make use of these on these pages? I haven't 
worked
with cookies yet, so am not sure where to start with that part.
Thanks,
--
Chip

--
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] address info, forms, maintanance

2003-06-05 Thread Miles Thompson
Chip,

Given that you have duplicate entries, then one field, or a combination of 
several fields, will probably be unique.

Before adding a record execute a SELECT, using the values from the form 
against that combination. If the number of records returned is greater than 
0, then execute an UPDATE query, otherwise an INSERT.

Now, that information is so vague to be almost useless, for it begs a 
number of other questions, such as
How many questions are end users allowed to ask?
How are questions flagged for expiration or completion/solution?
What kind of mix of questions do you allow?

Cookies only store a bit of information on the user's browser. There's 
nothing magic about them - google for netscape cookies. I don't think 
they'd be much help to you here.

HTH - Miles Thompson

At 01:13 PM 6/4/2003 -0700, [EMAIL PROTECTED] wrote:
I need to modify some company web pages that include a form for asking the
company departments questions, such as service dept, etc. As the forms are
currently built there is some field validation but no cookies. This info
is saved in a mysql database, problem is, there are duplicate entries,
every time an  end-user posts a question. What kind of code do I need to
add to these existing pages to prevent duplicate entries in the database?
(Manually scanning through and deleting dupes is a real drag.) And what
about cookies? Could I make use of these on these pages? I haven't worked
with cookies yet, so am not sure where to start with that part.
Thanks,
--
Chip
--
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] address info, forms, maintanance

2003-06-05 Thread chip . wiegand
Dan Brunner [EMAIL PROTECTED] wrote on 06/04/2003 01:24:13 PM:

 Hello!!
 Are talking about the same Post Question???
 On another words, what is being duplicated??
 If not, you can use auto_increment.
 Dan

This pertains to every time a person visits the page and fills in the form 
- today, tommorrow, next week, next month, whenever. The address info is 
being written to the database each time they send the form. The message 
body itself isn't saved to the database, only the name and address info.
--
Chip

 On Wednesday, June 4, 2003, at 03:13  PM, [EMAIL PROTECTED] wrote:
 
  I need to modify some company web pages that include a form for asking 

  the
  company departments questions, such as service dept, etc. As the forms 

  are
  currently built there is some field validation but no cookies. This 
  info
  is saved in a mysql database, problem is, there are duplicate entries,
  every time an  end-user posts a question. What kind of code do I need 
  to
  add to these existing pages to prevent duplicate entries in the 
  database?
  (Manually scanning through and deleting dupes is a real drag.) And 
what
  about cookies? Could I make use of these on these pages? I haven't 
  worked
  with cookies yet, so am not sure where to start with that part.
  Thanks,
  --
  Chip
 
  -- 
  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] address info, forms, maintanance

2003-06-05 Thread CPT John W. Holmes
 I need to modify some company web pages that include a form for asking the
 company departments questions, such as service dept, etc. As the forms are
 currently built there is some field validation but no cookies. This info
 is saved in a mysql database, problem is, there are duplicate entries,
 every time an  end-user posts a question.

Do you mean that when I hit submit there are duplicate entries submitted
or that it may match what someone else has submitted and become duplicate?

If it's the second case, wouldn't that be optimal? You'd know that X people
had the same issue/question and you can reply to each one when it's
resolved...

 What kind of code do I need to
 add to these existing pages to prevent duplicate entries in the database?

Makeing the column unique is the easiest way. If you get a duplicate error
from mysql_error(), then just ignore it because the problem is apparently
accounted for.

 (Manually scanning through and deleting dupes is a real drag.)

No one does anything manually... :) Easiest way to fix your data now would
be to make a new table with UNIQUE columns where you need them. Then do an
INSERT INTO ... SELECT to move the data from one table to the other.
Duplicates will be ignored by the new table. Proceed as normal... :)

 And what
 about cookies? Could I make use of these on these pages? I haven't worked
 with cookies yet, so am not sure where to start with that part.

Do you need to remember anything that the user enters in the form that's
specific to that user? That's all cookies are... a variable that you store
on the user's machine. If you don't already have a reason for them, you
probably don't need them.

---John Holmes...


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



Re: [PHP-DB] address info, forms, maintanance

2003-06-05 Thread Miles Thompson
Chip,

What's the database being used for then, if not to store and track 
questions and replies? If only as a repository of addresses that 's rather 
useless.

Unless you want to track the frequency of user's questions, then you could 
update a counter field for their email address.

If you've not gone down the road too far with this, there are some help 
desk type PHP solutions out there.

Miles

At 01:30 PM 6/4/2003 -0700, [EMAIL PROTECTED] wrote:
Dan Brunner [EMAIL PROTECTED] wrote on 06/04/2003 01:24:13 PM:

 Hello!!
 Are talking about the same Post Question???
 On another words, what is being duplicated??
 If not, you can use auto_increment.
 Dan
This pertains to every time a person visits the page and fills in the form
- today, tommorrow, next week, next month, whenever. The address info is
being written to the database each time they send the form. The message
body itself isn't saved to the database, only the name and address info.
--
Chip
 On Wednesday, June 4, 2003, at 03:13  PM, [EMAIL PROTECTED] wrote:

  I need to modify some company web pages that include a form for asking
  the
  company departments questions, such as service dept, etc. As the forms
  are
  currently built there is some field validation but no cookies. This
  info
  is saved in a mysql database, problem is, there are duplicate entries,
  every time an  end-user posts a question. What kind of code do I need
  to
  add to these existing pages to prevent duplicate entries in the
  database?
  (Manually scanning through and deleting dupes is a real drag.) And
what
  about cookies? Could I make use of these on these pages? I haven't
  worked
  with cookies yet, so am not sure where to start with that part.
  Thanks,
  --
  Chip
 
  --
  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


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


Re: [PHP-DB] address info, forms, maintanance

2003-06-05 Thread chip . wiegand
Thanks to everyone for the suggestions. Got it fixed. Just added a couple 
lines of code - 
$sql1 = select * from endusers where name like '$name';
   $result1 = mysql_query($sql1); 
 $count1 = mysql_num_rows($result1);
 if ($count1 == 0 )
   $sql = insert into endusers..blah blah blah

Now it works fine, no more duplicate entries. Just for those who asked - 
this is a database of end-user names
and addresses for a mailing list. The questions posted are kept by the 
department that responded to them. 
No one here has ever asked or implied a need to have the messages saved to 
the database, what they do
with the message is their game, not mine. I'm just cleaning up their 
existing code a bit.
--
Chip 

Miles Thompson [EMAIL PROTECTED] wrote on 06/04/2003 
08:31:14 AM:

 Chip,
 
 Given that you have duplicate entries, then one field, or a combination 
of 
 several fields, will probably be unique.
 
 Before adding a record execute a SELECT, using the values from the form 
 against that combination. If the number of records returned is greater 
than 
 0, then execute an UPDATE query, otherwise an INSERT.
 
 Now, that information is so vague to be almost useless, for it begs a 
 number of other questions, such as
 How many questions are end users allowed to ask?
 How are questions flagged for expiration or completion/solution?
 What kind of mix of questions do you allow?
 
 Cookies only store a bit of information on the user's browser. There's 
 nothing magic about them - google for netscape cookies. I don't think 
 they'd be much help to you here.
 
 HTH - Miles Thompson
 
 At 01:13 PM 6/4/2003 -0700, [EMAIL PROTECTED] wrote:
 I need to modify some company web pages that include a form for asking 
the
 company departments questions, such as service dept, etc. As the forms 
are
 currently built there is some field validation but no cookies. This 
info
 is saved in a mysql database, problem is, there are duplicate entries,
 every time an  end-user posts a question. What kind of code do I need 
to
 add to these existing pages to prevent duplicate entries in the 
database?
 (Manually scanning through and deleting dupes is a real drag.) And what
 about cookies? Could I make use of these on these pages? I haven't 
worked
 with cookies yet, so am not sure where to start with that part.
 Thanks,
 --
 Chip
 
 --
 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] address info, forms, maintanance

2003-06-05 Thread John W. Holmes
 Thanks to everyone for the suggestions. Got it fixed. Just added a
couple
 lines of code -
 $sql1 = select * from endusers where name like '$name';
$result1 = mysql_query($sql1);
  $count1 = mysql_num_rows($result1);
  if ($count1 == 0 )
$sql = insert into endusers..blah blah blah
 
 Now it works fine, no more duplicate entries. 

But now you're doing two queries for every insert. If you simply made
your columns unique and let the database handle it, you'd only have to
do one INSERT. Then check affected_rows() or mysql_error() to see if
either no rows were affected (no rows inserted) or the error mentions
duplicate. If either is the case, the row wasn't inserted because of a
unique constraint. If there is an error but it's not duplicate or
whatever, then it's another error and you should show it. 

---John W. Holmes...

Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/




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