[PHP] Serial Numbers

2010-07-12 Thread Gary
I'm sure it is possible, but I am unsure how to do this.  I have created a 
Sale coupon that I was going to put up on a site that I manage, for visitors 
to print out and bring to the store. The coupon is currently a .png, however 
I was planning on converting to a pdf.  I would like to put on the coupon a 
serial number that increases by 1 everytime the page is viewed. I dont 
really care if someone refreshes the page and skews the numbers.

Is this possible and could someone give me some help?

Thanks

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5273 (20100712) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Serial Numbers

2010-07-12 Thread Shreyas Agasthya
Perhaps using a static variable might help? I am just guessing.

--Shreyas

On Tue, Jul 13, 2010 at 12:22 AM, Gary gp...@paulgdesigns.com wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created a
 Sale coupon that I was going to put up on a site that I manage, for
 visitors
 to print out and bring to the store. The coupon is currently a .png,
 however
 I was planning on converting to a pdf.  I would like to put on the coupon a
 serial number that increases by 1 everytime the page is viewed. I dont
 really care if someone refreshes the page and skews the numbers.

 Is this possible and could someone give me some help?

 Thanks

 Gary



 __ Information from ESET Smart Security, version of virus signature
 database 5273 (20100712) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





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




-- 
Regards,
Shreyas Agasthya


Re: [PHP] Serial Numbers

2010-07-12 Thread Ashley Sheridan
On Mon, 2010-07-12 at 14:52 -0400, Gary wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created a 
 Sale coupon that I was going to put up on a site that I manage, for visitors 
 to print out and bring to the store. The coupon is currently a .png, however 
 I was planning on converting to a pdf.  I would like to put on the coupon a 
 serial number that increases by 1 everytime the page is viewed. I dont 
 really care if someone refreshes the page and skews the numbers.
 
 Is this possible and could someone give me some help?
 
 Thanks
 
 Gary 
 
 
 
 __ Information from ESET Smart Security, version of virus signature 
 database 5273 (20100712) __
 
 The message was checked by ESET Smart Security.
 
 http://www.eset.com
 
 
 
 
 


You need some indicator on your server to keep track of the number. To
me, the ideal solution would appear to be a MySQL database. You can set
up a table with an auto_increment field and use the id generated from
that.

Two things to maybe note:


 1. Don't use MAX(id) in a query to get the next auto value, use
something like mysql_insert_id() instead. The MAX() method is
just a race condition waiting to happen.
 2. If you expect a lot of traffic, then consider setting this table
to use the InnoDB engine instead of MyIsam which is usually the
default. This allows MySQL to apply row-level locking instead of
table-level, which can improve performance when PHP has to wait
for MySQL.


Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Serial Numbers

2010-07-12 Thread Floyd Resler

On Jul 12, 2010, at 2:52 PM, Gary wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created a 
 Sale coupon that I was going to put up on a site that I manage, for visitors 
 to print out and bring to the store. The coupon is currently a .png, however 
 I was planning on converting to a pdf.  I would like to put on the coupon a 
 serial number that increases by 1 everytime the page is viewed. I dont 
 really care if someone refreshes the page and skews the numbers.
 
 Is this possible and could someone give me some help?
 
 Thanks
 
 Gary 
 

Is there any particular reason you need it to be a PDF?  If not and the GD 
library is installed in your PHP, I would suggest using the GD library to draw 
your serial number on the coupon.  As for keeping track of the counter I would 
do it either in a database table or save the number to file.

Take care,
Floyd


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



Re: [PHP] Serial Numbers

2010-07-12 Thread Ashley Sheridan
On Mon, 2010-07-12 at 15:17 -0400, Floyd Resler wrote:

 On Jul 12, 2010, at 2:52 PM, Gary wrote:
 
  I'm sure it is possible, but I am unsure how to do this.  I have created a 
  Sale coupon that I was going to put up on a site that I manage, for 
  visitors 
  to print out and bring to the store. The coupon is currently a .png, 
  however 
  I was planning on converting to a pdf.  I would like to put on the coupon a 
  serial number that increases by 1 everytime the page is viewed. I dont 
  really care if someone refreshes the page and skews the numbers.
  
  Is this possible and could someone give me some help?
  
  Thanks
  
  Gary 
  
 
 Is there any particular reason you need it to be a PDF?  If not and the GD 
 library is installed in your PHP, I would suggest using the GD library to 
 draw your serial number on the coupon.  As for keeping track of the counter I 
 would do it either in a database table or save the number to file.
 
 Take care,
 Floyd
 
 


