Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    42

    Unanswered: Warning: odbc_exec(): From access

    Hey,

    I'm trying to extract some data from an access database. This is my error:

    Code:
    Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect in c:\program files\apache group\apache2\htdocs\cfm\cfm\2.php on line 35
    This error is party because im not inserting data hwnce the too few parameters. This is my code:

    Code:
    <?php
    
    function HTML_Head() {
        echo "
        <HTML><HEAD>
        <TITLE>Processing Form</TITLE>
        </HEAD>";
    }
    
    function HTML_Foot() {
        echo "</body></html>";
    }
    
    function Database_Entries($msg) {
        echo $msg;
    }
    
    function Output_Entries() {
        /*
            Make the connection to the database. The syntax is
            odbc_connect( 'SYSTEM_DSN' , 'USER', 'PASSWORD' );
            $cnx will hold the
            pconnect is used to establish a persistent database
            connection to the Database until the procedure is completed.
        */
    
        $cnx = odbc_connect( 'cfm1' , 'cfm', 'password' );
        if (!$cnx) {
            Error_handler( "Error in odbc_connect" , $cnx );
        }
    
        // send a simple odbc query . returns an odbc cursor
    	//$client = $_POST['client_id'];
    	//echo "$client";
        $cur= odbc_exec( $cnx, "SELECT ClientID, title, title2, surname, surname2 FROM MainClients WHERE ClientID = 4" );
        if (!$cur) {
            Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
        }
        
        $nbrow=0;   //Local variable to count number of rows
    
        // fetch the succesive result rows
        while( odbc_fetch_row( $cur ) ) {
            $nbrow++;
            $ClientID= odbc_result( $cur, 1 ); // get the field "Index"
            $title= odbc_result( $cur, 2 ); // get the field "FirstName"
            $title2= odbc_result( $cur, 3 ); // get the field "LastName"
            $surname= odbc_result( $cur, 4 ); // get the field "PhoneNumber"
    		$surname2= odbc_result( $cur, 5 ); // get the field "PhoneNumber"
    		echo "Confidential<br /> Client Fact Find<br /><br />Central FinancialManagement (Warwickshire) Ltd
    		<br/> Independant Financial Advisers<br />13 Swan Street<br />Alcester<br />Warwickshire<br />B49 5DP<br /><br />";
         echo "<table width=\"100%\"  border=\"1\">";
    	 echo "<tr><td colspan=\"3\">Clients"."</td>";
    			echo "<td colspan=\"5\">Name of client / ID Number $ClientID"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Spacer<br><br>"."</td>";
    			    echo "<td colspan=\"6\">"."</td></tr>";
         echo "<tr><td colspan=\"2\">Adviser"."</td>";
    			    echo "<td colspan=\"6\">Adviser Input"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Date of First Meeting:"."</td>";
    			    echo "<td colspan=\"6\">Adviser Input"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Adviser"."</td>";
    			    echo "<td colspan=\"6\">Adviser Input"."</td></tr>";
    	 echo "<tr><td colspan=\"8\" align=\"Center\"><strong>Personal Details</strong>"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">"."</td>";
    	            echo "<td colspan=\"4\" width=\"300\">Self"."</td>";
    			    echo "<td colspan=\"4\" width=\"300\">Partner"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Full Name:"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Address:<br><br><br>"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Telephone Numbers:<br>Home / work / mobile<br>"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">home e-mail address:<br><br>"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Date Of Brith:<br><br>"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    	 echo "<tr><td colspan=\"8\" align=\"Center\"><strong>Family Details</strong>"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">Self"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">Partner"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">marital Status:<br><br>"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Dependent Children:<br><br>"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Non-Dependent children:<br><br>"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    	 echo "<tr><td colspan=\"2\">Other Dependents:<br><br>"."</td>";
    	            echo "<td colspan=\"3\" width=\"400\">1"."</td>";
    			    echo "<td colspan=\"3\" width=\"400\">2"."</td></tr>";
    			
    		   	
        }
    
       // echo "<tr><td colspan=2>$nbrow entries </td></tr></table>";
    
        // close the connection. important if persistent connection are "On"
        odbc_close( $cnx);
    //}
    
     function Error_Handler( $msg, $cnx ) {
        echo "$msg  BNOOOOOO\n";
        odbc_close( $cnx);
        exit();
    }
    
    // function Enter_New_Entry($FirstName,$LastName,$PhoneNumber) {
    
        /*
            First, we create a connection to our ODBC source. This is done by creating
            a connection. Once this is done, we are returned an ODBC connection number.
            We use this number to use the ODBC functions within PHP.
        */
    
       // $cnx = odbc_connect( 'cfm1' , 'cfm', 'charlie' );
        //if (!$cnx) {
        //    Error_handler( "Error in odbc_connect" , $cnx );
      //  }
       // $SQL_Exec_String = "Insert Into People (FirstName, LastName, PhoneNumber)
            //   Values ('$FirstName', '$LastName', '$PhoneNumber')";
    
        $cur= odbc_exec( $cnx, $SQL_Exec_String );
        if (!$cur) {
           Error_handler( "Error in odbc_exec( no cursor returned G A Y ) " , $cnx );
       }
    
        odbc_close( $cnx);
    }
    
    //$strOldEntries = "Previous Entries in database";
    $strNewEntries = "Updated version of databse (after entries)";
    
    HTML_Head();
    Database_Entries($strOldEntries);
    Output_Entries();
    //Enter_New_Entry($FirstName,$LastName,$PhoneNumber);
    //Database_Entries($strNewEntries);
    //Output_Entries();
    HTML_Foot();
    
    ?>
    How can I combat this? I only want to extract data from the database, no inserting is necessary.

    Thanks for any pointers. This is a no brainer for me.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    does it work if you try:
    ...MainClients WHERE ClientID = 4;" )

    izy
    Last edited by izyrider; 11-28-04 at 11:23. Reason: regret posting: probably talking bu££$#1t
    currently using SS 2008R2

  3. #3
    Join Date
    Mar 2004
    Posts
    42
    thats for the query.

    "SELECT ClientID, title, title2, surname, surname2 FROM MainClients WHERE ClientID = 4"

    Client Id will be dynamic, ie the customer will select the client ID then ill pass it over as a variable to this page.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    sorry my friend - i edited my post while you were replying to it: so now your reply doesn't relate to what my (edited) post reads. the incoherence is all mine.

    i'm backing out of this one: i have no idea what sort of code you are playing with but it is certainly not VBA - the only pathetic suggestion i can come up with is to include a terminating semi-colon in your SQL string.

    best of luck, izy
    currently using SS 2008R2

  5. #5
    Join Date
    Mar 2004
    Posts
    42
    that didn't work.

    Its just some php script i've got off the net, its not great but im not very good with all this odbc connections.

    THe error relates to an insert error or something but i don't want to insert anything.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •