PHP MYSQL CRUD(Create Read Update Delete) Application update error -
i have been working on php mysql crud(create read update delete) application stuck @ update-(edit.php) script, error messages reflected in next lines: if($_post["do"]=="update") stating: undefined index 'do' getting error message: mysqli_query() expects 2 parameters reffering to: $result=mysqli_query($query); , similar stating mysqli_fetch_array() expects parameter 1 mysqli_result, referring to: while($row=mysqli_fetch_array($result)) have been trying solve past 2 days im wondering if few pair of eyes along knowledge help me pin point error(s).
<?php if($_post["do"]=="update"){ $terminal=$_post["terminal"]; $acquirer=$_post["acquirer"]; $acquirer_name=$_post["acquirer_name"]; $acquirer_agent=$_post["acquirer_agent"]; $merchant_name=$_post["merchant_name"]; $multilink_terminal=$_post["multilink_terminal"]; $country=$_post["country"]; $parish=$_post["parish"]; $area=$_post["area"]; $location=$_post["location"]; $venue=$_post["venue"]; $status=$_post["status"]; $date_online=$_post["date_online"]; $query="update terminal_ncb_jan_jun set acquirer='$acquirer', acquirer_name='$acquirer_name', acquirer_agent='$acquirer_agent', merchant_name='$merchant_name', multilink_terminal='$multilink_terminal', country='$country', parish='$parish', area='$area', location='$location', venue='$venue', status='$status', date_online='$date_online' terminal=$terminal"; mysqli_query($query); } $terminal=$_get["terminal"]; $query="select * terminal_ncb_jan_jun terminal='$terminal'"; $result=mysqli_query($query); while($row=mysqli_fetch_array($result)){ ?> <form name="update" method = "post" action ="edit.php"> <table> <tr> <td>terminal</td> <td><?php echo $row[0];?><input type="hidden" name="terminal" value="<?php echo $row[0];?>"></td> <td>acquirer name</td> <td><input type="text" name="acquirer_name" value="<?php echo $row[1];?>" disabled="disabled"></td> <td>acquirer agent</td> <td><input type="text" name="acquirer_agent" value="<?php echo $row[2];?>"></td> <td>merchant name</td> <td><input type="text" name="merchant_name" value="<?php echo $row[3];?>"> </td> <td>multilink terminal</td> <td><input type="text" name="multilink_terminal" value="<?php echo $row[4];?>"> </td> <td>country</td> <td><input type="text" name="country" value="<?php echo $row[5];?>"></td> <td>parish</td> <td><input type="text" name="parish" value="<?php echo $row[6];?>"></td> <td>area</td> <td><input type="text" name="area" value="<?php echo $row[7];?>"></td> <td>location</td> <td><input type="text" name="location" value="<?php echo $row[8];?>"></td> <td>venue</td> <td><input type="text" name="venue" value="<?php echo $row[9];?>"></td> <td>status</td> <td><input type="text" name="status" value="<?php echo $row[10];?>"></td> <td>date online</td> <td><input type="text" name="date_online" value="<?php echo $row[11];?>"></td> </tr> <tr> <td><input type="hidden" name ='do' value ='update'><input type='submit' value="updatae record"></td> </tr> <?php } ?> </table> </form> </body> </html>
first issue $_post['do'] doesn't have value , isn't instanced if. check beingness passed update page correctly , has value echoing out before if. prepare it.
2nd issue mysql params you're not opening mysql connection anywhere in script can't run mysql_query.
fixing issue 2 prepare other issues too.
finally since appears learning don't utilize mysql_ functions utilize pdo or @ to the lowest degree mysqli , prepared statements.
php mysql
No comments:
Post a Comment