I'm trying to develop a website with PHP and MySQL. Here is my PHP code I tried:
$sql = sprintf("INSERT INTO request_boms SET
request_list_id = %d,
project_version_id = %d,
amount = %d,
user = '%s',
timestamp = %d",
$requestNo, $bomID, $amount, $_SESSION["admin_user_name"], time());
$this->db_inventory->Execute($sql);
My $this->db_inventory
variable is connected with an DB API. There is no issue with it. But when I execute the code up here returns me this:
Subquery returns more than 1 row
INSERT INTO request_boms SET request_list_id = 14, project_version_id = 429, amount = 1, user = 'admin', timestamp = 1607510083
I searched this issue on here (stackoverflow) but in all issues have SELECT
statement in their queries. I didn't give any SELECT
statement in my INSERT INTO
query. How could it be possible?
Edit (Due to comments)
Here is my Execute()
public function Execute($sql) {
$rs = new RecordSet($sql, $this->db_type, $this->conn);
return $rs;
}
And RecordSet
class RecordSet {
public $rs;
public $db_type;
public $conn;
public function RecordSet($sql, $db_type, $conn) {
$this->db_type = $db_type;
$this->conn = $conn;
if ($this->db_type == 'sybase') {
$rsx =@sybase_query($this->sql_escape($sql));
if (!$rsx) {
$this->queryError(sybase_get_last_message(),$sql);
}
} elseif ($this->db_type == 'mssql') {
$rsx =@mssql_query($this->sql_escape($sql));
if (!$rsx) {
$this->queryError(mssql_get_last_message(),$sql);
}
} elseif ($this->db_type == 'odbc') {
$rsx =@odbc_exec($this->conn, $this->sql_escape($sql));
if (!$rsx) {
$this->queryError(odbc_errormsg(),$sql);
}
} else {
$rsx = mysqli_query($this->conn, $this->sql_escape($sql));
if (!$rsx) {
$this->queryError(@mysqli_error($this->conn),$sql);
}
}
$this->rs = $rsx;
}
}
In my database I also have a table called request_components
. And it had 2 primary key: id
and request_list_id
. After deleting request_list_id
key from table, the problem solved. It seems to creating conflict between tables. If you had this problem, you should check your database.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.