Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with counter on shopping cart

Status
Not open for further replies.

mancroft

Programmer
Oct 26, 2002
267
GB
Hello
I am making a shopping cart and need a simple counter to add as an order number.

The cart table in phpmyadmin looks like:

zzzzzzzzzzzzzzzzzzz
Database my_cart - table simplecount running on localhost
SQL-query

SQL-query : [Edit]
SELECT * FROM `simplecount` LIMIT 0, 30

count count_id
24 1
zzzzzzzzzzzzzzzzz

so I know the counter is working.

However the code on the emailform where the counter information is transmitted looks like this:

zzzzzzzzzzzzzzzzzz

mysql_query("UPDATE simplecount SET count = (count + 1) WHERE count_id = 1",$con);

$thecounter = mysql_query( "SELECT count FROM simplecount WHERE count_id = 1;",$con);

zzzzzzzzzzzzzzzzzzzzzzzzzz

and produces the output:

ORDER NUMBER: Resource id #3

instead of

ORDER NUMBER: 24

which I would expect.

Any ideas please?

 
Number one, "count" is a MySQL reserved word. Use of reserved words as column names is a very bad idea.

Second, if you need a sequence of numbers for a column, I strongly recommend you use an auto_increment column.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top