no both the things are not working!
actually mysql_connect('localhost', 'user', 'pass');
is written when we use mysql database only but i want to use ODBC so this syntax would not work.ofcourse my database is mysql.
I am not familiar with the ODBC ways to connect to MySQL. Still the logic is always the same:
1. Connect to DB
2. Select DB
3. Enter query
4. Get results from query
5. Close connection
You should follow these steps whatever way of connection you use with the DB.
so, you should do smth like this:
[php]
//1. Connect
$connect = odbc_connect(database, user, pass);
//2. I assume that for ODBC database selection is done with the connect opiton...Still you have to check more in detail the php manual.
//3.Enter query
$query = 'SELECT STATEMENT GOES HERE';
$runquery = odbc_exec($connect, $query);
//4. Retrieve information
$rowsAffected = odbc_num_rows($runquery);
for ($i=0; $i<$rowsAffected; $i++)
{
$result[$i]=odbc_fetch_array($runquery);
}
[/php]
You should be able then to read the $result[] array to retrieve data. Note that result[0] will hold another array what may be accessed using the column name for each item. E.G. if your table column name is 'username' you can access the data in the array like this:
[php]
$resultrow = $result[0];
echo $resultrow['username'];
[/php]
Good luck