$run = $con->query ( $query );
$id = mysql_insert_id ();
//find category Name
$category = $_REQUEST ['category'];
$run1 = $con->query ("select * from category where id='$category'");
$run2=$run1->fetch_array();
$category=$run2['category'];
//find subcategory Name
$run11 = $con->query ("select * from subcategory where id='$subcategory'");
$run21=$run11->fetch_array();
$subcategory=$run21['subcategory'];
Asked
Active
Viewed 97 times
-4
-
What type is `$con`? – Progman Oct 25 '20 at 21:28
-
2your cod eis **vunerable** to **sql injection** so use only **prepared statements with paramaters** – nbk Oct 25 '20 at 21:30
-
1Reading the [PHP Manual](https://www.php.net/manual/en/mysqli.insert-id.php) will be an invaluable experience to learn about these transitions. – Martin Oct 25 '20 at 21:31
-
If you are changing the old mysql_* API then I would recommend changing it to PDO. Why bother with mysqli? – Dharman Oct 25 '20 at 21:37
1 Answers
-1
See mysqli::$insert_id. mysql_insert_id() was part of the now deprecared mysql-extension.

slaakso
- 8,331
- 2
- 16
- 27