Posts by rray • 66,288 points
1,220 posts
-
196
votes9
answers12451
viewsA: How to prevent SQL code injection into my PHP code?
1 - NAY use the mysql_* functions as they are considered obsolete (deprecated) and will soon be removed. A few more reasons not to use them. Utilize Prepared statements, this will reduce the…
-
0
votes4
answers3156
views -
12
votes5
answers98198
viewsA: How to display the result of a query on an PHP html page?
When more than one result is returned by your query, use a while to get them all. $sql = mysql_query("Select * From tb_trabalhador and tb_detalhe_trabalhador"); while($exibe =…
-
3
votes6
answers636
viewsA: How do you turn the average to red?
Just add an if inside the for $resultado = ''; for($i=0;$i<count($aluno);$i++){ $cor = 'black'; if($aluno[$i]['media'] <= 20 ){ $cor = 'red'; } $resultado .= "<p…
-
2
votes7
answers7710
viewsA: How to send email automatically?
Use Datediff mysql to perform the compute between. $validade = ("SELECT Nome, AlvaraValidade, AcidenteValidade, SeguroValidade, FinancasValidade, SocialValidade, RemuneracaoValidade, ....//sql…
-
12
votes3
answers72494
viewsA: How can I check if one string contains another in Javascript?
Using one regex it is possible to know if certain text is contained in another, using method match(). Its regex must be bounded by // modifiers in js metacharacter list var str = 'algum texto';…
-
65
votes6
answers9431
viewsA: When should var be used in Javascript?
It is always recommended to use the keyword var because it makes the variable local, otherwise it becomes global. This avoids conflicts, corrupted variable, makes the code less vulnerable to access…
javascriptanswered rray 66,288 -
5
votes2
answers353
viewsA: Remove matrix input by its value
To remove an item from the array by passing the value, the function array_search(), resolves. It resumes the key if the value is found in the array and then just pass the Indice to unset(). This…
-
3
votes3
answers269
viewsA: How to prevent a method from printing data when calling a third-party API?
Utlizando display_errors it is possible to hide/display errors at runtime in a specific script. ini_set('display_errors', false); $this->soapClient = new SoapClient($wsdlLink); $retorno =…
-
1
votes3
answers3831
viewsA: Check if number is integer in Access
According to this link, to check if the variable type is int/integer, use this code If TypeName(x) = "Integer" Then…
-
3
votes3
answers6810
viewsA: Difference between PATH_SEPARATOR and DIRECTORY_SEPARATOR
PATH_SEPARATOR This constant serves to separate paths with the correct character according to the operating system that in windows are separated by ;and on linux by : DIRECTORY_SEPARATOR, Serves to…
-
-3
votes5
answers1562
viewsA: Optimize function to include classes also looking in sub-directories
The SPL has class Directoryiterator to list directories and files. The idea is to take the directories below classes and return as an array and then list all the files in each folder. function…
-
8
votes3
answers12113
viewsA: Check if a table exists in the database
For information_schema mysql is possible to access all tables in a database: SELECT table_name FROM information_schema.tables WHERE table_schema = 'data_base' AND table_name = 'nome_da_tabela' After…
-
8
votes3
answers3229
views -
1
votes2
answers2445
viewsA: What is the syntax for searching with array as parameter in Mysql?
A solution with php would generate a query with several ? to the IN(). and then pass the numbers on execute()of the PDO $sql ='SELECT c.cpf FROM tbl_cliente as c WHERE c.cpf IN('; $qtd_cpfs =…
-
12
votes2
answers396
viewsA: Is there a function to display the defined variables?
get_defined_vars(): takes all variables defined in scope(Gobal or local depending on the location of the function call) and then you can run a print_r or var_dump to view their respective values.…
-
5
votes3
answers7789
viewsA: Built-in form action parameter is not passed via GET
In your action you leave only the file name. <form method="get" action="painel.php"> and in php check that the value has been set and contains something. if(isset($_GET['consulta']) &&…
-
3
votes5
answers28367
viewsA: When to use self vs $this in PHP?
$this is used within the class to access object properties/methods. self is used to access static members.
-
1
votes6
answers28585
viewsA: How to get Timestamp in Javascript?
With pure javascript it is possible to get the timestamp like this: console.log(new Date().getTime()); //ou alert(new Date().getTime());
-
33
votes5
answers74978
viewsQ: How to get the table name and attributes of a Mysql database?
How to get the names of all tables in the database Mysql? How to get the attributes (name, type, etc...) of a given table in the Mysql database?