Jump to content
MakeWebGames

DB query


boionfire81

Recommended Posts

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

Link to comment
Share on other sites

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']."";
Link to comment
Share on other sites

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.   Paste as plain text instead

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