Thursday 15 July 2010

php - mysqli_insert_id doesn't return anything -



php - mysqli_insert_id doesn't return anything -

<?php >here database connection code $connection = mysqli_connect($server_name,$user_name,$password,$database_name); >the post variable comes page $first_name = $_post['first_name']; $last_name = $_post['last_name']; $birth_date = $_post['birth_date']; if($connection){ $insert = "insert describee(first_name,last_name,birth_date) values ('$first_name','$last_name','$birth_date')"; $execute_insert = mysqli_query($connection,$insert) or die("insert query error"); >here want select lase inserted row database show in textarea tag if( !empty($first_name) && !empty($last_name) && !empty($birth_date) ){ $last_id = mysqli_insert_id(); $select = "select * describee id = $last_id"; $execute_select = mysqli_query($connection,$select) or die("select query error"); >$last_id doesn't hold info homecoming error in select query. ?>

you're missing connection mysql should passed parameter mysqli_insert_id()

$last_id = mysqli_insert_id($connection);

php

No comments:

Post a Comment