Drew
Drew

Reputation:

Headache getting php and sql server 2005 to run together

Below is the code that i cannot get to work. I know i have established a connection to the database but this returns nothing. What am i doing wrong?

$result = "SELECT * FROM images WHERE path = ?";
$params = array("blah");
$row = sqlsrv_query($conn, $result, $params);

$finished = sqlsrv_fetch_array($row);


if($finished)
{
echo "blach";
}

Upvotes: 1

Views: 1586

Answers (3)

matt.mercieca
matt.mercieca

Reputation: 873

What if you don't use a literal? Most of the MSDN examples use variables.

I'd try:

$result = "SELECT * FROM images WHERE path = ?";
$var = "blah";
$row = sqlsrv_query($conn, $result, array($var));

$finished = sqlsrv_fetch_array($row);

Upvotes: 0

Tom Haigh
Tom Haigh

Reputation: 57815

Would it be worth checking that the query is not returning an error?

$result = "SELECT * FROM images WHERE path = ?";
$params = array("blah");
$row = sqlsrv_query($conn, $result, $params);

if( $row === false ) {
    print_r(sqlsrv_errors());
}

Upvotes: 0

user29149
user29149

Reputation: 11

You may need to replace your ntwdblib.dll as explanied on the mssql_connect() page of the php.net manual.

Upvotes: 1

Related Questions