ZaphodQB Posted June 4, 2008 Share Posted June 4, 2008 Running PHP Version 5.2.5 case "deleteprefix"; $Query = "update prefixes set status = -1 where id = '107' AND status > -1"; $Result = mysql_query ($Query, $Connection) or die("Prefix update query failed : ".mysql_error($Connection)); $updateCounter=mysql_affected_rows($Result); echo "updateCounter = $updateCounter"; if($updateCounter){change_counter("vails","prefixcount",1,$tempVailData['id']);} break; There are no errors being returned. CREATE TABLE `prefixes` ( `id` bigint(20) unsigned NOT NULL auto_increment, `vail` bigint(20) unsigned NOT NULL default '0', `text` varchar(32) collate latin1_general_ci NOT NULL default '', `status` tinyint(4) NOT NULL default '0', `key` varchar(32) collate latin1_general_ci NOT NULL default '', PRIMARY KEY (`id`), KEY `text` (`text`), KEY `vail` (`vail`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=118 ; The query sets a status column in the prefixes table to -1 for the row with the id(primary key) of 107. This works and I can look in the database and see that the column has been changed from a 1 to a -1. But the mysql_affected_rows($Result) statement does not appear to be returning a value into the $updateCounter (flag) veriable. Output from the echo is "updateCounter =" (nothing in there) So the line that is supposed to call the function change_counter() never calls. What kind of simple misunderstanding am I operating under here, that is causing this simple step to fail? Thanks for your time. Quote Link to comment Share on other sites More sharing options...
hvle Posted June 4, 2008 Share Posted June 4, 2008 mysql_affected_rows([$database_link]) ; I think it won't work correctly because you passed in $Result, which is not a database link. try $updateCounter = mysql_affected_rows($Connection); or maybe just $updateCounter = mysql_affected_rows(); Quote Link to comment Share on other sites More sharing options...
ZaphodQB Posted June 4, 2008 Author Share Posted June 4, 2008 Thank you I knew I was doing something stupid, but my brain is fried and I could not figure out what it was. I had to pas it the Connection resource! Thanks works like it's suposed to now! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 4, 2008 Share Posted June 4, 2008 The original code was probably generating a php error. When developing php code or debugging php code, always set php error_reporting to E_ALL and display_errors on to get php to help you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.