-1

When I use

mysql_affected_rows($result);

...in php then I get below warning how to remove it?

Warning: mysql_affected_rows(): supplied resource is not a valid MySQL-Link resource in C:\wamp\www\st_db_1\search_db.php on line 60

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
ravi
  • 109
  • 2
  • 4
  • 13
  • 2
    I'm afraid you will need to show us more code than that to get a reasonable answer. The reason it's happening is because $result is not a valid MySQL link resource (so if it's being set to the return value of mysql_query(), then perhaps the query you are running is incorrect causing mysql_query to return false instead). – Nils Luxton May 21 '11 at 06:34
  • I'm assuming, from what I've experienced recently, that either what's inside $result is not what is expected, or that there's actually nothing inside $result. Could you please provide more info? – βӔḺṪẶⱫŌŔ May 21 '11 at 06:35
  • $query = "INSERT INTO `$clas` (`adm_no`, `adm_dt`, `name`, `dob`, `f_name`, `f_office`, `f_o_no`, `m_name`, `m_office`, `addr`, `pho_no`,`id`) VALUES ('$_SESSION[adm_no]', '$adm_dt', '$name', '$dob', '$f_name', '$f_office', '$f_o_no', '$m_name', '$m_office', '$addr', '$pho_no', '1');"; $result = mysql_query($query, $connection); – ravi May 21 '11 at 06:45
  • Please read this question - http://stackoverflow.com/questions/332365/xkcd-sql-injection-please-explain – El Yobo May 21 '11 at 07:37
  • You have an error in your query, if you want some real help, provide the query in your question – Ibu May 21 '11 at 07:40

4 Answers4

1

I assume $result = mysql_query() ??

Don't pass it that variable, you can pass it the connection link $variable or just use mysql_affected_rows();

0xAli
  • 1,059
  • 10
  • 22
1

$result must be the link identifier not the query example

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');

// will return for the most recent connection
echo mysql_affected_rows();

// will return for $link connection defined 2 rows up
echo mysql_affected_rows($link);
nico
  • 50,859
  • 17
  • 87
  • 112
Andrei Stanca
  • 908
  • 2
  • 11
  • 26
1
if($result)
{
    mysql_affected_rows($result);

}
Pradeep Singh
  • 3,582
  • 3
  • 29
  • 42
0

Your query did not produce a valid result.
Try echo mysql_error() before calling mysql_affected_rows().

gnur
  • 4,671
  • 2
  • 20
  • 33