Solved

PHP Excel Query

Posted on 2002-05-21
7
385 Views
Last Modified: 2012-05-04
hello,
I'm very familiar with querying MS Access databases.  To this point I have had not problems.  I am being forced to query an Excel file now and am having countless problems.  I am using the following code to connect to the database:

$con = odbc_connect("datatest", "", "");

that works great!

when I attempt to query a datasheet named 'names' I get the following error:

Warning: SQL error: [Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'names'. Make sure the object exists and that you spell its name and the path name correctly., SQL state S0002 in SQLExecDirect in c:\phpdev\www\connect2.php3 on line 4

it is able to connect to the excel database datatest so I know that the Excel datasource is working.

If anyone can provide the solution i'd be very greatful.

Nathan
0
Comment
Question by:phenixfilms
  • 2
7 Comments
 
LVL 4

Accepted Solution

by:
lokeshv earned 100 total points
ID: 7025891
cna u post ur code here ?

a alternate way....
http://www.phpclasses.org/browse.html/file/274.html

Lk
0
 
LVL 1

Author Comment

by:phenixfilms
ID: 7026129
<?
$con = odbc_connect("datatest", "", "");
$Query = "SELECT * FROM names";
$query_exe = odbc_do($con, $Query);
while(odbc_fetch_row($query_exe))
{
#for each of the records found#
print "Found a record<br>";
}

?>
0
 
LVL 40

Assisted Solution

by:RQuadling
RQuadling earned 100 total points
ID: 7026499
I've just tried setting up an ODBC Excel link via MSQuery.

It seems that you have to have Tables and System Tables turned on to be able to get to the sheets.

The names of the sheets I have are ...

Sheet1$,Sheet2$,Sheet3$ and a chart sheet called Sheet1$_

FOr me, only the first one has any data on it.

As the names include the $ at the end, what about adding that in your code?

Richard.
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 11664829
My comments explain a bit towards getting the answer but no comments again.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now