I can think of a good reason for making it as a PDF. A PDF is built for
printing to scale exactly as you need, whereas a bitmap is very
different. Traditionally, GD creates screen images, which are 72dpi,
whereas print usually uses 300dpi bitmaps, and they generally don't
scale well.

Having said that, writing it in GD will be a fair bit easier!

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Serial Numbers

2010-07-12 Thread Floyd Resler

On Jul 12, 2010, at 3:22 PM, Ashley Sheridan wrote:

 On Mon, 2010-07-12 at 15:17 -0400, Floyd Resler wrote:
 
 On Jul 12, 2010, at 2:52 PM, Gary wrote:
 
  I'm sure it is possible, but I am unsure how to do this.  I have created a 
  Sale coupon that I was going to put up on a site that I manage, for 
  visitors 
  to print out and bring to the store. The coupon is currently a .png, 
  however 
  I was planning on converting to a pdf.  I would like to put on the coupon 
  a 
  serial number that increases by 1 everytime the page is viewed. I dont 
  really care if someone refreshes the page and skews the numbers.
  
  Is this possible and could someone give me some help?
  
  Thanks
  
  Gary 
  
 
 Is there any particular reason you need it to be a PDF?  If not and the GD 
 library is installed in your PHP, I would suggest using the GD library to 
 draw your serial number on the coupon.  As for keeping track of the counter 
 I would do it either in a database table or save the number to file.
 
 Take care,
 Floyd
 
 
 
 I can think of a good reason for making it as a PDF. A PDF is built for 
 printing to scale exactly as you need, whereas a bitmap is very different. 
 Traditionally, GD creates screen images, which are 72dpi, whereas print 
 usually uses 300dpi bitmaps, and they generally don't scale well.
 
 Having said that, writing it in GD will be a fair bit easier!
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 

Having said that, writing it in GD will be a fair bit easier!

Yep, that's why I was asking! :)

Take care,
Floyd



Re: [PHP] Serial Numbers

2010-07-12 Thread Gary

Floyd Resler fres...@adex-intl.com wrote in message 
news:e6321b00-590d-4294-9b81-81cc92883...@adex-intl.com...

On Jul 12, 2010, at 2:52 PM, Gary wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created a
 Sale coupon that I was going to put up on a site that I manage, for 
 visitors
 to print out and bring to the store. The coupon is currently a .png, 
 however
 I was planning on converting to a pdf.  I would like to put on the coupon 
 a
 serial number that increases by 1 everytime the page is viewed. I dont
 really care if someone refreshes the page and skews the numbers.

 Is this possible and could someone give me some help?

 Thanks

 Gary


Is there any particular reason you need it to be a PDF?  If not and the GD 
library is installed in your PHP, I would suggest using the GD library to 
draw your serial number on the coupon.  As for keeping track of the counter 
I would do it either in a database table or save the number to file.

Take care,
Floyd


Floyd

Thanks for your reponse.

No real reason that the file has to be a pdf, that was my original plan 
before I came up with the counter idea..  I also thought it might not be as 
difficult to put the script on a pdf.

I have used the GD library in the past, so it is installed on the server, 
however I dont know how to apply to this situation..

After I posted the question, the thought came to me to simply create the 
coupon in html and include a simple counter, like a hit counter, but since I 
had the png already created, I was hoping there was a way to include the 
script on it instead of recreating in html/php.

Gary




__ Information from ESET Smart Security, version of virus signature 
database 5273 (20100712) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Serial Numbers

