Jump to content

Recommended Posts

Uhm. You are "hostile" to using the functionality designed to make life easier on you because....?

 

Are you saying you want all the results in an array, and then access the array key? Or you want to give a function the ID and get that row?

With Hostile I mean the id column of sql table do not update accordingly. OK if the id is the only solution I employ it.

My table has many many rows, and I need only the last six rows. I want to get all the rows and then by using array keys fetch them: $result[$size-1]; $result[$size-2] and ...;

 

If I could store only last six rows directly from the SQL statement, then life would be much easier.

Sorry I again encountered a problem

 

The below part of script doesn't work with "prepare", while it easily runs with "query";

DEFINE("SELECT", "SELECT english, persian FROM ");

$statement = SELECT . $table . " ORDER BY id DESC LIMIT 6";

if($data = $database->query($statement))

{

$b = $data->fetch_array(MYSQLI_NUM);

echo $b[0] . " " . $b[1];

$data->close();

}

It is due to security reason. I often use it. recently I read a book at which this method was also used. When I use prepare in place of query (and of course some more change such as execute() added) it errs that the method mysqli_stmt::fetch_array is undefined.

POST THE CODE for crying out loud.

 

 

http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php

http://www.php.net/manual/en/class.mysqli-stmt.php

 

There is no fetch_array on a prepared statement. The error message is pretty clear. 

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.