mysql update doesn't work before using header() on php -


i have code here, send numeric value database. php code:

<?php $ctr =1 <form method = 'post'> $radio =$ctr; <input type 'radio' name = '$radio[ctr]' /> $ctr++; <input type ='submit' name='submit'>  </form>  if(isset($_post['submit'])) { for($ctr=1; $ctr<$countme; $ctr++) { score++; } enter code here $insert = mysql_query("update `tblname` set `score` = '".$score."' number = '$number'); if ($insert){ header('location:somefile.php');} } ?> 

now problem is, update query seems not working, header() work insert 0 value database. i'd tried changing header() echo statement , database updated right value.

what think problem? code doesn't return error. in advance.

this not correction, creation… <?php?> code should @ top of page, because header() no output if printed on page.

also, you're missing mysql_connect(), aware of that? , finally, not secure php, careful.

<?php if(isset($_post['submit'])) {      $score = 0;     foreach ($_post['radio'] $id => $value) {         $value == true , $score++;     }      // mysql_connect();     $insert = mysql_query("update `tblname` set `score` = '{$score}' `number` = {$number}");      if ( $insert ) {         header('location:somefile.php');     }  } ?>   <form method="post">     <input type="radio" name="radio[]" />     <input type="submit" name="submit" /> </form> 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -