Hi Cpt,

That's not the exact code.  The exact code is below.  Multiple workers
are being selected from a MULTIPLE <select> form field.  I just use a
while loop do go through the selected ones to delete them individually.

PHP Version: 4.3.4
MySQL Version: 4.0.17

$i="0";
while ($i <= "$selected") {
        $delete_assignment = mysql_query("DELETE FROM webprojectassign WHERE
workerid='$assigned[$i]'");
        $i++;
}
if (mysql_affected_rows($delete_assignment) < "1") {
        $tpl->newBlock('message');
        $tpl->assign("message","<b>ERROR:</b> There was an error deleting those
workers from the project.");
}
else {
        $tpl->newBlock('message');
        $tpl->assign("message","The workers have been deleted from the
project.");
}

If you (or anyone else) know of another way I should be doing this,
please let me know.  I'm open to any suggestions.

Best Regards,
--
Tyler Longren
J.D. Web Services, L.C.


On Tue, 2004-01-06 at 15:14, CPT John W. Holmes wrote:
> From: "Tyler Longren" <[EMAIL PROTECTED]>
> 
> > I don't think mysql_affected_rows() is working like it should for me.
> > In the manual for mysql_affected_rows() it has this (Example 1):
> >
> > /* this should return the correct numbers of deleted records */
> >    mysql_query("DELETE FROM mytable WHERE id < 10");
> >    printf("Records deleted: %d\n", mysql_affected_rows());
> >
> > However, when I do this:
> > $delete_assignment = mysql_query("DELETE FROM consultingprojectassign
> > WHERE workerid='$assigned[$i]'");
> > printf("Records deleted: %d\n", mysql_affected_rows());
> >
> > It always says "Records deleted: 0".  Even though the record was,
> > indeed, deleted.  I have an if statement also that says if
> > mysql_affected_rows() < "1", then print an error message.  Well, since
> > it always returns 0, no matter what, the error is always shown, even
> > when the record is deleted.
> 
> I can't see a reason why that wouldn't work. Is that your exact code, i.e.
> you're not doing anything else between the mysql_query() call and the
> mysql_affected_rows() call? What versions of PHP/MySQL are you using?
> 
> ---John Holmes...
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to