Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate Query clearing results through PHP
    text
    copied!<p>I'm developing under my development machine in PHP and connecting to the database remotly. I uploaded the files to the server and online the query works as expected but in localhost it doesn't. All other queries work!</p> <p>I have a block of code to insert a new record at the database or update if it already exists.</p> <p>The code is:</p> <pre><code> $name = mysql_real_escape_string($_REQUEST['name']); $title = mysql_real_escape_string($_REQUEST['title']); $content = $_REQUEST['content']; $lang_drop = mysql_real_escape_string($_REQUEST['lang']); if($uid == 0) { $maxSort = tools::getInfo($table, Array(), Array('MAX(sort_order) as sort_order')); $maxSort = $maxSort[0]['sort_order']+1; $sql="insert into quemsomos (title,name,lang,sort_order) values( '$title', '$name', '$lang_drop', $maxSort )"; echo $sql; mysql_query($sql); $uid = mysql_insert_id(); } else{ $maxSort = $data['sort_order']; $sql="update `quemsomos` set `title`='blabkalm', `name`='{$name}', `lang`='{$lang_drop}', `sort_order`=$maxSort where `uid`={$uid}"; mysql_query($sql); echo $sql; } </code></pre> <p>Pretty simple... If I insert a new record it works fine and $sql value printed is:</p> <pre><code>insert into quemsomos (title,name,lang,sort_order) values('title412', 'name421', 'pt', 3 ) </code></pre> <p>The problem is that when I update the query executes but only the hardcoded values are stored in database. I mean, after the bellow update all values in the DB are empty except for sort_order which is saved and title (because it's hardcoded... if i place the right variable the field gets blank also)</p> <p>echo $sql for the update statement returns the following:</p> <pre><code>update `quemsomos` set `title`='blabkalm', `name`='name421', `lang`='pt', `sort_order`=3 where `uid`=2 </code></pre> <p>As you can see all values are there and if I run this query manually all works out fine...</p> <p>Does this make sense to anyone?</p>
 

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