Jump to content

MS SQL PHP Connection Test Apache2 Server


kat35601

Recommended Posts

I created this to test the connection to my ms sql server with a web page. I can connect with isql with out fail.

when I open this I get

 

PHP SQL Test

END PHP SQL Test

 

I was expecting to get sql data between the above lines. What am I doing wrong.

 

 

<html>
<head>
<title>PHP SQL Test</title>
</head>
<body>
<p> PHP SQL Test </p>

<?
$conn =odbc_connect("datasource","user","password");
if(!$conn) {
    exit("Connection Failed: " . $conn);
}

$sql="SELECT top 10 * from WIP_master";
$rs =odbc_exec($conn,$sql);
print_r($rs);
if(!$rs){
exit("Error in SQL");
}
odbc_close($conn);
?>
<p> End PHP SQL Test </p>
</body>
</html>

Link to comment
Share on other sites

There may be other problems that aren't obvious...

 

You need to make a change to your php.ini file: run phpinfo() in a script and it will tell you where you can find the file near the top. Hopefully you do have one.

In there are two settings to change:

error_reporting = -1
display_errors = on
They exist in the file somewhere and probably in two locations: one place describes a bunch of settings, the other is the actual location where the setting is defined. Possibly commented out with a semicolon, in which case you need to uncomment it after changing the value.

 

When you do that, restart Apache and run phpinfo() again. Then look for those two settings - they should have the new values.

 

Then try your script again. There will probably be some kind of error message. Or more than one.

Link to comment
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.