Note that there are some explanatory texts on larger screens.

plurals
  1. POphp UPDATE QUERY fail my_fetch_array
    primarykey
    data
    text
    <p>I am trying to update my supplier information within a form</p> <p>Here is my my code for the editsupplier form</p> <pre><code>&lt;?php $SupplierID = $_GET['SupplierID'] = $row['SupplierID']; //Connect and select a database mysql_connect ("localhost", "root", ""); mysql_select_db("supplierdetails"); //Run query $result1 = mysql_query("SELECT * FROM suppliers WHERE SupplierID=$SupplierID"); while($row = mysql_fetch_array($result1)){ $SupplierID = $_GET['SupplierID'] = $row['SupplierID']; $SupplierName = $row['SupplierName']; $Currency = $row['Currency']; $Location = $row['Location']; $ContactNumber = $row['ContactNumber']; $Email = $row['Email']; } ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; &lt;meta name="description" content="" /&gt; &lt;meta name="keywords" content="" /&gt; &lt;meta name="author" content="" /&gt; &lt;link rel="stylesheet" type="text/css" href="style.css" media="screen" /&gt; &lt;title&gt;Harrison Spinks&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrapper"&gt; &lt;?php include('includes/header.php'); ?&gt; &lt;?php include('includes/nav.php'); ?&gt; &lt;div id="content"&gt; &lt;h3&gt;&lt;center&gt;Edit Supplier Information&lt;/center&gt;&lt;/h3&gt; &lt;p&gt;Please enter all the following details to edit a supplier&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;br&gt; &lt;/br&gt; &lt;form action="Edit_Supp.php" method="post"&gt; &lt;br&gt; &lt;/br&gt; &lt;input type="hidden" name="SupplierID" value="&lt;?php echo $SupplierID;?&gt;"/&gt; Supplier Name: &lt;input type="text" name="SupplierName" value="&lt;?php echo $SupplierName ;?&gt;" /&gt; &lt;br&gt; &lt;/br&gt; Currency: &lt;input type="text" name="Currency" value="&lt;?php echo $Currency ;?&gt;" /&gt; &lt;br&gt; &lt;/br&gt; Location: &lt;input type="text" name="Location" value="&lt;?php echo $Location ;?&gt;" /&gt; &lt;br&gt; &lt;/br&gt; Contact Number:&lt;input type="text" name="ContactNumber" value="&lt;?php echo $ContactNumber ;?&gt;" /&gt; &lt;br&gt; &lt;/br&gt; Email:&lt;input type="text" name="Email" value="&lt;?php echo $Email ;?&gt;" /&gt; &lt;br&gt; &lt;/br&gt; &lt;input type="submit" value= "Edit Supplier Information"/&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Errors are:</p> <pre><code>Notice: Undefined variable: row in E:\xampp\htdocs\EditSupForm.php on line 2 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\xampp\htdocs\EditSupForm.php on line 8 </code></pre> <p>This is the code behind the form:</p> <pre><code>&lt;?php $con = mysql_connect("localhost", "root", ""); mysql_select_db("supplierdetails"); if (!$con) { die('Could not connect: ' . mysql_error()); } //Run a query $SupplierID= $_POST['SupplierID'] = $row ["SupplierID"]; $result1 = mysql_query ("SELECT * FROM suppliers WHERE SupplierID= '".$SupplierID."'") or die(mysql_error()); $row = mysql_fetch_array($result1); $SupplierID = $_POST['SupplierID'] = $row ["SupplierID"]; $SupplierName = $_POST['SupplierName']; $Currency = $_POST['Currency']; $Location = $_POST['Location']; $ContactNumber = $_POST['ContactNumber']; $Email = $_POST['Email']; $SupplierID = $row['SupplierID']; $query = "UPDATE suppliers SET SupplierID = '".$SupplierID."', SupplierName= '".$SupplierName."', Currency = '".$Currency."', Location = '".$Location."', ContactNumber = '".$ContactNumber."', Email = '".$Email."' WHERE SupplierID = '".$id."'"; $result1 = mysql_query($query); //Check whether the query was successful or not if($result1) { echo "Supplier Updated"; header ("Location: Supplier.php"); } else { die ("Query failed"); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload