Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8142737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:54:21+00:00 2026-06-06T12:54:21+00:00

I am using the ODBC extension in PHP to connect to an SQL 2000

  • 0

I am using the ODBC extension in PHP to connect to an SQL 2000 server. Here is what I am up against:

  1. I can execute queries with odbc_exec() OR
  2. I can execute queries with odbc_execute()

In my opinion, the differences between these two query executing methods are nearly as different as night and day:

  1. odbc_exec() will execute a non SQL-safe query and return the results from the query
  2. odbc_execute() is used in conjunction with odbc_prepare() to execute an SQL safe query on the database. However, odbc_execute() can only ever return a boolean, and therefore cannot be used to return the results from a SELECT statement, or to check how many rows were updated from an UPDATE or DELETE statement

Is this really the way this all works, or is there some way to escape values for use in odbc_exec() or to get the results back from odbc_execute()?

The PHP documentation doesn’t seem to over any solutions for the above dilemma.

Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:54:23+00:00Added an answer on June 6, 2026 at 12:54 pm

    The resource for the query you’re running is returned by the odbc_prepare function, not odbc_execute.

    These two blocks of code do the same thing:

    $query=odbc_exec("SELECT * FROM table WHERE userinput=".$hopefully_escaped_user_input);
    while($row=odbc_fetch_array($query) {
      //do stuff with $row
    }
    
    
    
    $query=odbc_prepare("SELECT * FROM table WHERE userinput=?");
    odbc_execute($query,Array($user_input);
    while($row=odbc_fetch_array($query) {
      //do stuff with $row
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using C++ to query a SQL Server 2005 database using ODBC. The queries
I want to connect php to Access without using ODBC connection like MySQL. Please
I'm trying to connect to an access database from a php script using ODBC.
what are the various other programs using which i can connect to odbc database
I have connected sqlserver using ODBC in php. I'm able to connect the database
Here is my sub for updating a Database using ODBC: Public Sub UpdateDatabase(ByVal sql
I am able to successfully connect from access 2007 into SQL Server 2008 using
I am using an ODBC connnection to connect to a database. When I execute
How do I connect to a database on other computer using ODBC connection? Let
I'm using a Odbc connection to a mysql server, and was wondering how I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.