PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$result=mysql_query("UPDATE sspp SET nname='$nname' AND email='$email' WHERE id='$id'");
if (result=="TRUE") {
echo "Successfully changed account with ID:$id. <a href="index.php?action=cpanel">Click here to continue.</a>";
} else {
echo "Update did not complete succesfully. <a href="index.php?action=cpanel">Click here to continue.</a>";
}
It always comes up with Update did not complete succesfully. Can anyone help me?
$query = "UPDATE sspp SET nname='$nname' AND email='$email' WHERE id='$id'");
$result=mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result))
{
echo "Successfully changed account with ID:$id. <a href="index.php?action=cpanel">Click here to continue.</a>";
exit;
}
else
{
echo "Update did not complete succesfully. <a href="index.php?action=cpanel">Click here to continue.</a>";
exit;
}
[php_man]mysql_affected_rows[/php_man] wrote:mysql_affected_rows() returns the number of rows affected by the last INSERT, UPDATE or DELETE query associated with link_identifier. If the link identifier isn't specified, the last link opened by mysql_connect() is assumed.
[php_man]mysql_num_rows[/php_man] wrote:mysql_num_rows() returns the number of rows in a result set. This command is only valid for SELECT statements. To retrieve the number of rows affected by a INSERT, UPDATE or DELETE query, use mysql_affected_rows().
Only for SELECT,SHOW,EXPLAIN or DESCRIBE statements mysql_query() returns a resource identifier or FALSE if the query was not executed correctly. For other type of SQL statements, mysql_query() returns TRUE on success and FALSE on error. A non-FALSE return value means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows.
It'll return the value true.. not the string true.