I keep getting the following error and cant seem to figure out where I'm going wrong with the code and have tried changing it but just seem to make is worse wonder could someone please help me, the code i am using is as follows:

this is the code for deleteCus.php

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


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

print $str;
mysql_query($str);





?>
This is code that i am using wit AJAX in it


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registeration</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="JSFunctions.js"/>
<script src="../includes/ice/ice.js" type="text/javascript"></script>
</script>

<style type="text/css">
#container #main centre {
	text-align: center;
}
</style>
</head>
</html>

<body>
<div id="container" ice:editable="*">
	<div id="top">
    
    	<div id="logo">
        	<h1>Small Business Database    </h1>
      </div>
        
</tr>
</table>          
  </div>
<div id="navigation">
			<div id="nav">
              <div align="center">
                <table>
                  <td>
                    <tr><a href="home.php"><em></em> Homepage</a></tr>
                  <tr><a href="Products.php"><em></em>Products</a></tr>
                  <tr><a href="Orders.php"><em></em>Orders</a></tr>
                  <tr><a href="Invoices.php"><em></em>Invoices</a></tr>
                  <tr><a href="Suppliers.php"><em></em>Suppliers</a></tr>
                  </td>
                </table>
              </div>
			</div>
			<div id="subnav">
       		  <div align="justify">
       		    <ul class="dropdown">
       		      <li> <a href="Customer.php">Customers</a>
       		        <ul class="sub_menu">
       		          <li><a href="Customer_add.php">Add</a></li>
       		          <li><a href="edCustomer.php">Edit</a></li>
       		          <li><a href="deleteCustomer.php">Delete</a></li>
       		          <li><a href="">Lookup</a></li>
   		            </ul>
   		          </li>
       		      <li> <a href="Products.php">Products</a>
       		        <ul class="sub_menu">
       		          <li><a href="Products_add.php">Add</a></li>
       		          <li><a href="Products_edit.php">Edit</a></li>
       		          <li><a href="Products_delete.php">Delete</a></li>
       		          <li><a href="Products_lookup.php">Lookup</a></li>
   		            </ul>
   		          </li>
       		      <li> <a href="Invoice.php">Invoices</a>
       		        <ul class="sub_menu">
       		          <li><a href="Invoice_add.php">Add</a></li>
       		          <li><a href="Invoice_edit.php">Edit</a></li>
       		          <li><a href="Invoice_delete.php">Delete</a></li>
       		          <li><a href="Invoice_lookup.php">Lookup</a></li>
   		            </ul>
   		          </li>
   		        </ul>
       		  </div>
			</div>        
	  </div>
</div>
<p><!-- close top--><!--/main-->
  </div>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div align="left" id="page-wrap">
  <p>Delete Customer Form </p>
  <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
  <script>
$(document).ready(function(){
	

	$("#customer").change(function()
	{
	
		var id=$(this).val();
		var dataString = 'id='+ id;
		$.ajax
		({
			type: 'POST',url:'DelDetails.php',data: dataString,	cache: false,success: function(html)
			{				
				$('.details').html(html);			
			}
		});
	

 
	});
});

  </script>
  <form method="post" name ="theForm" id="theForm"  >
    <table width='797' height="45" id='details'>
      <tr>
        <td width="789" colspan="2"><select name='cusname' id='customer' >
          <?php customerList(); ?>
        </select>
          <input type='button' value='Select Customer' name='submit' id='submit' /></td>
      </tr>
    </table>
  </form>
  <br/>
  <div id="details" class="details"></div>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<?php
include("functions.php");

	$id=$_POST['id'];
    $myArray=array();
    $myArray=getCustomerDetails($id);
	
	
	print "<form method='POST' action='deleteCus.php'>";
	
	
	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[6] '></input></td></tr>";
	print "<tr><td>Postcode</td><td><input name='cpostcode' type='text' size=30 value='$myArray[5] '></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' onSubmit alert('Are you Sure you want to Delete This Customer')/> <br />";

	print "</form>";

?>
<?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="select * from CustomerName='$cname',CustomerAddress='$cusadd1',CustomerAddress1='$cusadd2',CustomerAddress2='$cusadd3',County='$ccounty',CustomerPostCode='$custpc',CustomerTelNo='$custele',CustomerEmail='$cusemail' where customerid=$cid";

print $str;
mysql_query($str);




?>
Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80

the error is:

( ! ) Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on line 6
Call Stack
#	Time	Memory	Function	Location
1	0.0008	676088	{main}( )	..\deleteCus.php:0

delete from customer where customerid =
Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80

In the first file $cid is never defined.
I think you mean $_POST instead of just $cid?

Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80

yea it should be, i'm after changing it there now but still getting the same error!!!!

Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80

check your code by replacing your line 8 with this.....

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

If it's fine then ok...otherwise ....before line 8 add this line and see what's your output.....

echo $_POST['cid'];
Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80

thanks a million tomato.pgn that worked!!! :D

Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80

Mark solved if its solved.

Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80

Welcome...i am always their to help others.....:)

Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80
<?php
include("config.php");
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$q=$_POST['q'];
$q=mysql_real_escape_string($q);
$q_fix=str_replace(" ","%",$q); // Space replacing with %
$result=mysql_query("SELECT title FROM articles WHERE title LIKE '%$q_fix%'");
}
?>
<html>
<body>
<form method="post" action="">
<input type="text" name="q" /> <input type="submit" value=" Search " />
</form>

<?php 
while($row = mysqli_fetch_array($result))
{
$title=$row['title'];
echo '<div>'.$title.'</div>';
}
?>
</body>
</html>

Notice: Undefined variable: result in C:\wamp\www\myfirst_samp\search.php on line 19

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\wamp\www\myfirst_samp\search.php on line 19

Please help me...

Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80

I'm getting result without error after submitting...
But, before searching i am getting that error,

Re: error: Notice: Undefined variable: cid in C:\wamp\www\Engineering\deleteCus.php on li 80 80
Member Avatar

Consider a new thread next time as this is unrelated to the original post.
ANyway,

You are trying to refrence $result, even if a POST has not been made as the following will run regardless:

<?php 
while($row = mysqli_fetch_array($result))
{
    $title=$row['title'];
    echo '<div>'.$title.'</div>';
}
?>
Be a part of the DaniWeb community

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