Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help Forums Windows Startup Programs Database Virus, Spyware, and Malware Removal Guides Computer Tutorials Uninstall Database File Database Computer Glossary Computer Resources
 

Welcome Guest ( Log In | Click here to Register a free account now! )



Register a free account to unlock additional features at BleepingComputer.com
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.
Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

> PHP connecting to ODBC
KamakaZ
post Sep 17 2009, 02:14 AM
Post #1


Senior Member
****

Group: HJT Sophomore Classmen
Posts: 440
Joined: 26-August 08
From: Victoria
Member No.: 233,642



Hey,

Has anyone ever tried to use php to connect to an Advantage ODBC database on a remote server? Well the server with the database is in the same LAN i just need to open the port and from what i can tell add an extension to php.ini. I don't know what port or anything...

Brad


--------------------
If I am helping you and don't reply in 24 hours please send me a PM

Currently in training...

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies (1 - 8)
KamakaZ
post Sep 20 2009, 10:33 PM
Post #2


Senior Member
****

Group: HJT Sophomore Classmen
Posts: 440
Joined: 26-August 08
From: Victoria
Member No.: 233,642



Does anyone know how to add the extension into php.ini for ODBC databases on a linux box?


--------------------
If I am helping you and don't reply in 24 hours please send me a PM

Currently in training...

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
Go to the top of the page
 
+Quote Post
groovicus
post Sep 20 2009, 11:52 PM
Post #3


Hail Groovicus!
******

Group: Site Admin
Posts: 7,961
Joined: 5-June 04
From: Centerville, SD
Member No.: 689



You need to know what port, otherwise it will not work.


--------------------
Never Argue With Stupid People



Microsoft Senior Student Partner
Go to the top of the page
 
+Quote Post
KamakaZ
post Sep 21 2009, 12:07 AM
Post #4


Senior Member
****

Group: HJT Sophomore Classmen
Posts: 440
Joined: 26-August 08
From: Victoria
Member No.: 233,642



i have contacted the software mob... they say the person that knows will return an email to me later this week...

in the mean time, how can i go about getting my webserver ready to interact with an odbc database?

I've been looking into ODBC connectors and what not, do i need these if i going to use php to make the connection?


--------------------
If I am helping you and don't reply in 24 hours please send me a PM

Currently in training...

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
Go to the top of the page
 
+Quote Post
groovicus
post Sep 21 2009, 01:03 AM
Post #5


Hail Groovicus!
******

Group: Site Admin
Posts: 7,961
Joined: 5-June 04
From: Centerville, SD
Member No.: 689



QUOTE
in the mean time, how can i go about getting my webserver ready to interact with an odbc database?


Typically one would set up a test class to mimic connecting to a database. Meaning that one would set up a test database on their own server so that when one want s to connect to the real server, all they would need to do is change database info.

In order to connect to an Advantage db, you will need to add the proper PHP extensions. Other than that, there are tons of search results that deal with your issue. You will just have to comb through them to find what you need.


--------------------
Never Argue With Stupid People



Microsoft Senior Student Partner
Go to the top of the page
 
+Quote Post
KamakaZ
post Sep 22 2009, 01:44 AM
Post #6


Senior Member
****

Group: HJT Sophomore Classmen
Posts: 440
Joined: 26-August 08
From: Victoria
Member No.: 233,642



I've managed to get it set up and can connect to the Data Source, just can’t seem to get my head around how the odbc commands in php work.

This is the connection I have got (which works fine as the DSN is set up in windows, haven’t been able to get it to work in linux yet)

CODE
<?
$conn = odbc_connect("GunnSrvModODBC", "", "");
$query = "SELECT * FROM DSTOCK LIMIT 0, 10";
?>



DSTOCK is a valid table and has data in it, whenever i try to call data from it it returns a blank page not matter what odbc_ function i try to use...

Can someone please help with this?

Cheers,

~Kam


--------------------
If I am helping you and don't reply in 24 hours please send me a PM

Currently in training...

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
Go to the top of the page
 
+Quote Post
groovicus
post Sep 22 2009, 10:19 AM
Post #7


Hail Groovicus!
******

Group: Site Admin
Posts: 7,961
Joined: 5-June 04
From: Centerville, SD
Member No.: 689



You have a connection to the database, and you have a sql query that you want to send to the database; now you have to actually send the query to the database. Here is how I did it in a recent project. The type of database is different, but the process is the same:

[code]
mysql_connect("localhost","puser", "val_puser") or die(mysql_error());
mysql_select_db("valiantvineyards") or die(my_sql_error());


--------------------
Never Argue With Stupid People



Microsoft Senior Student Partner
Go to the top of the page
 
+Quote Post
groovicus
post Sep 22 2009, 10:27 AM
Post #8


Hail Groovicus!
******

Group: Site Admin
Posts: 7,961
Joined: 5-June 04
From: Centerville, SD
Member No.: 689



You have a connection to the database, and you have a sql query that you want to send to the database; now you have to actually send the query to the database. Here is how I did it in a recent test project. The type of database is different, but the process is the same:

CODE
    mysql_connect("localhost","user", "pass") or die(mysql_error());
    mysql_select_db("valiantvineyards") or die(my_sql_error());
    $result = mysql_query("SELECT id, name FROM headings");

    while($row = mysql_fetch_array($result)){
        $arr = array('id' => $row['id'], 'name' => $row['name']);
    }


The first line establishes a connection to the database. the second line establishes which table to use. The third line is the actual query that gets a result set. The while loop is used to get the records from the result set, one by one. You need to spend some time learning how SQL works, and understanding the odbc docs, or you are going to have a really tough time.


--------------------
Never Argue With Stupid People



Microsoft Senior Student Partner
Go to the top of the page
 
+Quote Post
KamakaZ
post Sep 22 2009, 05:40 PM
Post #9


Senior Member
****

Group: HJT Sophomore Classmen
Posts: 440
Joined: 26-August 08
From: Victoria
Member No.: 233,642



i know how to do mysql_query 's but with an odbc database, well this is what i'm making of it, you have to prepare the query with odbc_prepare then you have to execute the prepared query with some parameters. Also unlike mySQL you don't have to select the database as this is all done with the ODBC connector.


--------------------
If I am helping you and don't reply in 24 hours please send me a PM

Currently in training...

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 22nd November 2009 - 12:08 AM


Advertise   |   About Us   |   Terms of Use   |   Privacy Policy   |   Contact Us   |   Site Map   |   Chat   |   Tutorials   |   Uninstall List
Discussion Forums   |   The Computer Glossary   |   Resources   |   RSS Feeds   |   Startups   |   The File Database   |   Virus Removal Guides

© 2003-2009 All Rights Reserved Bleeping Computer LLC.