-1

i still new in sqlserver and i trying to fetch database like this

$sql = "select top 1 pdate from j2365join_transaction_old where order by pdate desc";
$mulaisql = sqlsrv_query($sqlconn2, $sql, array(), array( "Scrollable" => 'static'));
$mulai = sqlsrv_fetch_array ($mulaisql, SQLSRV_FETCH_ASSOC);
print_r ($mulai);

but go error

sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given

, can someone explain to me why i got this error, thanks

Nikhil Vaghela
  • 2,045
  • 2
  • 13
  • 28
Pentolan
  • 161
  • 10

1 Answers1

0

Error in your query my friend.

$sql = "select top 1 pdate from j2365join_transaction_old where order by pdate desc";

You should write condition after where clause. If there is no WHERE condition then please remove WHERE clause. So your query will we right

$sql = 'select "top 1 pdate" from j2365join_transaction_old  order by pdate desc';

Generally you should not use spaces in column, although you have done then you can read it by using

Quote ("field name")

Large brackets

"[field name]"

With backticks

SELECT * FROM `Area One`
Noman
  • 4,012
  • 1
  • 20
  • 35
Nilesh Daldra
  • 84
  • 1
  • 9