Level 10
mysqli_fetch_array ?
Previously i had build a code redeem website with php old version, but then i upgraded php version to 7. After that i found mysql fetch array function has been removed. What should i need to change in my code?
$sql = "SELECT * FROM code_redeem WHERE redeemCode='$promoCode'";
$result = mysqli_query($connection,$sql)or die('error getting data');
$num_rows = mysqli_num_rows($result);
if ($result->num_rows == 1) {
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
if($num_rows==1){
if($row['used']==1){
echo "<script type='text/javascript'>alert('Code has been used');</script>";
}else{
$sql = "UPDATE code_redeem SET used='1', user= '$userName', contactNo= '$contactNo',email= '$email', browserName= '$browserName', browser= '$browser', location= '$location', regDate= '$regdate', device= '$device' WHERE redeemCode='$promoCode'";
if ($connection->query($sql) === TRUE) {
//echo "Record updated successfully";
} else {
//echo "Error updating record: " . $connection->error;
}
require_once ('run/start.php');
return;
}
}
}
}
Please or to participate in this conversation.