Kill connect problem ASPLinux+PHP+FreeTDS+unixODBC+MSSQL7

Alex softer at pisem.net
Wed Jun 19 02:41:06 EDT 2002


Hi All!

Script bellow work fine, but connect to MSSQL7 remainder after it.
How can I kill connect ?

---------------------------- execute.html
<html>

<head>
<title>PHP/ODBC demo</title>
</head>

<body bgcolor="#FFFFFF">

<p>Enter a DSN, database username/password and the required SQL and submit
to execute
<p>
If you do not need a database username/password leave those fields empty.
<p>
<form action="execute.phtml" target=_blank method="post">
  DataSource Name:
  <input text name="dsn" maxlength="60"></input>
  <br>DB Username:
  <input text name="username" maxlength="60"></input>
  <br>DB Password:
  <input password name="password" maxlength="60"></input>
  <br>SQL<br>
  <textarea name="sql" rows="8" cols="60"></textarea>
  <p><input type="submit" value="Execute Query"> </p>
</form>

</body>
</html>

---------------------------- execute.phtml
<html>
<head>
<title>PHP/ODBC Example</title>
</head>
<body>
<h1>PHP/ODBC example</h1>
<p>
Please make sure your php.ini file is installed correctly and that
track_errors = on or if this example fails you will not be able to
get an error message indicating why.
<p>
<?
    /* 
     * connect to server 
     */
    echo "<p>Attempting to connect to DSN $dsn<p>";
    $dbc = @odbc_connect($dsn, $username, $password);
        
    if (!$dbc) {
	/*
	 *  To get php_errormsg make sure track_errors = on in your
	 *  PHP ini file.
	 */
 	echo $php_errormsg;
        die("Connection failed");
    } else {
 	/*
         * run the query
         */
        echo "<p>Running query \"$sql\"<p>";
        $rid = odbc_exec($dbc, $sql);
        if (!$rid) {
	    echo $php_errormsg;
            die("Execute failed");
        } else {
            /*
             * check if there are any result columns
             */
            $num_fields = odbc_num_fields($rid);
            if ( $num_fields == 0 )
            {
                echo "Operation succeeded\n";
                echo "<p>".odbc_num_rows($rid)." rows altered\n";
            }
            else if ($num_fields > 0)
            {
                odbc_result_all($rid, "border");
            }
            else 
            {
                die( "odbc_num_fields() returns -1" );
            }
            odbc_free_result($rid);
        }
        odbc_close($dbc);
    }
?>
</body>
</html>



More information about the FreeTDS mailing list