Reputation: 109
I have to adapt PHP5 script to PHP7. I almost figured it out everything but I'm blocked on a small part in a query function. My former colleague used the mysql_field_name function which is no longer available in PHP7.
I've tried to modify the code but it seems that it's not working.
This is the original code:
$rep = mysql_query($query);
if ($rep)
{
$i = 0;
while($res = mysql_fetch_row($rep))
{
for($j=0; $j<count($res); $j++)
$tabRes[$i][strtoupper(mysql_field_name($rep, $j))] = $res[$j];
$i++;
}
}
I've tried to replace mysql_field_name by mysqli_fetch_fields .
$rep = mysqli_query($this->conn_id,$query);;
if ($rep)
{
$i = 0;
while($res = mysqli_fetch_row($rep))
{
for($j=0; $j<count($res); $j++)
$tabRes[$i][strtoupper(mysqli_fetch_fields($rep)->$j)] = $res[$j];
$i++;
}
}
How I can fix this issue?
Upvotes: 0
Views: 658
Reputation: 1745
Check mysqli_fetch_field_direct, which is among the alternatives after PHP7
Upvotes: 2