Forum Moderators: coopster

Message Too Old, No Replies

MySql updating time...

What's wrong?

         

rokec

7:40 pm on Jan 9, 2007 (gmt 0)

10+ Year Member



First I update base:

mysql_query("UPDATE armoury SET number = '1' WHERE id = '".$fdatabase[id]."'") or die(mysql_error());

And then i read number:

echo(mysql_fetch_array(mysql_query("SELECT number FROM armoury WHERE id = '$fdatabase[id]'"))); //results 0

And when I refresh page this code normally results 1.

What's worng? I think long database updating time is the reason.

Any help would solve all my problems.

eelixduppy

9:13 pm on Jan 9, 2007 (gmt 0)



I would first split this up and add some error handling:

$result = mysql_query("SELECT number FROM armoury WHERE id = '".$fdatabase['id']."'") or die(mysql_error());
$row = mysql_fetch_array($result);
echo '<pre>';
print_r($row);
echo '</pre>';

This should be a good start in discovering the problem as I fixed some errors ;)

rokec

5:17 am on Jan 10, 2007 (gmt 0)

10+ Year Member



No, problem is that mysql reads old value first, and then right value after you refresh page...

eelixduppy

5:28 am on Jan 10, 2007 (gmt 0)



I'm sorry. Looks like I misunderstood your question. Everything should work fine as you have it (except for those errors that I fixed) however the only thing I am unsure about is $fdatabase[id], as I have no idea where this value is coming from.

There is something wrong with your logic here, because if this is done correctly it will work as you want. Check the value of $fdatabase[id] before each query and also make sure that that unique id actually exists.

rokec

2:14 pm on Jan 10, 2007 (gmt 0)

10+ Year Member



$fdatabase[id] is equal to 1. $fdatabase is just an array set before:

$id=1;
$fdatabase[$id]=1;

Psychopsia

4:41 pm on Jan 10, 2007 (gmt 0)

10+ Year Member



As I can see, add the var symbol to ID

... WHERE id = '" . $fdatabase[$id] . "'" ...

[edited by: Psychopsia at 4:42 pm (utc) on Jan. 10, 2007]

rokec

5:09 pm on Jan 10, 2007 (gmt 0)

10+ Year Member



It is OK, i did but the problem is still the same...

Just to mention, I'm sending data via POST.

rokec

5:50 pm on Jan 10, 2007 (gmt 0)

10+ Year Member



I got it, thanks for help.