Conversion from mysql to mysqli not working -


i in process of converting existing mysql mysqli

but can't piece of code correct

mysql_query("insert `sendmsg`(`sendname`, `recievename`, `subject`, `body` , `mdate`, `mtime`) values ('$sendname','$recievename','$subject','$body','$msgdate','$msgtime')"); $new_id = mysql_insert_id(); mysql_query("insert `recievemsg`(`msgid`, `sendname`, `recievename`, `subject`, `body`, `mdate`, `mtime`, `status`) values ($new_id,'$sendname','$recievename','$subject','$body','$msgdate','$msgtime','unread')"); 

what tried given below didnt work

$mysqli->query("insert `sendmsg`(`sendname`, `recievename`, `subject`, `body` , `mdate`, `mtime`) values ('$sendname','$recievename','$subject','$body','$msgdate','$msgtime')"); $new_id = mysqli_insert_id(); $mysqli->query("insert `recievemsg`(`msgid`, `sendname`, `recievename`, `subject`, `body`, `mdate`, `mtime`, `status`) values ($new_id,'$sendname','$recievename','$subject','$body','$msgdate','$msgtime','unread')"); 

the problem $new_id = mysqli_insert_id(); statement bcoz first query executing

pls help

for mysqli object oriented style last inserted id use this

$mysqli->insert_id ; 

http://www.php.net/manual/en/mysqli.insert-id.php

so queries as

$mysqli->query("insert `sendmsg`(`sendname`, `recievename`, `subject`, `body` , `mdate`, `mtime`) values ('$sendname','$recievename','$subject','$body','$msgdate','$msgtime')");  $new_id = $mysqli->insert_id;  $mysqli->query("insert `recievemsg`(`msgid`, `sendname`, `recievename`, `subject`, `body`, `mdate`, `mtime`, `status`) values ($new_id,'$sendname','$recievename','$subject','$body','$msgdate','$msgtime','unread')"); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -