0

Error stating

Notice: Undefined variable: row in E:\xampp\htdocs\Edit_Supp.php on line 9

Notice: Undefined index: id in E:\xampp\htdocs\Edit_Supp.php on line 12 Supplier Updated

Code: Edit_Supp_Form.php

<?php   
$SupplierID = $_GET['id'];
//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['id'] = $row['SupplierID']; 
$SupplierID = $row['SupplierID']; 
$SupplierName = $row['SupplierName'];
$Currency = $row['Currency'];
$Location = $row['Location'];
$ContactNumber = $row['ContactNumber'];
$Email = $row['Email'];
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-    strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
  <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
 <form action="Edit_Supp.php" method="post">
 <br>
 </br>
 <input type="hidden" name="SupplierID" value="<?php echo $SupplierID;?>"/> 

Supplier Name: <input type="text" name="SupplierName" value="<?php echo $SupplierName ;?>" />
<br>
</br>
 Currency: <input type="text" name="Currency" value="<?php echo $Currency ;?>" />
 <br>
 </br>
 Location: <input type="text" name="Location" value="<?php echo $Location ;?>" />
 <br>
</br>
 Contact Number:<input type="text" name="ContactNumber" value="<?php echo $ContactNumber ;?>" /> 
<br>
</br>
Email:<input type="text" name="Email" value="<?php echo $Email ;?>" />
<br>
</br>
<input type="submit" value= "Edit Supplier Information"/>

 </form>
 </div>
 </body>
 </html> 

//Plus code for the Edit_Sup which is the code behind this page:

<?php
 $con = mysql_connect("localhost", "root", "");  
    mysql_select_db("supplierdetails");   
      if (!$con)     
          {       
        die('Could not connect: ' . mysql_error());        
         }    
 //Run a query        
$SupplierID= $_POST['id'] = $row ["SupplierID"];
 $result1 = mysql_query ("SELECT * FROM suppliers WHERE SupplierID= '".$SupplierID."'") or die    (mysql_error());     
$row = mysql_fetch_array($result1); 
$SupplierID = $_GET['id'];
$SupplierID = $_POST['id'];
$SupplierName = $_POST['SupplierName'];
$Currency = $_POST['Currency'];
$Location = $_POST['Location'];
$ContactNumber = $_POST['ContactNumber'];
$Email = $_POST['Email'];  
$SupplierID = $row['SupplierID'];         
$query = "UPDATE suppliers SET SupplierName = '".$SupplierName."', Currency     = '".$Currency."', Location = '".$Location."', ContactNumber = '".$ContactNumber."', Email = '".$Email."' WHERE SupplierID = '".$SupplierID."'";     
$result1 = mysql_query($query);           
 //Check whether the query was successful or not    
 if($result1) 
{          
 echo "Supplier Updated"; 

 }
else 
{        
 die ("Query failed");    
  }    
 ?>
1

2 Answers 2

2

You have referenced $_POST['id'] in Edit_sup.php, but I don't see any input field with the name id. and line 9 of Edit_sup.php reads -

$SupplierID= $_POST['id'] = $row ["SupplierID"];

I don't see where you got that $row variable from.

Sign up to request clarification or add additional context in comments.

7 Comments

@NatalieWebb that should be $_GET['id'] then. Please work on your basics.
i have got a $_GET['id] already which fills in all the information within the form
Notice: Undefined variable: row in E:\xampp\htdocs\Edit_Supp.php on line 9 Notice: Undefined index: SupplierID in E:\xampp\htdocs\Edit_Supp.php on line 12 Supplier Updated
Read my answer again. Where did the $row variable come from?
$row variable thought that was the row within my database
|
0

You're trying to get $row['id'], I think what you want is $_POST['SupplierID']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.