runnerjp Posted November 14, 2008 Share Posted November 14, 2008 im trying to notify users that there post has been replied too.. the thing is grabbing to tipoid_id so i can insert it into the db... so when a post is beeing created i was going to do this <?php if (isset($_POST['email'])) { $insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username')"; mysql_query($insertpost) or die("Could not insert post"); // RESOURCE ID IS IN $xyz $newPostID = mysql_insert_id($insertposts); echo $newPostID; //$insertemail = "INSERT INTO forum_email(user_id,topic_id,mailed) values('$id','$forumpostid','1')"; //mysql_query($insertemail) or die("Could not insert email"); //insert email $updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'"; mysql_query($updatepost) or die("Could not update post"); $newPostID = mysql_insert_id($insertpost); echo $newPostID; //header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum"); exit;?> Warning: mysql_insert_id(): supplied argument is not a valid MySQL-Link resource Link to comment https://forums.phpfreaks.com/topic/132701-solved-the-use-of-mysql_insert_id/ Share on other sites More sharing options...
runnerjp Posted November 14, 2008 Author Share Posted November 14, 2008 ah ok sorry just been reading and found it at last... all you have to do is place it under the insert and it will echo it out! bingo Link to comment https://forums.phpfreaks.com/topic/132701-solved-the-use-of-mysql_insert_id/#findComment-690113 Share on other sites More sharing options...
.josh Posted November 14, 2008 Share Posted November 14, 2008 mysql_insert_id doesn't necessarily have to be under the insert. It grabs the id of the last insert you did, whenever/wherever that was. Problem was that you were trying to pass the query string to it as an argument, when it expects a connection resource (which is an optional argument; it will use the one available by default). Link to comment https://forums.phpfreaks.com/topic/132701-solved-the-use-of-mysql_insert_id/#findComment-690115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.