Issue with the debugging in php -


i running aphpscript have while loop , file writings make take time.the problem comes when doesn 't seems print errors @ run time prints them after complete execution of script, , error in loop repeat every time loop , cost me lot of time. using wamp server version 2.2 .
here sample code

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="algorithm" content="text/html; charset=utf-8" /> <title>delta compression</title> </head> <body>  <?php //db connection $dbuser = "root"; $dbpass = ""; $dbname = "delta_compression"; $dbhost = "localhost";  //database connection $con = mysql_connect($dbhost,$dbuser,$dbpass); if (!$con) { die('could not connect: ' . mysql_error()); }  mysql_select_db($dbname, $con); echo "database connected !";  //variable declaration  $file="flag_track.txt"; $result=mysql_query("select * d_5"); $total_rows=mysql_num_rows($result); $limit=256;  while($i < $total_rows){     //increasing time limit      set_time_limit(0);     //getting value row of reading     $reading=mysql_result($result,$i,'reading');     //if first flag set          if(!(firstflag())) {             delta();             }     //convert decimal binary , store in db      if(savedelta(decbin($diffrence))== flase){         echo"error saving data in db";          }     } function delta(){          $delta=$flag-$reading;         file_put_contents ($file, $flag."<br>".$delta, file_append)."<br>";                      if( $delta > $limit){                 $flag=$reading;                 file_put_contents ($file, $flag."<br/>".$delta,     file_append)."<br>";                  } }  function firstflag(){ if($flag == null){         //set flag         $flag=$reading;         //saving flag          file_put_contents ($file, $flag, file_append)."<br>";         return true;         }         else {  return false; } }   function savedelta($dif) {  if(mysql_query("insert e_x_1 (delta_of_reading) values ('b" . $dif . "')")){ return true; //on success } else { return false; //on failure }  } ?>  </body> </html> 

the error in statement

mysql_query("insert e_x_1 (delta_of_reading) values (b'$dif')"); 

it should like:

mysql_query("insert e_x_1 (delta_of_reading) values ('b" . $dif . "')");  //i don't know if want `b` there or error 

and since function savedelta($dif) called inside while loop print error multiple times. can return error code , check successful execution of query.

function savedelta($dif) {    if(   mysql_query("insert e_x_1 (delta_of_reading) values ('b" . $dif . "')") ){     return true; //on success   } else {     return false; //on failure   }  } 

and in while loop check as:

if( savedelta(decbin($diffrence) === false ){   //print error , return or whatever }  

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -