burntheblobs Posted November 28, 2008 Share Posted November 28, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/134606-solved-could-not-convert-to-string-error/ Share on other sites More sharing options...
corbin Posted November 28, 2008 Share Posted November 28, 2008 $query = "INSERT INTO date (personId,comment) VALUES ('mysqli_insert_id($cxn)','$_POST[Comment]')"; $query = "INSERT INTO date (personId,comment) VALUES ('".mysqli_insert_id($cxn)."','$_POST[Comment]')"; Quote Link to comment https://forums.phpfreaks.com/topic/134606-solved-could-not-convert-to-string-error/#findComment-700841 Share on other sites More sharing options...
burntheblobs Posted November 28, 2008 Author Share Posted November 28, 2008 I love you guys. Solved. Quote Link to comment https://forums.phpfreaks.com/topic/134606-solved-could-not-convert-to-string-error/#findComment-700845 Share on other sites More sharing options...
corbin Posted November 28, 2008 Share Posted November 28, 2008 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). Quote Link to comment https://forums.phpfreaks.com/topic/134606-solved-could-not-convert-to-string-error/#findComment-700848 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.