PHP Classes

Error in your updated mysql_result

Recommend this page to a friend!

      PHP MySQL to MySQLi  >  All threads  >  Error in your updated mysql_result  >  (Un) Subscribe thread alerts  
Subject:Error in your updated mysql_result
Summary:Error in the 1.5 version of your mysql_result function
Messages:10
Author:Josh
Date:2017-09-06 13:54:11
 

  1. Error in your updated mysql_result   Reply   Report abuse  
Picture of Josh Josh - 2017-09-06 13:54:11
It took some digging and I kept overlooking it but I found the root of my issue when using the updated class file which included the version 1.5 changes to mysql_result function.


You have the second parameter for mysqli_data_seek using the $field variable which should be using the $row variable.

You can confirm this by referencing the original sourced code from Mario in the comment of the code itself.


Line 441 of mysql2i.class.php is currently:

mysqli_data_seek($result,$field);

It should be:

mysqli_data_seek($result,$row);



On a side note, looking at the other recent post and their supplied code they are using. This might be related to their issue they are having (as the code I am working on updating has similar "logic" lol).

This fixed the error I was getting stating:

[06-Sep-2017 08:36:33 America/Chicago] PHP Warning: mysqli_data_seek() expects parameter 2 to be long, string given in ....\mysql2i.class.php on line 441

  2. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-09-06 14:19:48 - In reply to message 1 from Josh
Thanks for the catch, looks I did put in the wrong parameter when updating the code I used. The package has been updated.

Dave

  3. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Reinaldo Coelho Reinaldo Coelho - 2017-09-21 10:58:34 - In reply to message 2 from Dave Smith
hello, this scripts work fine with datatables, but not with table.org, this table i use to edit, delete, uldate data, the problem is with this

function loadResult()
{
$cur = $this->query();
$ret = @mysql_result($cur,0);
//mysql_free_result( $cur );
return $ret;
}

on mysql2i

public static function mysql_result($result, $row, $field = null)
{

mysqli_data_seek($result, $row);
if (!empty($field)) {
while ($finfo = mysqli_fetch_field($result)) {
if ($field == $finfo->name) {
$f = mysqli_fetch_assoc($result);

return $f[$field];
}
}
}

$f = mysqli_fetch_array($result);

return $f[0];

}

i donīt know programing, initially i use this - https://github.com/philip/MySQLConverterTool

but yours solotions is more clean, and i donīt need update code

regards

Ronald Rabbit

  4. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-09-21 12:07:37 - In reply to message 3 from Reinaldo Coelho
I'm not seeing a problem in the code, are you receiving a mysql error, or is it returning the wrong or null result?

Also, what does the query() function look like in the same class as the loadResult() function?

Dave

  5. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Reinaldo Coelho Reinaldo Coelho - 2017-09-21 13:07:37 - In reply to message 4 from Dave Smith
thanks for your quick reply. The page without this code gives error (blank), with this code loads the page but not the table. With the previous program for the nudb.php file that connects to bd, it gives an error message for line 57 - http://www.botm.gov.pl/infomat/MySQLConverterTool/GUI/index.php, which I sent in the previous message. Here is what I use - https://github.com/nubuntu/jtable

function loadResult()
{
$cur = $this->query();
$ret = @mysql_result($cur,0);
//mysql_free_result( $cur );
return $ret;
}

the problem is with this part of code, myslq2i.class.php is not resolving

sorry my english, if you undestand, good

Thank you

  6. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-09-21 15:14:04 - In reply to message 5 from Reinaldo Coelho
Looks like we need to debut, I want to try making some changes to the loadResult method first, change...

function loadResult()
{
$cur = $this->query();
$ret = @mysql_result($cur,0);
//mysql_free_result( $cur );
return $ret;
}

to...

function loadResult()
{
$this->recordset = $this->execute();
$ret = mysql_result($this->recordset,0);
return $ret;
}

and let me know if there is any change.

Dave

  7. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Reinaldo Coelho Reinaldo Coelho - 2017-09-21 15:32:15 - In reply to message 6 from Dave Smith
when it changes to what it indicated, but still with mysql enabled, it works. When I go to the cpanel and change to php7 the page does not load gives this error

This page is not working.

www can not process this request at this time.
HTTP ERROR 500

and the datatables continue to work with before php5 and then php7

Ronald

  8. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Reinaldo Coelho Reinaldo Coelho - 2017-09-21 15:40:05 - In reply to message 7 from Reinaldo Coelho
I saw it now, it works but the line disappears to navigate the pages

<<< 12 ... 148988148989 >>> Go to page: "dropdown menu" Lines: "dropdownmenu"

Showing 1-5 out of 744942

  9. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-09-21 16:07:07 - In reply to message 8 from Reinaldo Coelho
It appears that the jtable class is redundantly specifying the mysql resource in the jtable/nudb.php file, change these 2 lines...

mysql_select_db($this->db,$this->dbo);

to

mysql_select_db($this->db);


and...

$this->recordset = mysql_query($this->_sql,$this->dbo) ;

to

$this->recordset = mysql_query($this->_sql) ;

Hopefully it is what is causing the new issue you just found, although it does appear to be the problem with original issue.

Dave

  10. Re: Error in your updated mysql_result   Reply   Report abuse  
Picture of Reinaldo Coelho Reinaldo Coelho - 2017-09-21 16:51:41 - In reply to message 9 from Dave Smith
this change works in php5 and loads the table, in php7 it does not give page error but does not load the table.
I know this is complicated, so many people will not switch to php7, the solution will be to choose a provider that always has php5

thanks for the interest and thanks for mysqli2.class.php, at least for the datatables solved

Ronald