mysql - When php page open it is automatically insert 1 blank row -
mysql - When php page open it is automatically insert 1 blank row -
i want remove automatically created blank row & massage displaying in same page.
i want redirect page & show ren_no
here code:
$servername = "localhost"; $username = "root"; $password = ""; $dbname = "ruet"; $tbl_name="apply"; // create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // check connection if (!$conn) { die("connection failed: " . mysqli_connect_error()); } // values form error_reporting(e_all ^ e_notice); $name_eng=$_post['name_eng']; $name_ban=$_post['name_ban']; // .......... // insert info mysql $sql="insert $tbl_name(name_eng.......... $result=mysql_query($sql); if (mysqli_query($conn, $sql)) { $last_id = mysqli_insert_id($conn); echo "applied successfully. registration no :: " . $last_id; } else { echo "error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); ### if insert info database, displays message "successful". //header("location: applyview.php");
your code adding row because you're doing query in part:
if (mysqli_query($conn, $sql)) {
so need erase part ... in comments explained must utilize 1 api (as suggestion mysqli or pdo, mysql deprecated)
$result = mysql_query($sql);
and you'll get:
$sql="insert $tbl_name(name_eng..........)" if (mysqli_query($conn, $sql)) {
if error persist more specific in error , code.
php mysql forms
Comments
Post a Comment