Posts by Wees Smith • 2,778 points
154 posts
-
1
votes1
answer101
viewsQ: Is it possible to link tables with keys stored in JSON column?
I have two tables: CREATE TABLE jtable (id integer, jdata JSON); INSERT INTO jtable(id, jdata) VALUES(1, '["1","2","3"]'); INSERT INTO jtable(id, jdata) VALUES(2, '["1","3"]'); INSERT INTO…
-
0
votes3
answers216
viewsA: Insert a form with while
You need to understand the operation of receiving data from the forms by PHP, when it comes to forms with repeated information as is your case, you have another option to facilitate the processing…
-
3
votes1
answer160
viewsA: I cannot insert email to the PHP - mysql database
Same syntax problem and is here: "INSERT INTO newsletter_emails SET email = '$letteremail'" INSERT is: "INSERT INTO tabela (campo1,campo2,...) VALUES (valor1,valor2,...)" SET is for UPDATE…
-
3
votes1
answer1135
viewsA: Subtract 1 month in PHP date
Surely this question should have duplicates, because working with dates is always a problem for those who don’t use them a lot, I sometimes curl up in something, but in the case of @Felipepacheco…
phpanswered Wees Smith 2,778 -
0
votes1
answer81
viewsA: List 3 fields from an Array
You have the multidimensional array $contatos that is storing the information nome, tel e email: if (array_key_exists('chave', $_GET)) { $contatos['chave'][] = $_GET['nome']; } Thus the…
-
0
votes1
answer24
viewsA: Error 1065 Query is Empty when changing page in my pagination
This is where you take the option you selected to do the initial search that will provide the data to the page and thus calculate the pagination need, correct? $opcao = $_POST['opcao'];…
-
2
votes2
answers205
viewsQ: List Attributes of an HTML Element with JS
Talk, you guys, all in peace? I was looking for a solution on the Internet, but I didn’t find what I needed, nor did I understand a way to do it, if anyone can shed some light? I would like to list…
-
2
votes1
answer48
viewsA: Input giving wrong results
It’s probably because you’re wearing a single name="gateway" to the three camps: <label><input type="radio" name="gateway" id="gateway" value="mercadopago" checked>…
-
1
votes1
answer174
viewsA: How to compare a zip code within an array with multiple ranges in PHP?
I think it may be so: //cep a ser encontrado $cep="03100-100"; //array com os intervalos dos ceps $array=array( array("01000-000","01599-999"), array("02000-000","02099-999"),…
-
4
votes1
answer39
viewsA: Different redirects per day of the week
First you will make an array, with the days of the week in English containing an array of links for each day of the week, here in the example I am using the first 3 letters because I will use…
-
2
votes1
answer32
viewsA: Data is not going to Database Mysql/PHP
Some mistakes may be causing this: <input type="text" class="form-control" name="firstName" id="firstName" placeholder="" value="" required> <input type="email" class="form-control"…
-
0
votes1
answer245
viewsA: Separate fields by TAB
I tested some forms, concatenating or not: $tab=chr(9).chr(9).chr(9);#aqui vai quantas tabs vc qser $conteudo = ""; while($mostrar = mysqli_fetch_array($sql)){ $conteudo .= "".PHP_EOL; $conteudo .=…
-
1
votes4
answers2211
viewsA: Javascript converting wrong date
You missed remembering Timezone: data_formatar = new Date("2019-01-15").toLocaleDateString('pt-BR', {timeZone: 'UTC'}); console.log(data_formatar);…
-
0
votes1
answer1140
viewsA: PHP connection using phpMyAdmin
Come on, first you need to take a look here at how to ask, avoid placing images with the code and yes put the same code. Now I will exemplify the connections with the database. The class PDO:…
-
1
votes2
answers146
viewsA: No return function
I believe the problem is: public function __construct($descricao, $estoque, $preco){ $this->$descricao = $descricao;// aqui $this->$estoque = $estoque;// aqui $this->$preco = $preco;// e…
-
2
votes2
answers72
viewsA: Save form data
First you will create the form: <form action="action.php" method="post"> <label>Nome:</label><br> <input type="text" name="name"><br>…
-
1
votes2
answers2230
viewsA: PHP Nfe 4.0, how to view invoice information?
Perhaps it is a small lack of attention, the secret is to remember that it is a multidimensional object, which has several layers containing arrays or other obejtos: public 'det' =>…
-
1
votes4
answers460
viewsA: How do you separate word into letters in php?
You can do it like this: $string="123"; for( $i=0; $i < strlen($string) ; $i++ ){ $array[$i]=$string[$i]; } Go print something like this: Array ( [0] => 1 [1] => 2 [2] => 3 )…
-
0
votes2
answers47
viewsA: PHP - I can’t update the database
I found the possible error, I had to define the variable $row, which contains the array brought by SELECT that will define the operation of UPDATE $resultado=mysqli_query($ligaBD,…
-
0
votes2
answers46
viewsA: Problem for displaying the values of an Array on the front end
If the information process is not done on the same page where you want to print the result, you need to transfer the return from one page to another. Just like the @PauloVictor said, you need a…
-
1
votes3
answers699
viewsA: How can I use the function href="#"?
Using anchors: <a href="#topo">Topo</a> <a href="#meio">Meio</a> <a href="#fim">Fim</a> <div id="topo">Div Topo</div> <div id="meio">Div…
-
0
votes1
answer30
viewsA: SQL does not return any table data despite not giving errors
I did a test here, using exactly your code and in fact did not return any error, but only managed to print the results according to the desired as follows: while($property =…
-
0
votes2
answers264
viewsA: Remove First Name and Last Name from Full Name
I believe that this is not the appropriate but functional form: SELECT SUBSTRING_INDEX(nome_completo, ' ', 1) AS primeiro_nome, SUBSTRING_INDEX(nome_completo, ' ', -1) AS ultimo_sobrenome,…
-
0
votes4
answers58
viewsA: Repeat loop on id
Using a simple for(): for(var i = 1; i <= 10; i++){ $('#tituloSlideInput'+i).on('change', function() { var value = $(this).val(); $('#slide_titulo1'+i).text(value); })…
javascriptanswered Wees Smith 2,778 -
1
votes1
answer85
viewsA: Variable sanitization X variable filter before insertion in MYSQL
I believe the way to make your code less bulky is to create a array() with the values relating to the changes you want to make with the str_replace(), so whenever you want to add some other value,…
-
0
votes1
answer230
viewsA: Export query to EXCEL in PHP error UTF-8
The header()s should always come at the top of the page before anything: <?php header ("Expires: Mon, 18 Nov 1985 18:00:00 GMT"); header ("Last-Modified: ".gmdate("D,d M YH:i:s")." GMT"); header…
-
0
votes2
answers343
viewsA: Select any div from a foreach
First, the IDs of the elements HTML must be unique on the page, inside that foreach, all have the same, using the variable $i, we will create an identifier for each of the DIVs to make them unique:…
-
2
votes1
answer190
viewsA: AJAX json_encode PHP file
I organized so that you can work with all the data that will be returned by PHP, transforming the variable $msg in a array() with the content: if(empty($errorMSG)){ $msg =…
-
0
votes1
answer25
viewsA: php database
You need the id_usuario which is logged in, I believe you already have it in hand, because the problem is here: $id_usuario = $_SESSION["id_usuario"]; $consulta = "SELECT * FROM usuarios WHERE…
-
2
votes1
answer450
viewsQ: Regular Expression to validate password - PHP
I searched here in the OS and tbm in Google, but I did not find something to act as I would like, I am also not good with regular expressions, I confess that I have some difficulty and I would like…
-
0
votes1
answer30
viewsA: Difficulty deploying multiple options in a conditional variable to load corresponding image
I believe it is not appropriate, but it must solve: $variavel_condicional_letra = ($data["CreditData"][0]["Score"]["Class"] == 'A') ? '<img src="api/images/a.png">'…
-
0
votes1
answer55
viewsA: Problem with the type of Ncode I get from a Sybase comic
Right now $db = odbc_connect($dsn, $user, $pwd); which is the solution, you need to set the connection to be made in UTF-8 so: <?php $dsn.="CharacterSet => UTF-8"; $db = odbc_connect($dsn,…
-
1
votes2
answers8001
viewsA: Subtract dates in PHP
One of the ways to do an operation with dates on PHP is: // a partir da data de hoje echo date("d/m/Y",strtotime(date("Y-m-d")."+12 month")); // a partir de outras datas echo…
-
1
votes1
answer67
viewsA: Dynamic combobox
With a $.Ajax() you do what you want First <select></select>: <td> <strong><label for="Valência">Valência</label></strong> <select id="Valencia"…
-
2
votes4
answers136
viewsA: How to know which checkbox are selected?
I added a test button so you can understand that var s must be inside the event so there is no repeat result: <input type="checkbox" data-id="1"> <input type="checkbox" data-id="2">…
javascriptanswered Wees Smith 2,778 -
2
votes2
answers48
viewsA: Working with Ajax
First step is the addition of dataType:"Json" in his $.Ajax(): $("#txtplaca").blur(function() { var url = 'consulta_tip_cli.php'; var txtplaca = $("#txtplaca").val(); $.ajax ({ url: url, data:…
-
3
votes3
answers62
viewsA: Error while connecting to php server
Problem is you didn’t set get() as a function within the class: class Connection { private static $connection = null; public static function get() { if (self::$connection == null) {…
phpanswered Wees Smith 2,778 -
0
votes3
answers179
viewsA: How to remove character from a String and turn it into integer value with PHP?
Several ways to achieve this result, another one is: $valor = preg_replace("/[^0-9]+/i","",$valor); However it is a numeric output, to convert to int, is used: $valor = (int)…
phpanswered Wees Smith 2,778 -
2
votes1
answer37
viewsA: Assign value to input
The problem is because the id is an attribute single there may only be 1, is replaced by the attribute class, works perfectly <input type="text" name="" class="Preco"> <input type="text"…
-
1
votes1
answer45
viewsA: Save a search result to a json_encode
I had a problem with the same purpose, save json in a database, so I found the solution to my problem, simple and easy: $string = json_encode(addslashes($queryResult)); Because of the quotes and/or…
-
1
votes2
answers432
viewsA: Parse error: syntax error, Unexpected '$folder' (T_VARIABLE) in
I simply rewrote the code and it worked: if(is_dir($pasta)){ $diretorio = dir($pasta); while($arquivo=$diretorio->read()){ if(($arquivo!='.')&&($arquivo!='..')){ unlink($pasta.$arquivo);…
phpanswered Wees Smith 2,778 -
1
votes1
answer440
viewsA: Upload Image in Blob Format
Try to do it this way: document.getElementById("btnSave").addEventListener("click", event => { canvas.toBlob(function(blob){ $.ajax({ url : "upload.php", type: "POST", data: blob, contentType:…
-
1
votes1
answer62
viewsA: Comparing similarity in two arrays!
That would prevent him from checking the duplicate by placing a if() within the second foreach(): foreach($array2 as $word2){ //verifica se word1 é diferente de word2, se for igual ele não compara…
-
1
votes1
answer109
viewsA: How to make a condition with mysql php number
I added the field max in the <input> that it enters the value with the value it has with account (you change the name of the fields that are necessary), which will limit up to the amount it…
-
0
votes1
answer45
viewsA: Validation of PHP Fields
You’re not defining a WHERE in the first query: $verifica_banco=mysqli_query($conexao,"SELECT * FROM petianos WHERE cpf='$cpf' LIMIT 1"); So he will check whether there is CPF registered or not.…
phpanswered Wees Smith 2,778 -
4
votes2
answers49
viewsA: Show total of records
Problem is you’re calling one while() within another and that in the second you define the condition as $vip2=="SIM", like the $vip2 which was set on that loop turn is actually "YES" it will create…
-
1
votes1
answer139
viewsQ: Working with Images - PHP
I have worked and still work with some image manipulation libraries in PHP, but I decided to study at source the manipulations, how they work, how to implement and work with images. As we know the…
-
1
votes2
answers98
viewsA: Using PDO links in PHP
Note that the array $rows holds a key 0 with the value being another array: Array ( [0] => Array ( [id_content] => 31 [img] => paleozoica.jpg [titulo] => Era Paleozoica [pv] =>…
-
1
votes2
answers24
viewsA: loop to get date
First problem is the current date format in the variable $now, you need to convert it to a format without the /: $now="18/07/2018"; $now=str_replace("/","-",$now); Then you will convert $now for the…
phpanswered Wees Smith 2,778 -
1
votes1
answer72
viewsA: Why is my database connection not working? Object-oriented PHP
class getForm{ public $nome; public $email; public $tel; public $query; public $conexao = null; public $usuario = "root"; public $senha = ""; public $banco = "testando"; public $servidor =…