boionfire81 Posted April 24, 2016 Share Posted April 24, 2016 Trying my hand at a note pad of sorts. I have a table setup called notepad with 3 columns, myid, yourid, note. The idea is to select the contents of the note column and display it where the userid's match. I came up with this $myid = ($ir['userid']); $yourid = ($r['userid']); $note = $db->query("SELECT `note` FROM `notepad` WHERE `myid`={$ir['userid']} AND `yourid`={$r['userid']}"); <textarea rows=7 cols=40 name='note'>{$note}</textarea> BUT the error is A critical error has occurred, and page execution has stopped. Below are the details: PHP Recoverable Error: Object of class mysqli_result could not be converted to string (4096) mccodes v2.0.5 btw Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 24, 2016 Share Posted April 24, 2016 You have to fetch the data Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted April 24, 2016 Author Share Posted April 24, 2016 so fetch_row instead of query? Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 25, 2016 Share Posted April 25, 2016 so fetch_row instead of query? No, both. Use $db->query to "query" the database. It will return a result and store it in the $note variable. But this result isn't just the data you wanted. It contains a lot of information about the query you asked the database to process. To get the data you need, after you query the database you need a line to store the data. $result = $db->fetch_row($note); Your code should look like: $myid = ($ir['userid']); $yourid = ($r['userid']); $note = $db->query("SELECT `note` FROM `notepad` WHERE `myid`={$ir['userid']} AND `yourid`={$r['userid']}"); $result = $db->fetch_row($note); echo "".$result['note'].""; Quote Link to comment 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.