0

i can't resolve my problem with special character, in my case "à". When i open my php file in browser, if the special character is include in database on a table with varchar utf8_general_ci the response is empty, but if i delete this character the response is normal. Could you help my please. Thank you in advance

Here my php code

<?php

include('connec.php');

$sql = "SELECT * FROM articles";

$result = $link->query($sql);

$myarray = array();

if($result->num_rows > 0){
    while($row = $result->fetch_assoc()){
        $myarray[] = $row;
    }
    // Send back the complete records as a json
    echo json_encode($myarray);
}else{
    echo "error";
}
$link->close();

return;
?>
KIKO Software
  • 15,283
  • 3
  • 18
  • 33
BabaBoy
  • 21
  • 1

1 Answers1

0

When your PHP file doesn't return anything there might be a simple error in it. There are two ways to check this:

  1. Check the PHP error logs. These are text files containing all the errors generated by your code.

  2. Switch on error reporting. This will output any error, except syntax errors! For those errors you need to check the logs. This is how you switch on error reporting:

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
KIKO Software
  • 15,283
  • 3
  • 18
  • 33
  • i don't have any error in php error log, and if i change the name of table to do a error, i have an error in php error log – BabaBoy May 30 '22 at 19:53
  • i'm using wamp to emulating ther application – BabaBoy May 30 '22 at 20:00
  • @BabaBoy Could you have a look at the source code of your web page to see if it is truly empty. Sometimes a page may look blank, but it is only because a character cannot be rendered. Next you could add the normal HTML code, see: [HTML5 Template](https://www.sitepoint.com/a-basic-html5-template/). It's long, but it explains everything. You can skip the CSS and JS. Finally, if there's still nothing, you could add a bit of extra feedback in the code. I usually do things like `echo "Step 1
    ";`, `echo "Step 2
    ";` and so on, on each line so I can see which lines get executed.
    – KIKO Software May 30 '22 at 20:10