Most viewed "php" questions
Use this tag when the question refers to some resource, information, or problem relating exclusively to the PHP programming language. For example: questions about classes, methods, functions, syntax and general use of this language. Do not use this tag if PHP is used circumstantially, but has no relation to the question problem. For example: do not use this tag for questions about HTML formatting, CSS or Javascript code.
Learn more…27,244 questions
Sort by count of
-
14
votes5
answers141242
viewsHow to get the current date and time without using the computer clock?
I’m having trouble in the date, he takes my clock from my computer and I wanted him to actually pick the right time. The result of the following code is that the date will take from your host…
-
120
votes4
answers127987
viewsHow to make the date() function format a date in English?
In my project I’m using the function date(), however I would like it to be in Portuguese, the departure date of the moment is: Thursday 6th, I would like it to be on the same model but in…
-
17
votes3
answers104158
viewsHow to solve a Notice: Undefined index?
Starting in PHP and following a tutorial I used the above code and ended up getting this error: Notice: Undefined index: Submit in C: wamp www mezzo-com reservas.php on line 3 How to solve it?…
-
6
votes1
answer100270
viewsHow to resolve Call to Undefined Function mysql_connect() error
I’m doing an IT inventory for registration and I want to connect to the database, but it’s giving this error: Fatal error: Uncaught Error: Call to Undefined Function mysql_connect() in C: xampp…
-
10
votes5
answers98198
viewsHow to display the result of a query on an PHP html page?
How can I display the results of a query in a table of an html page? Below is what I was able to do. However, the code only shows the first record. include("conectar.php"); $sql =…
-
8
votes6
answers96354
viewsHow to make an "Alert" in PHP?
I’m making an email form in PHP, and I’m trying to make one alert when the client clicks to send a validation. The validation seems to work because it redirects to the page I want, but does not…
-
15
votes6
answers90846
viewsDo I use PHP inside an HTML or an HTML inside a PHP?
I made all my site in HTML and CSS, but now I need to use PHP to send some data to a database. I’m just wondering if I modify all my documents to . php or if I use PHP inside HTML (if possible).…
-
11
votes5
answers83787
viewsPassing variables through the URL using friendly URL via GET
I am trying to mess with friendly URL. Before, to pass the variables I used for example: pagina.php?variavel=valordavariavel by clicking on this link I could use a echo and display the variable. I…
-
2
votes1
answer83416
viewsSend a message to Whatsapp via site
I wonder if there is how to send message to Whatsapp through website. Example: The customer is there on the site and there is a field to enter a message and click "send" and I receive the message on…
-
87
votes8
answers75484
viewsError - "Cannot Modify header information - headers already sent"
I have the following code using the function header() of PHP: header("location: painel.php?spv=nav/regMove"); exit; and when it is triggered reports the following error: Cannot Modify header…
-
10
votes5
answers74116
viewsRemoving a specific element in an array
I have the following array $input = array("item 1", "item 2"); But as it is dynamic, items can change $input = array("item 2", "item 4"); $input = array("item 4"); It is possible to use the…
-
22
votes4
answers68381
viewsScript returning Parse error: syntax error, Unexpected end of file
When including this method to a PHP code <?php function meuMetodo($a, $b) { $c = $a + $b; if ($c > 1) { return TRUE; } else { return $c; } ?> This error occurs: Parse error: syntax error,…
phpasked 9 years, 10 months ago Guilherme Nascimento 98,651 -
68
votes8
answers67841
viewsHow to export an HTML/PHP page to PDF
How to export an HTML page to a PDF file? Having a standard document where you can change variables within that template and then export that page to a PDF file in A4 format, without spoiling the…
-
24
votes8
answers64831
viewsHow to check if a checkbox is checked with PHP?
How to check if a checkbox is checked when a form is submitted?
phpasked 10 years, 11 months ago Leandro Costa 2,172 -
22
votes3
answers63728
viewsAdd days to a date
I need to add 2 more days on a date coming from a variable. I’m doing it this way but it’s not working. $data = '17/11/2014'; echo date($data, strtotime("+2 days"));…
-
14
votes1
answer60239
viewsScript that sends Whatsapp message?
There is the possibility to send a message Whatsapp through a Script PHP? (Like a text or an e-mail) I found a class, but it’s old and no longer works (the servers changed, with the sale of Whatsapp…
-
23
votes3
answers59486
viewsHow to compare dates in PHP?
I would like to know which function I use to compare two dates and return to larger. I have a form for HR registration in which the user will register their professional experiences and the date of…
-
51
votes6
answers59467
viewsHow to calculate the difference between two dates?
What is the most practical way to find the time difference between two dates in the default format used by Mysql (YYYY-MM-DD)? Ex: Date 1: 2013-12-11 Date 2: 1994-04-17…
-
24
votes7
answers59028
viewsRefactoring function to remove punctuation, spaces and special characters
I have this function already too old to "clean" the contents of a variable: Function function sanitizeString($string) { // matriz de entrada $what = array(…
-
11
votes1
answer58531
viewsRemove accents from a php string
I’m having problems with the accents in my code and I wanted to remove the accents when they did the research, Ex: Search: Hello | Hello. When doing a Music search on the site it returns the url…
-
11
votes6
answers57963
viewsHow to convert UTF-8 characters in PHP
In my web application, I am using a Mysql database that has the table EditableContent. This table has the field content, who’s kind text and has as input format utf8-bin. In the database the…
-
41
votes3
answers57228
viewsWhat to use require/include/require_once/include_once?
I am developing an application in PHP and would like to know when and why to use require or include or require_once or include_once? I also noticed that you can make these shapes and it works:…
-
117
votes3
answers57155
viewsCharset iso-8859-1 and utf-8 compatibilization problems
The 1st Image I use the charset=iso-8859-1 In this 2nd image I use utf8 I have a news system where you can paste html or text from other pages. On the page where the news are presented I use the…
-
12
votes8
answers56968
viewsPHP echo Special character problem ("ç")
I’m developing a website that displays the names of the months with strftime. HTML is already charset=UTF-8. The problem is that in the month name display it appears as in the image below I did a…
-
2
votes3
answers55998
viewsRun php function with onclick
I want to know how I can run a php function with the onclick event on an element a, taking as an example: <a href="">Teste onclick</a> And the function: function testeOnclick() { echo…
-
9
votes2
answers55209
viewsSet OPTION as SELECTED based on database values
I am preparing a form where I am setting the values of the fields with the database data. I’m having trouble setting the chosen option as selected to the <select/> in the code below: PHP…
-
3
votes3
answers55067
viewsScript to go back to the previous updated page?
Well, I wanted something that did that when a person clicked to go to a page they were redirected to the previous page.. But the page updates... Is that I made a small system of comments, when I…
-
2
votes3
answers54929
viewsCreate HTML table and display data using PHP
I’d like to see if anyone can help me with this problem of creating an HTML table in php. <?php <p><b>Alvará: </b></p> <p>Alvará Numero:…
-
43
votes4
answers53481
viewsHow to decrypt MD5?
If I have the following code $senha = md5("senha") and send it to the database $senha, it should be possible to recover this MD5 at the bank and show "password" back on an information update form,…
-
6
votes4
answers53244
viewsDifferent ways to count record numbers in Mysql
There’s a difference in performance if you do: //seleciona todos os itens da tabela $cmd = "SELECT * FROM produtos"; $produtos = mysql_query($cmd); //conta o total de itens $total =…
-
12
votes2
answers52864
viewsHow to check if the Term is contained in String in PHP?
I need to check if a certain tag is inside the string. I get this string from the database that comes in the form of tags comma separated without spaces as below: String canais,proteses,implantes…
-
3
votes3
answers52823
viewsHow to get current url with PHP
I have this link below. http://example.com/Novo/adm/categoria/1-Nome_Categoria http://example.com/Novo/adm.php?categoria=1 However I will need to compare current URL, to make a menu activation…
phpasked 7 years, 8 months ago PoneiMlditoUM 83 -
8
votes6
answers52587
viewsHow do I use a database on an HTML site?
I am interested in making a site that will use a database, many told me they use Mysql to do this, but I have no knowledge about it, installation, use etc. I have knowledge in PHP, HTML, CSS and…
-
3
votes1
answer52481
viewsHow to open a PHP file in the browser?
I’m trying to open files with the extension .php. In Firefox, it asks to download. In the IE it asks to carry out the download. Already in the Chrome it displays the PHP code. Before it wasn’t like…
-
22
votes3
answers51011
viewsHow to send email from localhost using PHP’s mail function?
I want to send emails from localhost. <html> <head> <meta charset="utf-8"> </head> <body> <h1> Olá mundo!</h1> <?php $enviar = mail(…
-
3
votes3
answers50069
viewsHow to display all the results of a SELECT in PHP?
I’ve done all this code myself, but I’m having a hard time displaying all the results below each other. <?php include 'conexao.php'; ?> <html> <head> <title>GMB Mineração e…
-
7
votes3
answers49921
viewsConvert string number to PHP integer
I’m converting a string to an integer in PHP, but at the return of settype($variavel, "integer"), or (int)$variavel bring me a null value or equal to 1. Have another way to try the conversion? The…
-
13
votes3
answers48813
viewsReceive external JSON data from PHP
I am trying to receive an external JSON file via PHP. I am doing so: <?php $json_file = file_get_contents( "http://www.moonwalk.com.br/api/VitrineDeProdutos/58e903df295cbc5c4639434d4c35090d");…
-
23
votes1
answer46824
viewsWhat’s different from Xampp, Wamp, Easyphp, Zwamp and PHP?
What a difference from Xampp, Wamp, Easyphp, Zwamp and PHP? They are all servers? Are all official PHP?
-
4
votes3
answers46491
viewsPath to access html folders ,css,php etc
Could someone explain me this Nives system to access folder in the use of languages like html,css and php (../)(.../)(./).?
-
5
votes5
answers45344
viewsAccess website on local network through my Android phone
I made a site in PHP and Mysql responsive and would like to access it on my Android phone by localhost, I know I have to put my IP on browser but when I send access it appears the following error:…
-
6
votes5
answers45121
viewsHow to use a PHP variable in javascript?
You can declare a variable in PHP and then use it in Javascript? Example: <? var w_qtd_v = 0; ?> <script language="javascript"> w_qtd_v = w_qtd_v + 1; </script>…
-
11
votes2
answers44856
viewsHow to get ip from a user using php?
I’m using the function getenv("REMOTE_ADDR"), to catch the ip users who enter a particular page of my site and then I made a if to redirect that ip which is not equal to the variable of ip allowed.…
-
3
votes3
answers44020
views -
2
votes0
answers43276
viewsConfirm ERR_CACHE_MISS form resubmission by going back to previous page?
Staff after I fill out a form and send to the database via POST, and after that go to another page, when I return to this form by the browser "<-" this error occurs on the screen: "Confirm form…
-
9
votes2
answers42711
viewsHow to set date(’d/m/Y H:i:s') with Brasilia time instead of server time
I’m recording the date and time in the database with the script: $sql = "INSERT INTO admin_users (user_name, user_password_hash, user_email, user_data) VALUES('" . $user_name . "', '" .…
-
7
votes1
answer41918
viewsTraverse string and replace a specific PHP character
I wanted to replace, in a string, all character occurrences & by a e (or remove it). The character may be in the middle of a word or appear several times in the same string. Example: Original…
-
15
votes5
answers41336
viewsNumber formatting (PHP)
I created a function cotacaoDolar(); who returns at the end: return str_replace(",",".",$texto_dolar); And the result, appears here: echo $i['sellingStatus'][0]['currentPrice'][0]['__value__'] *…
phpasked 10 years, 9 months ago GustavoCave 545 -
3
votes5
answers40467
viewsHow to redirect php pages
I have a login system in a program PHP that I want it to forward users to different pages depending on their profile. There is a login table that has a field called "perfil" who is either 0 or the…
-
40
votes3
answers39993
viewsHow to implement google reCAPTCHA on my website?
I’m trying to implement the reCAPTCHA from Google on my site, and I can’t do the integration Server-Side (I use the language PHP). How can I make reCAPTCHA work, and perform the validation before…