mysqli - Why query not working in from my php -
i have query, , have database. when query in dbforge(mysql) got result. when php, got nothing. can't understand why? if write query simple "select * table id = 1", working. below code:
<?php $conn = mysqli_connect("localhost", "username", "pass", "db"); ini_set('max_execution_time', 300); if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit(); } mysqli_query($conn, "set character set utf8 "); $result = mysqli_query($conn, "select distinct level_two reportls._report_sales_report level_one = 'Музыка'"); if($result == false) { die('invalid query: '.mysqli_error($conn)); echo "error"; } while ($data = mysqli_fetch_row($result)) { if(!empty($data[0])) $sendback = $sendback."<option value=\"$data[0]\">$data[0]</option>"; } echo ($sendback); $sendback = ''; mysqli_free_result($result); ?>
this code return nothing. if paste query dbforge, returns rows. me, or write hits? wrote not correct?
you can try when set charset utf8
/* change character set utf8 */ if (!$mysqli->set_charset("utf8")) { printf("error loading character set utf8: %s\n", $mysqli->error); } else { printf("current character set: %s\n", $mysqli->character_set_name()); }
related this.
Comments
Post a Comment