开发者

mySql Delete only removes the data not the entire entry

开发者 https://www.devze.com 2022-12-25 19:33 出处:网络
Hi all I开发者_如何转开发 have this line in my php code `$insert = "DELETE FROM allocation_table WHERE job = \'$jobnumber\' " ;

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 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 http://img34.imageshack.us/img34/4431/tablenj.jpg


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>';
}


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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消