Ben aşağıdaki kodu vardır:
public function createNewGuide($userID,$guideName)
{
$sql =" INSERT INTO myTable(name, updated)
VALUES ('$guideName', 'NOW()')";
//Process query
$this->query($sql); // This inserts the new row
$this->query('LAST_INSERT_ID()'); // This throws an error
return $this->query_result;
}
Benim sorgu işlevi, bu gibi görünüyor:
private function query($sql)
{
$this->query_result = mysql_query($sql, $this->conn)
or die("Unable to query local database <b>". mysql_error()."</b><br>$sql");
}
Ben şu hatayı alıyorum:
MySQL Database Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LAST_INSERT_ID()'
Ben googled ve benzeri sorunları baktı, ama bir cevap buldum değil: (
Ben gerçekten bu kullanarak SQL yapmak istiyorum ben, PHP function mysql_insert_id() denemedim.