I'm just trying to get the max value of a row in my table, I then want to insert that value into another table, so I'm trying to get that max value, and every time I'm trying to do something with it, I get this error "illegal string offset" .
$qry2= "SELECT MAX(buss_id) FROM businesses";
$result= mysqli_query($con,$qry2);
$maxid = mysqli_fetch_assoc ($result);
print_r ($maxid);
foreach($maxid as $individual_data)
{
//Assign the values
$maxx = $individual_data['buss_id'];
}
My print_r function prints everything properly, but I just can't access the value I need to manipulate. I'm a beginner, please be kind. Thank you.
Array ( [MAX(buss_id)] => 47 )
MAX(buss_id)so either you need to change your query toSELECT MAX(buss_id) AS buss_idor change your code to get the key as$maxx = $individual_data['MAX(buss_id)'];