Here is the error I am getting:

Unknown column 'Lo' in 'field list'

Here is my code. Any suggestions to get rid of this error:

global $conn,$dal;
$customerID = mysql_insert_id();

$strSQLInsert = "insert into Orders (CustomerID, LastName) values (".$customerID.", ".$values["LastName"].")";
db_exec($strSQLInsert,$conn);

$rs = $dal->Orders->Query("CustomerID=".$customerID." and LastName=".$values["LastName"],"");
$data = db_fetch_array($rs);

$idvalue = $data["ID"];
header("Location: Orders_edit.php?editid1=".$idvalue);
exit();

Recommended Answers

All 7 Replies

put single qoute for LastName as it is varchar.

global $conn,$dal;
$customerID = mysql_insert_id();

$strSQLInsert = "insert into Orders (CustomerID, LastName) values (".$customerID.", '".$values["LastName"]."')";
db_exec($strSQLInsert,$conn);

$rs = $dal->Orders->Query("CustomerID=".$customerID." and LastName='".$values["LastName"],"'");
$data = db_fetch_array($rs);

$idvalue = $data["ID"];
header("Location: Orders_edit.php?editid1=".$idvalue);
exit();

Thank you for the help. I tried the code and received this error:


Fatal error: Call to a member function Query() on a non-object

Still need an assist.

after inserting order what you exactly want?
i means what is the need for below code:

$rs = $dal->Orders->Query("CustomerID=".$customerID." and LastName='".$values["LastName"],"'");

if you want just last inserted id then it can be directly taken by mysql_insert_id

BTW above line use Orders as a class.
check your connection class and how to use that class functions for fetch table records.

I want to be able to insert the two fields into the customer table, then have the customer have the next page which is orders, with the two fields in the orders page and table.

Here is what I am trying to do. I have two tables, customers and orders. When the fields CustomerID and LastName are entered into the customers table, I want the same variables put into the new form which will then be inserted into the orders table when the rest of the form is filled.

The issue seems to be escaping variables. you should use ' and " in sql stmt to clearly distinguish variables into sql query. There can be some chances the code is getting failed before reaching to this point. Good luck. Keep us updated, what works for you.

Member Avatar for rajarajan2017

Form as below clearly in your code

$query = "INSERT INTO symbols (country, animal) VALUES ('$country', '$animal')";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.