Page 1 of 1

mysql_insert_id()

Posted: Sun Jun 20, 2010 4:57 am
by gazzieh
I am using the command mysql_insert_id() to load a page where a new article has been added to the system.

The problem is that when executed the result is 1 digit above the id value. So, if the unique value stored is 7 the code below gives 8.

Where am I going wrong?

Code: Select all

$insertQuery = "INSERT INTO cmsarticles (title,thearticle) VALUES ( '".$HTTP_POST_VARS['title']."', '".$HTTP_POST_VARS['thearticle']."')";
					
if ($result = $connector->query($insertQuery))
	{
	header("Location: ../article.php?id=".mysql_insert_id()."&act=v");
	}
else
	{
	echo('<center>Sorry, there was an error adding to the database</center>');
	}

Re: mysql_insert_id()

Posted: Sun Jun 20, 2010 6:05 am
by gazzieh
Ignore. All solved.

issue was not that section of code but with not ending a switch properly earlier.