|
Heinz Ernst - 2015-09-24 14:01:41
Hello Dave
In my original script I have the following code:
***********************************************
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
.....some result-code here
}
***********************************************
And I get back the following message:
Notice: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' in D:\xampp-5-6\xampp\htdocs\friedhof1\mainnav.php on line 15
Warning: mysqli_fetch_array() expects parameter 2 to be long, string given in D:\xampp-5-6\xampp\htdocs\friedhof1\includes\mysql2i.class.php on line 140
What do I have to change?
Thanks in advance
Heinz
Dave Smith - 2015-09-24 15:10:16 - In reply to message 1 from Heinz Ernst
Looks like the predefined fetch constants went away with the MySQL extension, so we need to add them. I put them in the mysql2i.func.php file, just before the first function...
//predifined fetch constants
define('MYSQL_BOTH',MYSQLI_BOTH);
define('MYSQL_NUM',MYSQLI_NUM);
define('MYSQL_ASSOC',MYSQLI_ASSOC);
Dave
Steve Lawson - 2016-07-08 21:12:27 - In reply to message 1 from Heinz Ernst
I will assume that this issue is occurring because you switched from PHP 7.0 from PHP 5.x. If so, the deprecated mysql_???? functions are no longer supported. You must use the mysqli_???? functions, instead. I think this also may be true in PHP 5.5 and above, but not sure.
So,
mysql_fetch_array($result, MYSQL_ASSOC));
becomes
mysqli_fetch_array($result, MYSQLI_ASSOC));
Note the inclusion of 'i' in the function name and the inclusion of 'I' in the constant name.
Steve Lawson - 2016-07-08 21:14:39 - In reply to message 2 from Dave Smith
"...so we need to add them. I put them in the mysql2i.func.php file, just before the first function..."
This is unadvised! An update could easily break this!! See my other reply.
Dave Smith - 2016-07-09 04:06:22 - In reply to message 4 from Steve Lawson
The concept behind the package is to provide a simple method that will allow code written with the mysql extension to continue to operate in PHP 7.
I have always recommended that the problem code be updated, which is what you are also suggesting. That said, there are situations where legacy code may not get updated right away, if ever, so this package will pick up the load and keep that legacy code from breaking.
Since the legacy code will not operate in PHP 7, it is highly advised that anyone using this package as a stop gap redefine the constants that will be missing in PHP 7.
Once any legacy code has been updated to the mysqli extension, this package is no longer needed.
Dave
Ezequiel - 2018-01-13 13:53:46 - In reply to message 2 from Dave Smith
Thaxs! Dave! It's work!
|