Hi all i am getting following error when i try to connect odbc_connect using php/mssql

MS SQL / DSN Test

Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in c:\easyphp\www\sqlserver.php on line 11

Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in c:\easyphp\www\sqlserver.php on line 12
 ContributionDate Contribution 
Warning: odbc_fetch_row(): supplied argument is not a valid ODBC result resource in c:\easyphp\www\sqlserver.php on line 16

Warning: odbc_free_result(): supplied argument is not a valid ODBC result resource in c:\easyphp\www\sqlserver.php on line 27

Warning: odbc_close(): supplied argument is not a valid ODBC-Link resource in c:\easyphp\www\sqlserver.php on line 28

BELOW IS MY PHP PROGRAM

<html>
<head><title>PHP SQL TEST</title></head>
<body>
<h2>MS SQL / DSN Test</h2>
<table border="1">
<?php
 $ConnString="DRIVER={saigopal};SERVER=system12;DATABASE=Top100";
 $DB_User="team100ro";
 $DB_Passwd="team100ro";
 $QueryString="SELECT ContributionDate, Contribution FROM tblContributionsfhf";
 $Connect = odbc_connect( $ConnString, $DB_User, $DB_Passwd );  
$Result = odbc_exec( $Connect, $QueryString ); echo "\t" . "<tr>\n"; echo "\t\t" . "<td>ContributionDate</td><td>Contribution</td>" . "\n"; while( odbc_fetch_row( $Result ) ) { $id = odbc_result($Result,"id"); $ContributionDate = odbc_result($Result,"ContributionDate"); $Contribution = odbc_result($Result,"Contribution"); echo "\t" . "<tr>\n"; echo "\t\t" . "<td>" . $ContributionDate . "</td><td>" . $Contribution . "</td>\n"; echo "\t" . "</tr>\n"; } odbc_free_result( $Result ); odbc_close( $Connect ); ?> </table>

    See what error is reported after each call to an odbc function

    if (odbc_error())
             {
                   echo odbc_errormsg($connect);
             }
    

    Your SELECT is probably wrong. It also doesn't have column "id", which you try to get from the result...

      Write a Reply...