Jump to content

MSSQL query


cooperd

Recommended Posts

Hello,

 

I am trying to query an SQL Server database from a php page. I am using the following code:

 

$sql="SELECT [Adjust] FROM dbo.[ProjectData] WHERE ([ProjectNumber] = '".$_GET[pn]."')";

$res = mssql_query($sql, $conn);

$row = mssql_fetch_assoc($res);

echo sprintf($row["Adjust"]);

 

This gives me a query value string SELECT [Adjust] FROM dbo.[ProjectData] WHERE ([ProjectNumber] = '1077') .  When I execute this query in SQL Server Management Studio I get the correct result, but the above code is returning a null value.  I know that my connection string is good.  If anyone could help me out I would appreciate it.

 

Thanks,

 

Dave

Link to comment
https://forums.phpfreaks.com/topic/183910-mssql-query/
Share on other sites

Have you tried echoing out the $sql and making sure all the data there is what you expect it to be? That would be my first check and if you could post the results after you echo out the $sql that would be great :)

 

EDIT: Try that after seeing if there was an error as rajiv suggested.

Link to comment
https://forums.phpfreaks.com/topic/183910-mssql-query/#findComment-970876
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.