2010-07-12 Thread Gary




Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1278962039.2202.5.ca...@localhost...
 On Mon, 2010-07-12 at 14:52 -0400, Gary wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created 
 a
 Sale coupon that I was going to put up on a site that I manage, for 
 visitors
 to print out and bring to the store. The coupon is currently a .png, 
 however
 I was planning on converting to a pdf.  I would like to put on the coupon 
 a
 serial number that increases by 1 everytime the page is viewed. I dont
 really care if someone refreshes the page and skews the numbers.

 Is this possible and could someone give me some help?

 Thanks

 Gary



 __ Information from ESET Smart Security, version of virus 
 signature database 5273 (20100712) __

 The message was checked by ESET Smart Security.

 http://www.eset.com







 You need some indicator on your server to keep track of the number. To
 me, the ideal solution would appear to be a MySQL database. You can set
 up a table with an auto_increment field and use the id generated from
 that.

 Two things to maybe note:


 1. Don't use MAX(id) in a query to get the next auto value, use
something like mysql_insert_id() instead. The MAX() method is
just a race condition waiting to happen.
 2. If you expect a lot of traffic, then consider setting this table
to use the InnoDB engine instead of MyIsam which is usually the
default. This allows MySQL to apply row-level locking instead of
table-level, which can improve performance when PHP has to wait
for MySQL.


 Thanks,
 Ash
 http://www.ashleysheridan.co.uk


Ashley

Thanks for your reply.

I was not going to go to the trouble of calling the AI number from a 
database, although that is an interesting concept.

The question really becomes How to insert into an image I could just write 
a simple hit counter and create a new php/html page, but since the image 
(coupon) was already created, I thought it would be easier, not to mention 
expand my abilities.

It is a small shop and if they get 100 coupons, they will be extatic, so it 
will not kill us if it were too much trouble.

I have gone to using  InnoDB as my standard table, mainly for the foreign 
key ability, but I do keep reading that there are more and more advantage to 
using is over Myisam.

Thanks again for your reply.

Gary
 



__ Information from ESET Smart Security, version of virus signature 
database 5273 (20100712) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



RE: [PHP] Serial Numbers

2010-07-12 Thread Daevid Vincent
 -Original Message-
 From: Gary [mailto:gp...@paulgdesigns.com] 
 Sent: Monday, July 12, 2010 11:53 AM
 
 I'm sure it is possible, but I am unsure how to do this.  I 
 have created a 
 Sale coupon that I was going to put up on a site that I 
 manage, for visitors 
 to print out and bring to the store. The coupon is currently 
 a .png, however 
 I was planning on converting to a pdf.  I would like to put 
 on the coupon a 
 serial number that increases by 1 everytime the page is 
 viewed. I dont 
 really care if someone refreshes the page and skews the numbers.
 
 Is this possible and could someone give me some help?

Is there a reason you need to increment by 1? I mean, are you going to
validate the coupon someone brings in to see if it's in the database or is
used already? Since you say you don't care if the number is skewed, it
sounds as if you don't care about the code either really.

Point being, why not just use md5(time()) or uniqid() or something and make
some truly unique code (that you may or may not wish to store in a DB).
This will be obscure enough the average person won't know that it isn't
tracked and most likely won't try to make their own. If I saw 123457, I'm
pretty sure I could make a coupon with 123500 on it. But if I saw
6ccd780c-baba-1026-9564-0040f4311e29 then I'm not really going to try and
fudge one of those. Then I'd use the barcode library to print the code
(again, doesn't have to actually work if you're not going to do a lookup)
just to add more realizm to it. There are a billion different ways to
make a unique ID. Even IF you are going to track them, you really shouldn't
do a sequential code as you originally wanted to do.

http://us.php.net/manual/en/function.uniqid.php
http://php.net/manual/en/function.com-create-guid.php
http://us.php.net/manual/en/function.mssql-guid-string.php
http://us.php.net/manual/en/function.md5.php
http://us.php.net/manual/en/function.sha1.php
http://us.php.net/manual/en/function.hash.php
http://us.php.net/manual/en/function.time.php
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#functio
n_uuid

Heck, you could even just use ip2long() on their IP address and then when
someone redeems the coupon code, a simple long2ip() would tell you if
it's a valid IP format rather than some hacked up string.
http://us.php.net/manual/en/function.ip2long.php
http://us.php.net/manual/en/function.long2ip.php

Daevid.
http://daevid.com

