Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.