Jump to content

Recommended Posts

When I try to run this query, it seems to not like the mysqli_insert_id($cxn) that I put in. Here is my code, and the error message that follows. Any ideas?

 

		$query = "INSERT INTO person (personName,personAge,personSchool,personCity,personState)
							VALUES ('$_POST[person_Name]','$_POST[person_Age]','$_POST[person_School]',
									'$_POST[person_City]','$_POST[state]')";
	$result = mysqli_query($cxn,$query)
				or die ("Couldn't execute query");

	$query = "INSERT INTO date (personId,comment)
							VALUES ('mysqli_insert_id($cxn)','$_POST[Comment]')";
	$result = mysqli_query($cxn,$query)
				or die ("Couldn't execute query");

 

Catchable fatal error: Object of class mysqli could not be converted to string in

Uh.... No problem I guess....

 

 

What was going on, by the way, is that it was being interpreted as mysql_insert_id(value of cxn) since functions are not parsed automatically in strings, but variables are (in double quoted strings, under some circumstances).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.