-1

I am just wondering if you could help me with my problem. Below is my code where I get to save a data in bullet form like this enter image description here

I'm using the code below for my project

<script>
$(".note").focus(function() {
    if(document.getElementById('note').value === ''){
        document.getElementById('note').value +='• ';
 }
});
$(".note").keyup(function(event){
 var keycode = (event.keyCode ? event.keyCode : event.which);
    if(keycode == '13'){
        document.getElementById('note').value +='• ';
 }
 var txtval = document.getElementById('note').value;
 if(txtval.substr(txtval.length - 1) == '\n'){
  document.getElementById('note').value = txtval.substring(0,txtval.length - 1);
 }
});
</script>


<script>
$(".prescription").focus(function() {
    if(document.getElementById('prescription').value === ''){
        document.getElementById('prescription').value +='• ';
 }
});
$(".prescription").keyup(function(event){
 var keycode = (event.keyCode ? event.keyCode : event.which);
    if(keycode == '13'){
        document.getElementById('prescription').value +='• ';
 }
 var txtval = document.getElementById('prescription').value;
 if(txtval.substr(txtval.length - 1) == '\n'){
  document.getElementById('prescription').value = txtval.substring(0,txtval.length - 1);
 }
});
</script>



<?php
include("db.php"); ?>
 <?php 
$sqlsearch;
$row;
$sqlsearch="";
$message="";
$conid="";
          $patient_id="";
          $lname="";
          $mi="";
          $fname="";
          $suffix="";



            
                $sql = "SELECT
                        patient.lname,
                        patient.fname,
                        patient.mi,
                        patient.suffix
                        FROM
                        patient
                        WHERE
                        patient.patient_id= '".$_REQUEST['patient_id']."'";
                        $result = mysqli_query($conn,$sql);
              
                       while($row = mysqli_fetch_array($result)){
                       $lname = $row['lname'];
                       $fname = $row['fname'];
                       $mi = $row['mi'];
                       $suffix = $row['suffix'];
                 
                         echo "<tbody><tr>";     
                        echo "<td> <h5> Patient's name: &nbsp; &nbsp;<u>" . $fname ."&nbsp;" . $mi .".&nbsp;" . $lname ."&nbsp;" . $suffix ."</u></h5></td></tr>";
                                
                    }
                 
                               
                
   ?>  
<form method="POST" action="">
    <textarea id="note" class="form-control note" name="note" id="note" rows="10" placeholder="" required=""></textarea><br><br>
     <textarea id="prescription" class="form-control prescription" id="note" name="prescription" rows="10" placeholder="" required=""></textarea>
</form>

The result in my SQL query is this enter image description here

Now my problem is that, this string '•' is also saved in the database with my data and I don't know where this came from. Can you guys point out where I got wrong in my coding?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
kdr
  • 1
  • 3
  • Possible duplicate of [Strange Characters in database text: Ã, Ã, ¢, â‚ €,](https://stackoverflow.com/questions/7861358/strange-characters-in-database-text-%c3%83-%c3%83-%c2%a2-%c3%a2-%e2%82%ac) – Heretic Monkey Oct 17 '18 at 18:59

2 Answers2

1

The • string is the bullet point characters preceding your Lorem Ipsum. Whatever collation your DB is using is not handling those UTF characters.

E.g.

String in 'ANSI'

..And UTF-8

zzevannn
  • 3,414
  • 2
  • 12
  • 20
  • oh, that make sense! so in what part of my code should I change so that the bullets will not be also saved but stays in my UI form? hehe – kdr Oct 17 '18 at 19:06
0

• is the SQL representation for bullet points.

When you send the data over to your database make sure you don't send the bullet points too.

valegians
  • 850
  • 1
  • 7
  • 17