mysql_insert_id(): problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

mysql_insert_id(): problem

Post by itsmani1 »

Code: Select all

include "conn.php";
	$ChkRes = mysql_query("select * from users where login = '" .$_POST['userid']. "'") or die(mysql_error());
	$ChkNum = mysql_num_rows($ChkRes);
	if($ChkNum > 0)
	{
		$str = "agegroup=".$_POST['year']."-".$_POST['month']."-".$_POST['day']."&userid=".$_POST['userid']."&readingp=".$_POST['readingp']."&fname=".$_POST['fname']."&lname=".$_POST['lname']."&sex=".$_POST['sex']."&email=".$_POST['email']."&city=".$_POST['city']."&state=".$_POST['state']."&zip=".$_POST['zip']."&country=".$_POST['country']."&toc=".$_POST['toc']."&terms=".$_POST['terms']."&user=does";
		header("Location:register.php?$str");
		exit;
	}
	else
	{
		$resultx = mysql_query("insert into users (login,password) values ('".$_POST['userid']."','".$_POST['password']."')") or die(mysql_error());
		$reidx = mysql_insert_id($resultx);
		echo $reidx;exit;
On execuation it gives me fowllowing error:
Warning: mysql_insert_id(): supplied argument is not a valid MySQL-Link resource in c:\wamp\www\atlantared\register_post.php on line 14
User avatar
cyberpunk71
Forum Newbie
Posts: 2
Joined: Fri Apr 07, 2006 7:47 am
Location: Knoxville, TN USA

mysql_insert_id(): problem

Post by cyberpunk71 »

The problem is not in this code. There may a problem in your conn.php. Submit your conn.php
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Re: mysql_insert_id(): problem

Post by feyd »

cyberpunk71 wrote:The problem is not in this code. There may a problem in your conn.php. Submit your conn.php
It's actually the call to mysql_insert_id().
Post Reply