Hello everyone, here is a piece of code in which the following should occur: the file name (current) is checked and its name is stored in the variable Fname, then a query is made in the database in which you need to pull out the value of a specific cell in the line, orienting to the cell in the same line under name Pname which contains what is stored in the variable Pname

$query= "SELECT Ptittle FROM dbo.Pcontent WHERE Pname='$Fname'"; $result = sqlsrv_query ($conn,$query); $myrow = sqlsrv_fetch_array ($result); echo $myrow; ?> 

when working out the script, such an error occurs:

 PHP Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\technet\mopr.php on line 25 

line 25:

  $myrow = sqlsrv_fetch_array ($result); 

1 answer 1

Everything is very simple. sqlsrv_query ($conn,$query); fails and returns false , not the result set.

Use sqlsrv_errors to view the error that occurred.

  • I can not compile how to do what I need: With if I remove the sample by WHERE, then everything works, but not quite, Resours id # 6 returns, how would I get the value out of the cell focusing on the variable - qaz qaz
  • @qazqaz added an answer - rjhdby