Jump to content

Recommended Posts

Okay, so I'm trying to run a query to pull the information from a specific item that they click on in order to edit it.

 

When I run an echo $query, though, it shows the field names rather than the information from the table.

 

How can I make it so that it pulls the information rather than the field names?

 

Here's what I have...

 

<?php
include("lib.php");
define("PAGENAME", "Edit Equipment");

if ($player->access < 100)

$msg1 = "<font color=\"red\">"; //name error?
$error = 0;

$query = $db->execute("SELECT * FROM items WHERE id=?", array($_POST['id']));

echo "$id";

$result = mysql_query($query);

echo "$query";

$data = mysql_fetch_assoc($result); 

$msg1 .= "</font>"; //name error?


?>

 

Thanks!!

You're mixing usage of $db with the base mysql functions.  One or the other.  $db->execute() returns a result object meant to be used however the $db library is designed (you don't say what you're using).  You cannot pass a result object back through the query function, the query function expects a string and will return false when you give it an object.  Then, you take that false and pass it into the fetch function, which throws the error you posted (which should have been in your first post).

The only db class that I know of that uses a "execute" method, returns "mysql_affected_rows()".  This method is suppose to be used for "INSERT, UPDATES, DELETES" according to the documentation in the class.  There is also a "query" method, that returns a resource, of which the method "fetchNextObject()" will return (ironically) a data object.

 

DB class

 

Although, the more powerful PDO should be used instead of this class.

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.