Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql query not working no error ot anything

      $result53543534 = mysql_query("UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'")
or die(mysql_error());

But does not update. checked $battle_get['username'] and the username is in there. i am not getting any errors or anything just not adding...

Any help would be very nice thanks in advance

like image 928
nick Avatar asked May 31 '11 17:05

nick


People also ask

What does != Mean in MySQL?

The symbol <> in MySQL is same as not equal to operator (!=). Both gives the result in boolean or tinyint(1). If the condition becomes true, then the result will be 1 otherwise 0. Case 1 − Using != operator.

Is not condition in MySQL?

Description. The MySQL NOT Condition (also called the NOT Operator) is used to negate a condition in a SELECT, INSERT, UPDATE, or DELETE statement.

Why is my update query not working?

If your MS Access update query fails to change the table's data, then the very first thing you need to check is; Whether the underlying Access table is updatable or not. To check this, you just need to open your Access table and try to edit the fields manually.

Can you use != In MySQL?

In MySQL, you can use the <> or != operators to test for inequality in a query. For example, we could test for inequality using the <> operator, as follows: SELECT * FROM contacts WHERE last_name <> 'Johnson';


1 Answers

See what the result from mysql_affected_rows() is:

if ( ! $result53543534 = mysql_query( "UPDATE users SET credit=credit+1 WHERE email= '{$battle_get['username']}'") ) {
    die( mysql_error() );
} else {
    echo "Number of rows affected: " . mysql_affected_rows() . "<br>";
}

I may not have the syntax completely right but I hope you get the idea. If the result is 0, you're not specifying the WHERE syntax so that it actually refers to any row(s).

If the result is greater than 0, then you're mistaken if you think it's not affecting any rows. It may not be affecting the rows you think it should, but that's another issue.

Also, echo your sql statement so you can actually see exactly what it's doing.

like image 80
user151841 Avatar answered Sep 29 '22 09:09

user151841