Yes it does.Taken from here: http://dev.mysql.com/doc/refman/5.0/en/update.htmlUPDATE returns the number of rows that were actually changed. The mysql_info() C API function returns the number of rows that were matched and updated and the number of warnings that occurred during the UPDATE.
mysql_num_rows is only used for commands like SELECT or SHOW. Use mysql_affected_rows() instead.
See here: http://www.php.net/mysql_num_rows
And here: http://www.php.net/manual/en/functio...ected-rows.php
So that line would change from:toPHP Code:
$num_result = mysql_num_rows($result);
But I'm no php expert.PHP Code:
$num_result = mysql_affected_rows();
Let me know if it works.
"The best software is the one that fits your needs." - A_A
Virus free since: date unknown
Anti-virus free since: August 2008
why y'all goin round the problem.
youngster, your LIMIT is the problem, the only reason you should try to do this is if there are more than one row in the table with ipc = 123 (etc.). by the looks of it you trying to make the update affect only one row.
the way to do that is make ipc a (primary) key of the table. if thats already done, then theres no need for LIMIT.
lay that aside, LIMIT as i have come to know it is used to control output of SELECT queries. so your query is flawed by having LIMIT in an UPDATE query, JUST REMOVE IT.
also theres quotes around your '$ipc' which indicates its character data, remove that if its numeric.Code:$query = "UPDATE ipcinfo SET active ='$active' WHERE ipc ='$ipc'";
Last edited by icymint3; Dec 12, 2006 at 09:22 PM.
Cultured in Aggression and Koding like a Warrior!!
“Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
"The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein
thanks very much you all . will try them all and hopefully something will work. Sometimes the simplest of things take the longest to do.
"...men are that they might have joy."
Nephi
Well you all i have tried what you all said by using the id instead of ipc and $num_result = mysql_affected_rows() instaed of $num_result = mysql_num_rows($result). However this is what turned up:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 4' at line 1"
here is the full block of code:
PHP Code:
<?php
include_once("conn.php");
$active = ($_GET["active"]);
$id = ($_GET["id"]);
// This is the SQL statement that will update the appropriate table in the database
$query = "UPDATE ipcinfo SET active = $active, WHERE id = $id";
if (!$result = mysql_query($query)) {
die(mysql_error());
}
$num_result = mysql_affected_rows($result);
/* This just gets the number of rows in the Query - It's just a check to see if the ipc exists - If not it echos out an error statement. */
// If the number of rows is not equal to one then it echos out an error statement
if ($num_result == 1) {
if($row = mysql_fetch_array($result));
echo"success= 1";
echo"active=$active";
}
else
{
echo( "success=0" );
}
// Clean up
mysql_close($dblink);
?>
Last edited by Arch_Angel; Dec 13, 2006 at 09:30 AM. Reason: added PHP code formatting
"...men are that they might have joy."
Nephi
ok i am going to try it again.
"...men are that they might have joy."
Nephi
i am now getting this error:
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/www/someurl on line 12
success=0
WHY SOMETHING SO SIMPLE IS SO HARD TO DO.
Last edited by leocrawf; Dec 13, 2006 at 09:52 AM.
"...men are that they might have joy."
Nephi
Ok this is what i discovered. The field is actually updating now(thank goodness) but i am still getting the error.
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/www/mobilenoni.com/someurl on line 12
success=0
this is line 12:$num_result = mysql_affected_rows($result);
"...men are that they might have joy."
Nephi