MAMP Pro - ODBC - PHP - MySQL

I am starting a training series tomorrow, and the class files were sent to me in different formats, JSP, ASP, PHP, etc.  Well I am using MAMP Pro on my mac, so I of course chose to use PHP.  Well the PHP files contain this odbc_connect("Presidents", , ) line to connect to a DB.  I was told this is DSN???  I noticed that there is a program called ODBC Administrator which is for setting up DSN's, this software comes with my Mac.  I have setup all of the DB's correctly in MySQL, so that is good to go.  And I even downloaded the mysql ODBC driver, which now shows up in ODBC, but I still can't figure out what to do from here.

This is a MAJOR rush!  

Another point, should I just go in and change all of the connection files to just connect to MySQL normally, the way I normally do in PHP?

$connect = odbc_connect("Presidents","","");
		
	$sql = "SELECT FirstName, LastName, StartYear, EndYear, ImagePath 
			FROM Presidents WHERE PresidentID=" . $_GET["Slide"];
	
	$rs = odbc_exec($connect, $sql);
	
	if ( $row = odbc_fetch_row($rs) )
	{
		$firstName = odbc_result($rs, 1);
		$lastName = odbc_result($rs, 2);
		$startYear = odbc_result($rs, 3);
		$endYear = odbc_result($rs, 4);
		$imagePath = odbc_result($rs, 5);
		echo "<President>
			<Name>$firstName $lastName</Name>
			<Years>$startYear - $endYear</Years>
			<Image>$imagePath</Image>
			</President>";
	}
	odbc_close($connect);
}

Open in new window

tjstalcupAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

adrpoCommented:

To connect to DSN Presidents you need to add it in your ODBC Data Sources.
I don't know how is it on MAC, but in Windows, you just add another DSN, give
the odbc driver (MySQL) give the name of the database, the user, the pass and then
you need to give the name: Presidents.

The odbc_connect will go to the ODBC data sources on the system, look for
DSN: Presidents and connect to it.

Cheers,
za-k/

0
tjstalcupAuthor Commented:
So I suppose what I am in need of is how to do this in OBDC Administrator - the program on the mac.  You can add Keys & Values, but when I do, it just says Key | Value, Apple's site says to dbl-click on them to edit them, but i can't :(
0
adrpoCommented:

Here is a bit of tutorial on how you can set up ODBC to MySQL in Jaguar:
http://www.macdevcenter.com/pub/a/mac/2003/06/20/odbc.html

Maybe it sheds some light...
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

tjstalcupAuthor Commented:
It sheds some light, but it still will not allow me to edit the Key - Values
0
adrpoCommented:

It might be that there is a bug in the MySQL driver which causes
ODBC Administrator to crash when adding System DSNs:
http://bugs.mysql.com/bug.php?id=32057

You might be better off using the driver directly from PHP :)

Cheers,
za-k/
0
adrpoCommented:

Hi again,

Directly on the MySQL site:
http://dev.mysql.com/doc/refman/5.0/en/myodbc-configuration-dsn-macosx.html
Warning
There are known issues with the OS X ODBC Administrator and Connector/ODBC that may prevent you from creating a DSN using this method. In this case you should use the command-line or edit the odbc.ini file directly. Note that existing DSNs or those that you create via the myodbc3i tool can still be checked and edited using ODBC Administrator.

Cheers,
za-k/
0
tjstalcupAuthor Commented:
Yeah, I saw that earlier, the terminal command-line launches the Connector/ODBC which then freezes, so I don't understand that.

And I can't find odbc.ini
0
adrpoCommented:

I don't know what to say here.
My experience with Mac is quite limited, and I don't have access to one to test.
I believe the odbc.ini should be in Library/ODBC/odbc.ini
You might need to create the odbc.ini file by hand if the tools
do not work properly. An example of odbc.ini is below.

Have a look at this page at the end.
It says you need to use putenv to set the paths to odbc.ini, etc.
http://www.iodbc.org/index.php?page=languages/php/php-osx-HOWTO

Cheers,
za-k/


[ODBC Data Sources]
 Presidents = MySQL 
        
 [Presidents]
 Debug = 1
 CommLog = 1
 ReadOnly = no
 Driver = /usr/local/lib/mysqlodb3.so
 Servername = 64.xxx.xxx.xx
 FetchBufferSize = 99
 Username = YOUR_USER 
 Password = YOUR_PASS
 Port = 3306
 Database = YOUR_DATABASE
 
 [Default]
 Driver = /path/to/libiodbc-3.0.5/odbcsdk/lib/oplodbc.so.1

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tjstalcupAuthor Commented:
Thanks so much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Mac OS X

From novice to tech pro — start learning today.