0

I am getting an error with below code that tries to process data from another form to use to update the database. I am not sure why I get this error. Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in .../editrecord.php on line 28

  <body>
    <?php 
    // connect to the DB
    include('includes/connect.php');
    // get value of id that sent from address bar
    $id=$_GET['id'];

    // Retrieve data from database 
    $sql="SELECT * FROM $Customers WHERE id='$id'";
    $result=mysqli_query($con, $sql);
    $rows=mysqli_fetch_array($result);
    ?>

    <table width="400" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <form name="form1" method="post" action="update_ac.php">
    <td>
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>&nbsp;</td>
    <td colspan="3"><strong>Update data in mysql</strong> </td>
    </tr>
    <tr>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
    </tr>
    <tr>
    <td align="center">&nbsp;</td>
    <td align="center"><strong>Name</strong></td>
    <td align="center"><strong>Lastname</strong></td>
    <td align="center"><strong>Email</strong></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td align="center">
    <input name="name" type="text" id="name" value="<? echo $rows['firstname']; ?>">
    </td>
    <td align="center">
    <input name="lastname" type="text" id="lastname" value="<? echo $rows['lastname']; ?>" size="15">
    </td>
    <td>
    <input name="email" type="text" id="email" value="<? echo $rows['email']; ?>" size="15">
    </td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>
    <input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>">
    </td>
    <td align="center">
    <input type="submit" name="Submit" value="Submit">
    </td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>

    <?php
    // close connection 
    mysqli_close($con);
    ?>
mush
  • 181
  • 1
  • 8
  • There is probably an error with your query, $sql. Try the error function to see what is going wrong: http://www.w3schools.com/php/func_mysqli_error.asp – Kohjah Breese Dec 06 '15 at 02:20
  • I get the following descrp, which doesn't say much to me.Error description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='1000005'' at line 1 – mush Dec 06 '15 at 02:25
  • 1
    You probably need to set the variable: $Customers. This should be the name of a MySQL table, e.g. SELECT * FROM Customers WHERE id = 1; – Kohjah Breese Dec 06 '15 at 02:29

0 Answers0