Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange MySQL/PHP issue: mysql query does not execute and there is no error
    primarykey
    data
    text
    <p>I ran into a strange bug in my PHP web app that I'm unable to sort out. The php script fetches a row from the database, it processes it and serializes a new query and writes back the row to the database.</p> <p>I copied the code that does this:</p> <pre><code>foreach($a as $key =&gt; $value) { $a[$key]="'".mysql_real_escape_string($value)."'"; } $a['lastUpdate']="$when"; //assembling request $assignments=array(); foreach($a as $key =&gt; $value) { $assignments[]="$key=$value"; } $q="UPDATE wtfb2_villages SET ".implode(',',$assignments)." WHERE (id=${a['id']})"; logText($q); logText(mysql_error()); $r=mysql_query($q) or die(__FILE__.':'.__LINE__.':'.mysql_error().':'.$q); logText(mysql_affected_rows()); logText('Mysql error in query is: '.mysql_error()."\n"); </code></pre> <p>That UPDATE seemingly executes. mysql_error() gives an empty string. mysql_affected_rows says 1 just like when everything is done. But if I look into the table using phpmyadmin I saw that nothing is changed.</p> <p>I logged the query itself its:</p> <pre><code>UPDATE wtfb2_villages SET id='22',ownerId='56',villageName='Új falu',x='0',y='1',buildPoints='7.2226273148149',barracksLevel='0',archeryRangeLevel='0',stablesLevel='0',workshopLevel='0',townHallLevel='0',blacksmithLevel='0',goldmineLevel='1',wallLevel='0',spearmen='0',archers='0',knights='0',catapults='0',diplomats='0',spearmanLevel='0',archerLevel='0',knightLevel='0',catapultLevel='0',spearmenTraining='0',archersTraining='0',knightsTraining='0',catapultsTraining='0',diplomatsTraining='0',lastUpdate='2011-01-18 21:56:10' WHERE (id='22') </code></pre> <p>If I just copy-paste this query directly into the phpmyadmin it executes it and I see the result in the table.</p> <p>The table is using myIsam engine. So no transactions or anythin such.</p> <p>I got stuck at this problem more than 2 hours and I'm unable to find out what's going on.</p> <p>This is the only one query that does this. queries before and after this one executing properly.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload