php - Loop through 1 table and add selected values to a 2nd table and 'do more while' the loop is iterating -
this question has answer here:
i have 2 tables: 'user2' , 'notes'
i select email entry in 'users2' signin = 900 , update row in 'notes' (with same email) pin number.
<?php require_once ('mysqli_connect.php'); //connect database $q = "select email email users2 signin = 900"; $r = mysqli_query ($dbc, $q) or trigger_error("query: $q\n<br />mysql error: " . mysqli_error($dbc)); $num = @mysqli_num_rows($r); if ($num > 0) { while ($row = mysqli_fetch_array($r, mysqli_assoc)){ $email = $row['email']; $pin = 1234; $q = "update notes set permit = '$pin' email = '$email'"; $r = mysqli_query ($dbc, $q) or trigger_error("query: $q\n<br />mysql error: " . mysqli_error($dbc)); } } ?> an error being returned:
warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in /home/fxyour/public_html/checkin/new4.php on line 8
that line 'while' on it.
i have tried various other ways error remains. have same layout in project , works fine.
something should help:
$pin = 1234; $q = "update notes set permit='$pin' email in (select email users2 signin = 900)"; $r = mysqli_query ($dbc, $q); update:
error in provided code author - $r variable used 2 times different results, , used in while loop, destroy workflow of script. change 1 variable name.
Comments
Post a Comment