0
I have a table in the database Mysql which contains 3 fields ( id, name and template) different from the other fields, the email template data with tags HTML (structure in longtext).
When I execute the code PHP to return the data, does not return any information. when I run the same script in another table, the data are returned perfectly. I believe it is the data with tags HTML that exists in my model.
Below follows all my script PHP:
<?php
include_once "conexao.php";
$sql = $db->prepare("SELECT * FROM modelo_email");
$sql->execute();
while($data = $sql->fetchAll( PDO::FETCH_ASSOC )){
$json ["data"] = $data;
}
echo json_encode($json);
It returns the value like this now "null"
– Robson Freitas
Try to display only with echo $json or better still use var_dump($json) to see what is being stored inside the $json variable.
– Jefferson Amorim
with var_dump displays the data. but brings with character error, I’m thinking that the error would be this.
– Robson Freitas
array(5) { [0]=> array(3) { ["id"]=> string(1) "1" ["name"]=> string(25) "Cobran Letter to Simple" ["model"]=> string(1440) " Dear (a) Lord (a) Checking our files, We do not identify the payment of the (s) quota(s) listed below (s).
– Robson Freitas
In the example you sent me, I am not seeing the "date" field that you are trying to bring inside the variable To bring the ID fieldVoce has to do $json = $data['id']; $json = $data['name']; $json = $data['template']; Basically this means, $json= (I want the $json variable to receive) from the SELECT output that is stored in the array $data the field [fieldname].
– Jefferson Amorim
I’m not saying that the use of the ['data'] field is incorrect, because you could have this 'date' field in the MODELO_EMAIL table as for example to store the registration date. In order to be able to certify that this field exists, run a var_dump($data). But I believe the problem is that you can bring a field name that does not exist in your table in case [date].
– Jefferson Amorim
Worse than putting the data, but still it returns null.. when I give a var_dump it returns me the full array , with all the data that exists in the table
– Robson Freitas