Field returning null if contains £

Field returning null if contains £

classic12classic12 Posts: 228Questions: 60Answers: 4

Hi Guys,

I am using the following getfiles.php

```
<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
include 'dbdatasurplus.php';
mysqli_set_charset("utf8");
$query6 = "SELECT a.quoteID, a.quoteTitle , a.notes, c.web_path FROM quotes a
INNER JOIN users_files b on b.user_id = a.quoteID
INNER JOIN files c on c.id = b.file_id
WHERE a.status = "."'active'"."
ORDER BY quoteID ASC , c.id ASC";

//echo $query6;
$myArray = array();
if ($result = $mysqli->query($query6))

{

    $tempArray = array();
    while($row = $result->fetch_object()) {
            $tempArray = $row;
            array_push($myArray, $tempArray);
        }
    echo json_encode($myArray);
}



//echo $query5;
$result->close();
$mysqli->close();
<?php > ``` The field a.quoteTitle returns null if it contains a '£' sign. ?>

I also tried adding added this to the database connection php files. mysqli_set_charset("utf8")

I looked at my tables and the field was set to CP1251 West so I changed this to UTF-8 Unicode.

Still having the same issue.

Cheers

Steve Warby

Answers

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    Hi Steve,

    This looks like a PHP / MySQL question, so you'd be best asking generic programming questions like this in StackOverflow, rather than here, which is specifically for DataTables.

    My best suggestion would be to use SET NAMES='utf8' in a query, but it might be that is what mysqli_set_charset is doing.

    Allan

This discussion has been closed.