Hi I am having a problem with code i have created to delete a customer from my database, would be grateful if someone could tel me where i have gone wrong

<?php
include ('db.php');


$cid=$_POST["cid"];
$cname=$_POST["cname"];
$cusadd1=$_POST["caddress"];
$cusadd2=$_POST["caddress1"];
$cusadd3=$_POST["caddress2"];
$ccounty=$_POST["county"];
$custpc=$_POST["cpostcode"];
$custele=$_POST["ctelephone"];
$cusemail=$_POST["cemail"];
print $cid;
$str="delete from customer CustomerName='$cname',CustomerAddress='$cusadd1',CustomerAddress1='$cusadd2',CustomerAddress2='$cusadd3',County='$ccounty',CustomerPostCode='$custpc',CustomerTelNo='$custele',CustomerEmail='$cusemail' where customerid=$cid ";

print $str;
mysql_query($str);




?>
<?php
include ('db.php');


$cid=$_POST["cid"];
$str="delete * from customer where  customerid=$cid ";

print $str;
mysql_query($str);



//print $str;

?>
<?php
include('functions.php');

	$id=$_POST['id'];
    $myArray=array();
    $myArray=getDeleteCustomer($id);
	
	

	

	
	print "<form name ='RegisterForm' method='POST' action='delCustomer.php' onSubmit='return validateEditCustomerSubmit(this)'>";

	
	print '<table>';
	
	print "<tr><td>Customer Name</td><td><input  name='cname'type='text' size=30 value='$myArray[1] '></input></td></tr>";
	print "<tr><td>Address Line 1</td><td><input name ='caddress' type='text' size=30 value='$myArray[2] '></input></td></tr>";
	print "<tr><td>Address Line 2</td><td><input name='caddress1' type='text' size=30 value='$myArray[3] '></input></td></tr>";
	print "<tr><td>Address Line 3</td><td><input name='caddress2' type='text' size=30 value='$myArray[4] '></input></td></tr>";
	
	print "<tr><td> County</td><td><input name='county' type='text' size=30 value='$myArray[5] '></input></td></tr>";
	print "<tr><td>Postcode</td><td><input name='cpostcode' type='text' size=30 value='$myArray[6] '></input></td></tr>";
	print "<tr><td> Telephone Number</td><td><input name='ctelephone' type='text' size=30 value='$myArray[7] '></input></td></tr>";
	print "<tr><td>Email</td><td><input name='cemail' type='text' size=30 value='$myArray[8] '></input></td></tr>";	
	print "<tr style='display:none'><td>Email</td><td><input name='cid' type='text' size=30 value='$myArray[0] ' ></input></td></tr>";		
    print "</table>";
	print "<input type='submit' value='Delete'/> <br />";

	print '</form>';

?>
function getDeleteCustomer($id){
	$sql=mysql_query("delete * from customer where customerid ='".$id."'");
	$row=mysql_fetch_array($sql);
	return $row; 
}

Your delete syntax looks off, move your where clause and in the getDeleteCustomer remove the "*". Here is a link to proper delete from syntax.

delete from customer  where       
 CustomerName='$cname' and 
 CustomerAddress='$cusadd1' and
  CustomerAddress1='$cusadd2' and
  CustomerAddress2='$cusadd3' and
  County='$ccounty' and
  CustomerPostCode='$custpc' and
  CustomerTelNo='$custele' and
  CustomerEmail='$cusemail' and 
  customerid=$cid
function getDeleteCustomer($id){
	$sql=mysql_query("delete from customer where customerid ='".$id."'");
	$row=mysql_fetch_array($sql);
	return $row; 
}

If you customerid is unique you can simplify the first to:

delete from customer  where customerid=$cid

thanks scappedcola for your advice but i figured out where the problems was. thanks tho

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.