views:

66

answers:

3

Hi all I have this line in my php code

 `$insert = "DELETE FROM allocation_table WHERE job = '$jobnumber' " ;
  Mysql_query ($insert) ;`

The problem is it will remove all the values from the the one line in my table but not the entry itself. as you can see in the picture if I delete where job = 315 , it does not delete the line but does delete all the entries

Yet in this code that preceeds it (a different table) . it works fine and the whole line is removed

$insert = "DELETE FROM event WHERE jobnumber = '$jobnumber' " ; 
mysql_query ($insert) ;enter code here

can anyone offer some advice please ?? alt text

A: 

Do you have any error handling routines in your code?
You might also want to add some debug output (or even better use a debugger like xdebug)
(oversimplified) example:

$insert = "DELETE FROM allocation_table WHERE job = '$jobnumber' " ;
echo '<pre>Debug: query=', htmlspecialchars($insert), '</pre>';
$rc = mysql_query($insert);
if ( !$rc ) {
  echo '<pre>mysql_query failed: ', mysql_error(), '</pre>';
}
else {
  echo '<pre>Debug: affected rows=', mysql_affected_rows(), '</pre>';
}

$insert = "DELETE FROM event WHERE jobnumber = '$jobnumber' " ; 
echo '<pre>Debug: query=', htmlspecialchars($insert), '</pre>';
$rc = mysql_query($insert);
if ( !$rc ) {
  echo '<pre>mysql_query failed: ', mysql_error(), '</pre>';
}
else {
  echo '<pre>Debug: affected rows=', mysql_affected_rows(), '</pre>';
}
VolkerK
Yes i do (removed for clarity though) but either way the entry is not removed just the data thanks
Mick
A: 

Maybe you have some weird setting on your MySQL table that is causing the query to function differently. Did you create the table yourself (with PMA?) or import it from somewhere else?

When you delete using PHPMyAdmin, what is the query that it runs?

Austin
A: 

Try deleting in PhpMyAdmin and see what happens. At least there you'll be able to easily see any error message.

Do you have foreign keys defined and/or table constraints?

pocketfullofcheese