Questions tagged as 'php'

2
answers

___ ___ erkimt Error in MySQL "expects parameter 1 to be resource, boolean given in" ______ qstntxt ___
%pre%

I have this code and can not see error in it, but it gives me this error. I know there should already be a topic of this on the site but I have tried all the ways and nothing. Give me the bool error (false)

    
______ azszpr28190 ___

This error happens when %code% or %code% fails, it is usually a syntax error in the sql query and returns a %code% as explained in manual . For mysql_fetch _ * () to function properly you must pass a variable of type %code% or %code% which is the return of %code% / %code% on success.

To fix the error you can force mysql_ * mysqli _ mysqli _ to display the database error with the mysql_error () or mysqli_error ()

Version with old mysql functions _ *

%pre%

Version with mysqli_ * procedural

%pre%

Version with mysqli_ * OO

%pre%

The query will return this error because %code% is a reserved mysql word.

  

Error Code: 1064. You have an error in your SQL syntax; check the   manual that corresponds to your MySQL server version for the right   syntax to use near 'desc'

The other way is to print the query and test directly at the database:

%pre%

Related:

Why should not we use functions of type mysql_ *?

MySQL vs PDO - which is the most recommended for to use?

How to print the SQL statement being sent to the bank?

    
______ azszpr333477 ___

The problem occurs because the %code% method needs a parameter with the connection to the database.

I leave an example below. Remember to modify the data to connect to the bank.

I leave it as a hint for you to study using the PDO because it is safer and the %code% is already depreciated.

  

Example:

%pre%     
___

$query = "Select * from servico where ID_SERVICO = $id"; $result = mysql_query($query); if($row = mysql_fetch_array($result)) { $nome = $row['NOME']; if($nome == 'Marketing') { include ("servicos/marketing.php"); }...
asked by 07.08.2014 / 19:13
1
answer

XSS attacks, how does it happen?

Recently a client has been the victim of XSS attacks. We treat all inputs that we encounter with faults, but I can not understand how malicious javascript code was inserted into the .js files on the server. How did you change the script via X...
asked by 28.03.2014 / 15:27
2
answers

Why use error_reporting with display_errors and display_startup_errors?

I've been using it for a long time: error_reporting(E_ALL|E_STRICT); To debug scripts (note that I use E_STRICT just to maintain compatibility with older versions of PHP), but I noticed that other people often use ini_set('display_...
asked by 04.01.2016 / 02:45
2
answers

How and when should we use Interface to document systems in PHP?

I've always wanted to know exactly, if it's a good practice, to make a system always using Interfaces, or is it not necessary? Interface People { public function getName(); public function setName($string); public function getAge(); pu...
asked by 26.11.2015 / 12:45
2
answers

What is the difference, in practice, between Session and Application?

I'm studying about Web Technologies , and during my class a topic about concepts involving Session and Application came up. The technology covered during class was C# . I did not quite understand the differences between them...
asked by 27.11.2015 / 16:35
2
answers

What is the question mark in a query?

Does%% use of a query really prevent SQL injection ? Avoid 100%? I saw this code and I heard lots of people talking about it, saying it helps in this case and how to use it? Could someone give a better example? $query = "SELECT * FROM tabel...
asked by 26.06.2014 / 23:18
6
answers

How to create a password reset link?

I'm developing a site that has user registration area, the password is encrypted for increased security on the site, however when the user forgets the password how can I return the password from him unencrypted? I've seen a number of sites wh...
asked by 28.02.2014 / 18:07
3
answers

What are the most common problems and dangers when enabling 'register_globals' in php?

Recently I asked the following question How the file gets $ _POST ? Based on the comments and the answer I was interested in knowing the main problems and dangers of having this function enabled in php.ini?     
asked by 22.09.2014 / 15:56
3
answers

How to choose the largest value of an array?

I'm trying to use the max function, but I can not get it right. // variáveis da diferença salarial $saldev[0] = $_POST ["Tdate5"]; $saldev[1] = $_POST ["Tdate9"]; $saldev[2] = $_POST ["Tdate13"]; $saldev[3] = $_POST ["Tdate17"]; $salde...
asked by 21.04.2015 / 06:44
1
answer

What is the function of '@' (at) at the beginning of expressions in PHP

What is the function of @ at the start of expressions in PHP? I have seen in some classes and I could not get the function to put this @ at startup.     
asked by 10.02.2015 / 15:13