Php Help
Author
Discussion

Robatr0n

Original Poster:

12,362 posts

246 months

Monday 10th April 2006
quotequote all
Ok abit of a long shot here, but any help is appreciated. I'm currently making a php and MySQL database for my final year project AND a company that has expressed interest.

I have been fine up until now. I am having problems deleting records from tables in my Database.

I have the following code:


<?php
$connection = @mySql_connect('localhost','root','');
If (!$connection) {
echo '<p><b>Unable to connect to the database at this time!</b></p>';
exit();
}

$Supplier_ID=$_POST["Supplier_ID"];
$Name=$_POST["Name"];
$Address=$_POST["Address"];
$Contact_Details=$_POST["Contact_Details"];

@mysql_select_db('Grainword');

$sql="DELETE Supplier VALUES
Name='$Name',
Address='$Address',
Contact_Details='$Contact_Details'
WHERE Supplier_ID='$Supplier_ID'";

if (@mysql_query($sql)) {
echo '<p>Updated</p>';
} else {
echo '<p>Error Deleting Supplier Record</p>';
}

?>


The connection is fine to the database, all the fields are correctly spelt in relation to the database and the primary key is also correct.

This is alot like my add function to the database except with this delete function I beleive there is a problem deleting the primary key (Supplier_ID) which is why I have a WHERE clause.

Currently I am stumped, I know I'm not far wrong but I cannot see where I am going wrong.I am currently receiving the message "Error Deleting Supplier Record".

Any help is greatly appreciated.

fredf

267 posts

263 months

Monday 10th April 2006
quotequote all
I'm no sql expert, but shouldn't you be doing:

DELETE FROM Supplier WHERE Supplier_ID='$Supplier_ID'

Robatr0n

Original Poster:

12,362 posts

246 months

Monday 10th April 2006
quotequote all
You sir, are a genius!

I have been practically tearing my hair out over this one. Thank you!!