Jump to content

[SOLVED] the use of mysql_insert_id


runnerjp

Recommended Posts

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

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).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.