Some people, when confronted with a problem, think 'I know, I'll use
XML.'
Now they have two problems. 


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



Re: [PHP] Serial Numbers

2010-07-12 Thread Gary

Daevid Vincent dae...@daevid.com wrote in message 
news:a380a1570d4c4351b38e1cce2aabe...@mascorp.com...
 -Original Message-
 From: Gary [mailto:gp...@paulgdesigns.com]
 Sent: Monday, July 12, 2010 11:53 AM

 I'm sure it is possible, but I am unsure how to do this.  I
 have created a
 Sale coupon that I was going to put up on a site that I
 manage, for visitors
 to print out and bring to the store. The coupon is currently
 a .png, however
 I was planning on converting to a pdf.  I would like to put
 on the coupon a
 serial number that increases by 1 everytime the page is
 viewed. I dont
 really care if someone refreshes the page and skews the numbers.

 Is this possible and could someone give me some help?

 Is there a reason you need to increment by 1? I mean, are you going to
 validate the coupon someone brings in to see if it's in the database or is
 used already? Since you say you don't care if the number is skewed, it
 sounds as if you don't care about the code either really.

 Point being, why not just use md5(time()) or uniqid() or something and 
 make
 some truly unique code (that you may or may not wish to store in a DB).
 This will be obscure enough the average person won't know that it isn't
 tracked and most likely won't try to make their own. If I saw 123457, I'm
 pretty sure I could make a coupon with 123500 on it. But if I saw
 6ccd780c-baba-1026-9564-0040f4311e29 then I'm not really going to try and
 fudge one of those. Then I'd use the barcode library to print the code
 (again, doesn't have to actually work if you're not going to do a lookup)
 just to add more realizm to it. There are a billion different ways to
 make a unique ID. Even IF you are going to track them, you really 
 shouldn't
 do a sequential code as you originally wanted to do.

 http://us.php.net/manual/en/function.uniqid.php
 http://php.net/manual/en/function.com-create-guid.php
 http://us.php.net/manual/en/function.mssql-guid-string.php
 http://us.php.net/manual/en/function.md5.php
 http://us.php.net/manual/en/function.sha1.php
 http://us.php.net/manual/en/function.hash.php
 http://us.php.net/manual/en/function.time.php
 http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#functio
 n_uuid

 Heck, you could even just use ip2long() on their IP address and then when
 someone redeems the coupon code, a simple long2ip() would tell you if
 it's a valid IP format rather than some hacked up string.
 http://us.php.net/manual/en/function.ip2long.php
 http://us.php.net/manual/en/function.long2ip.php

 Daevid.
 http://daevid.com

 Some people, when confronted with a problem, think 'I know, I'll use
 XML.'
 Now they have two problems.

Daevid

Thanks for your reply.

The numbers are not for show, we are not trying to make it seem like we have 
thousands of coupons.  We are going to use the numbers to guage how many 
times people see the coupon and to see how many it takes before we have 
someone show up to use it, but dont really care if someone gets a kick out 
of hitting the refresh button 10 or 20 times to watch the number go up.

I was going to start the number at 72010001 (July 2010, 001) and if someone 
figured out what it was, we dont really care. As I mentioned, it is a small 
shop (one man show) that the site gets and average of 350 visits per month 
(which he is very happy with over what he had).

Although I do like the idea of using there ip address...

Thanks for your reply and all the links.

Gary




__ Information from ESET Smart Security, version of virus signature 
database 5273 (20100712) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Serial Numbers

2010-07-12 Thread Paul M Foster
On Mon, Jul 12, 2010 at 02:52:39PM -0400, Gary wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created a
 Sale coupon that I was going to put up on a site that I manage, for visitors
 to print out and bring to the store. The coupon is currently a .png, however
 I was planning on converting to a pdf.  I would like to put on the coupon a
 serial number that increases by 1 everytime the page is viewed. I dont
 really care if someone refreshes the page and skews the numbers.
 
 Is this possible and could someone give me some help?

Doing this in a PDF is pretty easy. Check out the FPDF library. It's
pretty lightweight. I print invoices to PDF all the time, so I have to
insert numbers into PDFs created by FPDF. Check the documentation.

Paul

-- 
Paul M. Foster

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