11-16-2008, 04:33 AM
|
#1 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
Can you use IGNORE in the update of a mysql row ?
so yeah i am working on my news system so i am doing in the edit part that if someone lets say posted "R" as title then ok posted done, but if it has the
R already in recored then IGNORE, it , this works create in when posting something but have not tested in delete or update before :S
The code "Not working,.. Something i am not doing right ?, please let me know :P as i said never tried on update or delete..";
PHP Code:
function editnews($sname, $uname, $story) {
$sql = sprintf(" UPDATE IGNORE
`news`
SET
`sname` = '%s',
`uname` = '%s',
`story` = '%s',
`pdate` = NOW()",
mysql_real_escape_string($sname),
mysql_real_escape_string($uname),
mysql_real_escape_string($story));
$res = mysql_query($sql) or die(mysql_error());
if(!mysql_affected_rows())
{
echo 'The Name: '.$sname.' is already taken!';
exit;
}
if ($res) {
echo "News Post Has Been Updated!";
} else {
echo "News post could not be updated.";
}
return $res;
}
Thank you!

|
|
|
|