Jump to content

[SOLVED] mysql_affected_rows not returning affected row count


ZaphodQB

Recommended Posts

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.

Link to comment
Share on other sites

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();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.