php - error on every sql query with mysqli -


i created new empty php file simple function mysqli query, this:

$dab = new mysqli($dbhost,$dbuser,$dbpassword,$dbdbname);  function dbq($sql) {     global $dab;     $wynik= $dab->query($sql);     if (!$wynik) {           printf("errormessage: %s\n", $dab->error);      }     return $wynik; } dbq('set character set utf8'); dbq('set collation_connection = utf8_general_ci');  

on every query i'm getting blank errormessage , don't know cause here.

script connecting database without errors. when performed looped query, recieved blank errormessage each repeat.

  1. you ought set proper php error reporting in order see php errors
  2. you have verify connect errors.
  3. you shouldn't echo errors out unconditionally.
  4. oh, , have set charset using right method

so, code be

error_reporting(e_all); ini_set('display_errors',1);  $dab = new mysqli($dbhost,$dbuser,$dbpassword,$dbdbname); if ( !$dab ) {     throw new exception(mysqli_connect_error()); } if (!$dab->set_charset('utf8')) {     throw new exception($dab->error); }  function dbq($sql) {     global $dab;     $wynik= $dab->query($sql);     if (!$wynik) {         throw new exception($dab->error);     }     return $wynik; } 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -