0

I have a chat bot that creates a corpus of messages from a GroupMe chat and generates responses using the Markovify module in Python 3. I recently started running a LAMP stack out of my dorm so that I can record these messages, store them in a MySql database, and display them on demand for people on the University wifi.

My problem as of late is that question and quotation marks, which show up fine in the python console program, appear as "�" on the web page. Here's the index.php file:

<html>  
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
<title> Hove and Lonor Database </title>
</head>

<body>

<div id="top_container">
  <h1 class="title">HOVE AND LONOR LIVE FEED Y'ALL</h1> 
   <h2><a href="/search/"> user lookup </a></h2>
</div>




<center>
<?php 
error_reporting(E_ALL);        
ini_set('display_errors', 1);
$conn = mysqli_connect('localhost', 'someuser', 'somepass');
mysqli_select_db($conn, 'groupme');

$query = "SELECT * FROM msgs";
$result = mysqli_query($conn, $query) or die (mysqli_error($con));

echo "<table>";

while($row = mysqli_fetch_array($result)) {
    echo"<tr><td>" . $row['date'] . "</td><td>" . $row['user'] . "</td><td>" . $row['msg'] . "</td></tr>";
}

echo "</table>";

mysqli_close($conn);

?>
</center>
Qirel
  • 25,449
  • 7
  • 45
  • 62
rudiejd
  • 392
  • 2
  • 13
  • All it takes, is one wrong charset setting in your application - *everything* needs to be the same charset! I have previously written [**an answer about UTF-8 encoding**](https://stackoverflow.com/a/31899827/4535200) that contains a little checklist, that will cover *most* of the charset issues in a PHP/MySQL application. There's also a more in-depth topic, [**UTF-8 All the Way Through**](https://stackoverflow.com/q/279170/4535200). Most likely, you'll find a solution in either one or both of these topics. – Qirel Apr 05 '19 at 21:17
  • For Python, the two first lines should be `#!/usr/bin/env python # -*- coding: utf-8 -*-` (each line starting with the `#`). – Qirel Apr 05 '19 at 21:17
  • @Qirel thank you! that first guide did the trick. i couldn't find it while searching for the problem i was having – rudiejd Apr 05 '19 at 21:57

0 Answers0