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
https://forums.phpfreaks.com/topic/2958-cannot-perform-entry/
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
https://forums.phpfreaks.com/topic/2958-cannot-perform-entry/#findComment-9948
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.