Posts by Marcos Vinicius • 300 points
17 posts
-
1
votes1
answer58
viewsA: Take empty value of an array, how to do?
Pedro, this function mysqli_fetch_array() returns NULL if no result is found as the PHP website says: Returns an array that corresponds to the obtained row or NULL if there are no more rows in the…
-
-1
votes2
answers352
viewsA: Read JSON multidimensional array via PHP
Dude, you were trying to access a multidimensional, associative array as if it were just $array[0]['Event-home-team']. There are other ways to solve your problem, but the easiest and perhaps…
-
1
votes3
answers639
viewsA: Count to 100 with PHP
I find it much more simple to use a for note the example: <?php $numero = 45; $resultado = []; for($i = ($numero+1);$i <= 100;$i++){ $resultado[] += $i; } print_r($resultado); not to mention…
-
0
votes1
answer49
viewsA: Data is not being entered into the database
you opened the connection you defined the query($sql) but did not execute, follow an example: <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; //…
-
0
votes1
answer88
viewsA: Data from a PHP POST request does not arrive as JSON
You are converting only $Fields into json when you should actually convert the result
-
0
votes2
answers53
viewsA: Add empty items at the end of array
in this case I am assuming that there is only one record returned from the BD: $emp_itemx=array(array( "idhis" => 'xxx', "id_user_cartao" => 'xxxx', "ponto" => 'xxx', "id_user" => 'xxx',…
-
0
votes1
answer40
viewsA: The page only displays the Else message. if doesn’t work and I don’t know what the problem with that simple code is anymore
the correct test is like this: if ($_SERVER['REQUEST_METHOD'] == 'POST') So it checks if the page was triggered by the post method (i.e., by the form).
-
2
votes1
answer42
viewsA: INSTER MYSQL PHP PDO ERROR
do not need quotes in the columns "INSERT INTO usuarios (user, password, phone, email, type, status, level, hash) VALUES (:user, :password, :phone, :email, :type, :status, :nivel, :hash)"
-
1
votes2
answers114
viewsQ: convert one-dimensional array to associative multidimensional
my problem was to convert an array into a single array in a multidimensional associative array,: $dados = array(1,"1minuto","seco",2,"3minutos","chuva"); as you can see are three types of data that…
phpasked Marcos Vinicius 300 -
0
votes1
answer28
viewsA: Error in data editing page
its error is the lack of the method, the page expects to receive the data via POST, except for the id that would go via GET. <form action="editarPerfilUsuario.php?id=<?php echo $_GET['id'];…
-
0
votes1
answer75
viewsA: Change the file name when uploading
you’ll have to blow up(explode()) the file name and with the resulting array join the date, follow the example: $nomeETipo = explode('.',$file['name']); $fileName = $nomeETipo[0].date('dmY') . "." .…
phpanswered Marcos Vinicius 300 -
2
votes1
answer875
viewsA: List directories and PHP files
I think that solves your problem: <?php $itens = new DirectoryIterator('./'); foreach($itens as $item){ if($item->gettype() === 'dir'){ $diretorios[] = $item->getFilename(); }else{…
-
-2
votes2
answers163
viewsA: Txt generation, does not work PHP_EOL function
uses at the end of the line: "\n" tested in my local environment and worked like this, do not forget to put between double quotes.
-
0
votes1
answer188
viewsA: How to fix "Call to Undefined method Dbconnection::prepare() in Userdao.php on line xx" error?
change your line: $stmt = $this->conn->prepare($sql); for: $conexao = $this->conn; $stmt = $conexao->prepare($sql);
-
0
votes1
answer61
viewsA: htaccess PHP friendly URL
add that line to your . htaccess: RewriteCond %{REQUEST_URI} !(\.jpeg|\.jpg|\.gif|\.png)$ [NC] so the rewrite will ignore the images.
-
-2
votes1
answer53
viewsA: Why isn’t the image effaced?
Are you sure the problem isn’t in your browser cache? because, if the image is deleted and the new image appears in the folder but does not appear in the browser can only be the browser cache that…
phpanswered Marcos Vinicius 300 -
3
votes2
answers89
viewsA: Problem with DRY
I tried a different approach but I think I came to the same result as my colleague: $a1 = 0; $b1 = 0; $a = [5,6,7]; $b = [3,6,10]; $c = count($a); for($i = 0; $i < $c;$i++){ if($a[$i] >…