» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2006, 02:04 PM
zizu zizu is offline
Junior Member
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
zizu is on a distinguished road
Default Mysql_affected_rows() isn't working on a delete query?

Code:
if (!empty($delete)) {
$query = "DELETE FROM items WHERE id=" . $delete;
$result = @mysql_query($query);
if (mysql_affected_rows($result) == 1) {
echo "Deleted";
}
}

It's weird. The delete query works and succesfully deletes the item, but it says "Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in code.php" and it doesn't say "deleted" even though it was succesfully deleted from the database.

If I do "if ($result)" then it says "Deleted" whenever it succesfully runs the query, which doesn't necessarily means it deleted one.

The one way I can see around this is running a select query before deleting it.

edit: Well I ended up doing that (adding select query before). You can delete this now. -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-26-2006, 02:05 PM
jacques jacques is offline
OSP Starters
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jacques is on a distinguished road
Default

You need to pass the database connection resource, not the query resource. Or you can not pass any arguments and it will default to the last used connection:

http://us2.php.net/manual/en/functi...fected-rows.php -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Working on internet, Work at home moms, Intresting !! alex General Talk 14 11-01-2006 01:58 AM
On Delete Cascade.....!!!!! ingo MySQL Forums 2 09-18-2006 07:21 AM
working with Dates gazelle ASP forums and Tips 2 08-26-2006 01:48 PM
to delete old sessions. Leon MySQL Forums 1 08-03-2006 09:20 AM
Query works on production but not on testing server parore MySQL Forums 1 07-31-2006 03:11 PM


All times are GMT. The time now is 12:10 PM.