Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old April 22nd, 2003, 11:27 AM
hirenpathak hirenpathak is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 14 hirenpathak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 34 sec
Reputation Power: 0
Question PHP - MSAccess Connection.

Hi ,
I am trying to connect Ms Access database using PHP. I am running Apache on my computer.
I created DSN for MSAccess. but for odbc_connect() function I am getting this error.
"SQL error: , SQL state 00000 in SQLConnect...\...\databaseconn.php line 3"

what could be the reason..?

Reply With Quote
  #2  
Old April 23rd, 2003, 11:22 AM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Which version of PHP are you using?
Which OS is PHP running on?
Have you setup your php.ini file correctly ?
__________________
El éxito consiste en una serie de pequeñas victorias día a día

MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html

Reply With Quote
  #3  
Old April 23rd, 2003, 12:15 PM
hirenpathak hirenpathak is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 14 hirenpathak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 34 sec
Reputation Power: 0
Yeah,
I have windows 2000 OS. my php version is 4.0. I already configured my php.ini file. and rest of the things are working fine. The only problem is with Access connection. its not executing my odbc_exec() function.


Reply With Quote
  #4  
Old April 24th, 2003, 01:35 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Can you verify that you are creating a valid MySQL resouce link from odbc_connect() function?

Reply With Quote
  #5  
Old April 24th, 2003, 07:24 PM
hirenpathak hirenpathak is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 14 hirenpathak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 34 sec
Reputation Power: 0
Ok ...here is what i m trying to do.

<?
$connect = odbc_connect("prod","","") // "prod" is my DSN name

// I am trying to connect MSAccess database using PHP and i have apache running on my computer.
$query = "select * from blah_blah";
$result = odbc_exec($connect, $query);

...... the way to display the result.....



?>

...hey..wait...i just got one thought...shoudl I put my .mdb file in apache's htdocs/ ? I dont think so...right..? i can put it in my c:/ because i have already created DSN to connect with DB.

anyway...thats what i m trying to do..but i am getting that error.
any idea...?

Reply With Quote
  #6  
Old April 25th, 2003, 08:51 AM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Verify that you have a valid connection by returning the value of `$connect`. This check just ensures that the connection was successful.

Reply With Quote
  #7  
Old April 25th, 2003, 10:56 AM
hirenpathak hirenpathak is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 14 hirenpathak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 34 sec
Reputation Power: 0
the error comes at the first line of my code. and it is.. at
$connect = odbc_connect("prod","","");

"SQL error: , SQL state 00000 in SQLConnect...\...\databaseconn.php line 3"

so How can I print the result for $connect. ?

Reply With Quote
  #8  
Old April 28th, 2003, 02:29 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Can you try this?
$link_id = @odbc_connect("prod","","") or die ("Unable to connect to server");
print $link_id;

Reply With Quote
  #9  
Old April 28th, 2003, 02:34 PM
hirenpathak hirenpathak is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 14 hirenpathak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 34 sec
Reputation Power: 0
yeah,
It says....Unable to connect to server. ...

I am too much frustrated now.
here is my whole code..
<?
// This is the DSN we have created for our database
$connect = @odbc_connect('prod', '', '') or die("Unable to connect");

echo "<br>".$connect."<br>";
?>
<HTML>
<BODY>

Database connection testing.....
<BR>

<?
global $connect;

$noderesult = odbc_exec($connect,"select Unit_id, Unit_Name from Mfg_Units");
echo "<UL type='disc'>";
while(odbc_fetch_row($noderesult))
{
$id = odbc_result($noderesult,"Unit_id");
$type = odbc_result($noderesult,"Unit_Name");
echo "<LI>";
echo "<b>$id</b>&nbsp;&nbsp;&nbsp; --- $type";
}
echo "</UL>";

?>
</BODY>
</HTML>

Reply With Quote
  #10  
Old April 28th, 2003, 03:43 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,827 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 22 h 57 m 29 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Ok, a couple of questions.
1) Are you sure the mdb file was registered as a datasource? i.e. can you open back up the odbc manager and see the file as a "system" dsn (which it must be registered as system and not user).

2) has the file been moved?
3) can you still open the file?
4) is it password protected?

I just registered one on my system and accessed it just fine using the same connect statement that you did, so the syntax is correct.

Reply With Quote
  #11  
Old April 29th, 2003, 07:54 AM
hirenpathak hirenpathak is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 14 hirenpathak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 34 sec
Reputation Power: 0
yeah datasource is correct and it is "System" DSN only. even .mdb is also fine and working perfect in Access environment. I have one doubt ...do I have to modify something in php.ini file.? or is this related to some server configuration..?

Reply With Quote
  #12  
Old April 29th, 2003, 08:05 AM
hirenpathak hirenpathak is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 14 hirenpathak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 34 sec
Reputation Power: 0
hey hey....
I got it...its working now. Thanks a lot. I just re created my system DSN and now its working perfectly.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > PHP - MSAccess Connection.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |