0
I am making a form for editing materials (products).
I am viewing the list of materials and I created in my form a button that passes my IdItem
.
I’m in error:
Warning: sqlsrv_fetch_array() expects Parameter 1 to be Resource, Boolean Given in D: xampp5.6 htdocs sysriomed bank-material.php on line 27
function buscaMaterial($conn, $IdItem){
$query = "select m.id as IdMat, I.id as IdItem, M.nome, M.tipo, I.nSerie ,I.valorUnitario from medx.dbo.material as M, medx.dbo.itemMaterial as I on M.id=I.idMaterial where IdItem = {$IdItem}";
$resultado = sqlsrv_query($conn, $query);
return sqlsrv_fetch_array($resultado, SQLSRV_FETCH_ASSOC);
}
I am working with SQL Server 2014 and PHP 5.6.
banco-material.php
is where are my duties related to materials.material-altera-formulario
is the data editing form.lista-material.php
is my material list.
Looks like your query failed.
– rray
But in the database it works
– fabricio_wm
Put the query code there.
– rray
I edited by code. I had already posted all the content in git. sqlsrv_fetch_array return multiple or one result?
– fabricio_wm
Leave it at that:
$resultado = sqlsrv_query($conn, $query) or die(print_r(sqlsrv_errors()));
Returns only one element.– rray
Returned this: Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 156 [code] => 156 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax pr xima keyword 'on'. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax pr xima keyword 'on'. ) )
– fabricio_wm
Let’s go continue this discussion in chat.
– fabricio_wm
Has syntax error :P seems to have missed the
INNER JOIN
before theON
– rray
Array ( [0] => Array ( [0] => 42S22 [SQLSTATE] => 42S22 [1] => 207 [code] => 207 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Column name 'Iditem' read. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Column name 'Iditem' read. ) ) 1
– fabricio_wm
I put and is giving that column name is invalid
– fabricio_wm
vc cannot use the alias in Where or Join, should use the original column name in case
I.id
– rray