Posts by rray • 66,288 points
1,220 posts
-
4
votes1
answer99
viewsA: mysqli_result Object ( )
Do not use single quotes ' in field names only for values, if you have a special character name or reserved word use the crase ` ("show" is a mysql reserved word). Your consultation should look like…
-
6
votes1
answer508
viewsA: Discover an array key by the given value?
Use the function array_search(), given a value if found it returns the corresponding array key. demo <?php $arr = array("primeiro" => 1, "segundo" => 2, "terceiro" => 3); $chave =…
-
15
votes2
answers13578
viewsA: Mysql error "expects Parameter 1 to be Resource, Boolean Given in"
This mistake happens when mysql_query() or mysqli_query() failure, is usually a syntax error in the sql query and returns a false as explained in manual. To mysql_fetch_*() it is necessary to pass a…
-
1
votes1
answer502
viewsA: Error in Function connection class code
Properties must be declared in the body of the class in the case $conexao was defined as a local variable of the constructor so soon after its call it lost its value. Define $conexao as a member of…
-
1
votes1
answer847
viewsA: error in mysqli query
When making a query and table/field have special characters use: ` Single quotes ' should only be used in text/Character values etc change the occurrences: $query_Busca = "SELECT * FROM…
-
4
votes2
answers836
viewsA: check whether GET exists or not
Use the function in_array to make this comparison, the first argument is the value to be found and the second is in which variable the search should be made in the case $nomes. $nomes = array…
-
1
votes2
answers788
viewsA: registering php data in SQL server database 2008
In your code failed to call the function mssql_query() who is responsible for executing the query. To resolve Add this line: mssql_query('INSERT INTO ....') or die(mssql_get_last_message()); When…
-
1
votes4
answers912
viewsA: Behavior of the function preg_match() for short names
$b = "da"; var_dump(preg_match('/^[^A-Z]*$/', $b{0})); Your regex says, match at line start(^) something other than capital letters between A-Z([^A-Z]) followed by any character(*), when it’s past…
-
1
votes4
answers1559
viewsA: Jquery does not work in PHP
Change the file paths <script src="C:\wamp\www\cadastro\javascript\jquery-1.5.2.min.js" type="text/javascript"></script> <script…
-
8
votes3
answers7767
viewsA: Send email with CCO in PHP
Using the function mail() it is necessary to pass this information in the header which is the last argument, just add that line: $cabecalho .= "From: \"{$nome_remetente}\"…
-
6
votes4
answers12575
viewsA: What does "0x" mean at the beginning of hexadecimal numbers?
Some languages define 0x as prefix to a hexadecimal number, it is basically a sign for the compiler/interpreter that the number should be treated on another basis(16). whole php…
hexadecimalanswered rray 66,288 -
3
votes1
answer72
viewsA: Upload does not work online, it appears on the screen part of the code of the Upload class
When part of the source code is displayed on the screen, it means that your code has the short_open_tag <? and on the server this directive is disabled. To resolve this change all occurrences of:…
-
4
votes2
answers2738
viewsA: How to clear screen data?
Com javascript utilize var form = document.getElementById('form'); form.reset(); This will erase the values of input fields, fields with default value will be maintained. Another solution is to use…
-
6
votes2
answers5466
viewsA: How to duplicate the records of a table in the BD
Use a insert along with a select, the types of data in the select and in the insert should be the same or compatible it is also possible to use other clauses as where, joinetc. INSERT INTO…
-
17
votes1
answer569
viewsQ: What is Sargable argument?
In database queries what is the concept of a sargable argument (Search Argument Able)?
-
2
votes1
answer2592
viewsA: Save formatted text in Mysql DB
If the text formatted by Tinymce has html, remove the strip_tags of $postagem. This function removes all html tags so the text will be written to the database without any formatting. change:…
-
3
votes2
answers1752
viewsA: Problem with session_register
Session_register was discontinued in php5.3 and removed in php5.4 the error messages respectively are: Deprecated: Function session_register() is deprecated and Fatal error: Call to Undefined…
-
4
votes1
answer870
viewsA: Pdo UPDATE does not work
When to use ? bindValue puts the order of the argument and variable: $statement = $conn->prepare("UPDATE stream_table SET src = ? WHERE start = ? "); $statement->bindValue(1, $value);…
-
106
votes5
answers12967
viewsQ: Why is the use of GOTO considered bad?
Some languages, such as C, still have the instruction goto. I have always heard that using it is not a good practice. I would like to know: What would be the reasons to avoid the goto and what…
-
9
votes2
answers1023
viewsA: Error creating a Mysql table
Change type for engine. The type was using in older versions of Mysql. "The Older term TYPE is supported as a synonym for ENGINE for backward Compatibility, but ENGINE is the Preferred term and TYPE…
-
2
votes3
answers2000
viewsA: Pass checkbox list to php
Only marked items are sent to php, to catch all it is necessary to add brackets[] in the checkbox name otherwise only the last value is sent. change: <input type='checkbox' class='marcar'…
-
7
votes7
answers57425
viewsA: Check/Deselect Checkbox from a button
With pure javascript you can take the element by name and assign the checked value of marcar/desmarcar todos the others in onclick(), because getElementsByName() returns an array. <script…
-
3
votes3
answers233
viewsA: Add enumerator to a PHP table
If you’re just going to add the line number, create a variable that counts: $linha = 1; while($exibe = mysql_fetch_array($qr)){ //seu código... echo $linha .' - '. $exibe['nome']; $linha++; }…
-
5
votes2
answers13368
viewsA: Number of "bound variables" does not match the number of "tokens"
This error happens when there is a parameter more or less in the query, in the update: UPDATE usuario SET email = ?, senha = ?, chave = ?, pergunta = ? WHERE codusuario = ? 1 2 3 4 5 there are 5…
-
3
votes3
answers12958
viewsA: Generate Excel with php query
It is possible, one of the alternatives is to use lib phpexcel for handling excel files include '../../includes/excel/PHPExcel.php'; $objPHPExcel = new PHPExcel();…
-
5
votes3
answers1785
viewsA: How to deal with multiple queries?
One way to improve the organization of a procedural project is to separate php from html and break the code (macaroni) into functions. Also remember to use modern api’s for database connection…
-
6
votes2
answers7411
viewsA: Determine the field in ORDER BY RAND() in mysql
According to the documentation random results cannot be obtained by a given column. You cannot use a column with RAND() values in an ORDER BY clause, because ORDER BY would evaluate the column…
-
2
votes3
answers44020
views -
3
votes1
answer124
viewsA: What is the difference between Start and Publish on an Eclipse server?
Start: starts Tomcat service by eclipse. Publish: Puts code or jsp modifications into effect without having to restart the server. Publishing involves copying files (projects, resources and server…
-
5
votes3
answers394
viewsA: How to fill an Object value automatically in php?
With PDO you can pick up a standard object just by specifying the type of return of consultation PDO::FETCH_OBJ: $db = new PDO('mysql:host=localhost;dbname=test','usuario','senha'); $sql = "select *…
-
3
votes2
answers385
viewsA: Innodb and Myisam generating Table already exists error
Find the folder where the database files are and remove them: Select @@datadir Access the folder returned by select enter the corresponding database and delete the. MYD, . FRM and MYI files.…
-
4
votes3
answers614
viewsA: Database query in Postgresql
The GROUP BY mysql does not adhere to the sql standard, meaning it offers greater flexibility and it is not necessary to specify all columns of the from list in the group by how the documentation…
-
7
votes2
answers6602
viewsA: Insert data into database using mysqli
To use mysqli with Prepared statements is the following code: $mysqli = new mysqli('host','usuario','senha','base'); $sql = 'INSERT INTO tabela (campo1, campo2, campo3) values(?,?,?)'; $stmt =…
-
3
votes3
answers15493
viewsA: How to add the results of an array brought from the PHP database?
Array_sum does not work as expected pq mysql_query() returns only a row and not the entire array, for example: SELECT valor FROM tabela will be returned to line: Array ( [0] => 150 [valor] =>…
-
0
votes3
answers720
viewsA: How to find values in pascal
In the name search, take the name typed put in a variable then create a for to list all elements, within it enter a if which checks if name is equal to the current entry in the record. Note that a…
-
1
votes2
answers404
viewsA: Using Mysqli, error query
To use a connection to PDO, call him and not the mysqli in place of : $conn = new mysqli($host1, $user, $pass, $bd); swap for: $conn = new PDO('mysql:host=localhost;dbname=base', 'usuario',…
-
3
votes1
answer100
viewsA: Mysql connection by Pdo does not exist
It seems that your constructor does not run as soon as the connection is not created, because the name is incorrect _construct() should be __construct() constructors - manual change: public function…
-
2
votes3
answers176
viewsA: Login system
Do not use single quotes in table names, only in values. $db = mysql_query("SELECT * FROM 'users' WHERE nome = '$nome' and password = '$password' ") or die(mysql_error()); $num_row =…
-
6
votes3
answers24936
viewsA: Last position of an Array
To leave the array in the last element use the function end() $arr = array ('maça', 'banana', 'melancia', 'morango', 'uva'); echo end($arr); the exit is : uva…
-
2
votes1
answer1371
viewsA: Edit a news page
It appears to be syntax error only, there’s a comma left before the where, remove her. $sql = "UPDATE noticias SET titulo='".mysql_real_escape_string($_POST['titulo'])."',…
-
18
votes2
answers6538
viewsQ: Meaning of ?: ?= ?! ? <= ? <! in a regex
In several regex I noticed some symbols that do not seem to be part of the capture but some kind of functionality. I would like to know the name or term of these symbols and what is the…
-
4
votes2
answers919
viewsA: Separate time and search between dd/mm/yyyy dates
It is recommended to use fields date for date and timestamp for date and time in your tables, date fields as varchar has several problems in sorting and searching. To get around this situation use…
-
3
votes2
answers204
viewsA: How to split a string in PHP?
Another approach is to use a regex for the string after btih: and use explode() to catch all the Seeds(udp://tracker.com:80) preg_match('/(?:btih:)+([a-z0-9]+)(?:&dn=)/i', $link, $torrent);…
-
2
votes3
answers1650
viewsA: How to turn a query into a json?
Simplify your code by removing variables $codigo $nome... and just pass $linha and convert the array to json only after while: $arr = array(); while ($linha = mysql_fetch_array( $chamaDados ) ) {…
-
3
votes1
answer88
viewsA: Doubt in the comparison of variables
If you need to find (compare) a value, you can transform these variables($a, $b, $c e $d) in an array and then search with the in_array(), the first argument($numero) is what you want to seek and…
-
12
votes1
answer50072
viewsA: How to get in SQL the last record inserted according to its date
Select the last record by sorting by the date decreasing and restricting the number of lines with limit or top SELECT Ped.Quantidade FROM ped WHERE data <=@data ORDER BY data DESC limit 1 or…
-
1
votes3
answers6487
viewsA: How to take ID from another table and INSERT into another?
The mysql_* functions are deprecated the use of mysqli or PDO is recommended. In this question has a list of arguments for NOT using them. To get the last id inserted use the function…
-
5
votes1
answer591
viewsA: Is it possible to convert a pseudocode to portugol?
← It means sign of assignment, it needs to be exchanged for = pseudo code: mGeral ← mGeral + Idade in portugol turns: mGeral = mGeral + Idade…
-
3
votes2
answers464
viewsA: Portugol expecting a value of the "real" type
There is an error of logic missing increment cont if not it will always be smaller want QTD in that code add the line cont = cont + 1 after reading(N3) faca{ leia(N1) leia(N2) leia(N3) }…
-
31
votes3
answers4357
viewsQ: Difference between Date, sql. Date and Calendar
What is the difference between the classes java.util.Date, java.sql.Date and java.util.Calendar and in which situations the use of one or the other is recommended?…