Jump to content

Cannot perform entry


renesis

Recommended Posts

Hi all. I'm new to this forum and hope to find the solution to my problem.

What my problem is...

I have created a web site in php-mysql-apache.

It deals with online product orders. Assume there are 2 tables, "products" and "orders".

Assume that a customer selects some products and pressing "checkout" button the list of the selected products appears. I need to capture the product details and insert them to the "orders" table but it fails.

 

I use the following code:

 

<?php

mysql_connect("$host","$user","$pass");

mysql_select_db("$database");

mysql_query("insert into orders values (now(), '', '', '', item_code='$code_no', '', '', '', '')")

or die(mysql_error());

 

?>

 

I explain:

 

now() is the date today.

item_code is the column in "orders" table and "code_no" is the column in "products" table. I use "" because at the moment I'm not interested in these columns.

What I get from this code in the "orders" table is the correct date in the "order_date" column and a "1" in the "item_code" column.

How did this "1" come from?

Any obvious mistakes? Any proposal?

Many thanks in advance.

Link to comment
Share on other sites

[!--quoteo(post=323245:date=Nov 30 2005, 01:43 PM:name=renesis)--][div class=\'quotetop\']QUOTE(renesis @ Nov 30 2005, 01:43 PM) 323245[/snapback][/div][div class=\'quotemain\'][!--quotec--]

I use the following code:

 

<?php

mysql_connect("$host","$user","$pass");

mysql_select_db("$database");

mysql_query("insert into orders values (now(), '', '', '', item_code='$code_no', '', '', '', '')")

or die(mysql_error());

 

?>

 

Any obvious mistakes? Any proposal?

try this

mysql_query("insert into orders values (now(), '', '', '', $code_no, '', '', '', '')")

or

mysql_query("insert into orders values (now(), '', '', ''," . $code_no . ", '', '', '', '')")

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.