Jump to content

[SOLVED] Could not convert to string error


burntheblobs

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

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.