New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Web Design and Hosting Creating sites, scripting, and hosting discussions.

PHP / mySQL Project help


Post Reply New Thread Subscribe

 
Thread Tools
iRock

 
Member Since: Feb 09, 2005
Posts: 842
iRock will become famous soon enough

iRock is offline
Hey everyone,

I have a project that I got to get done. Its work related to I cant go into to much detail. Its pretty basic actually I just need someone to tell me what exactly I need.

Ok, I have an .exe file (I know this is mac-forums!) that queries an Access Database. So, I am going to take the database from there.

I have to just integrate it into a webpage.... It should just be a basic page that can query the DB etc.

Can anyone tell me what exactly I need.

Im guessing I just need a little PHP.. and I assume it isnt anything major.
Im sure I could create maybe some sort of a barebones page and "Skin" it?

All help greatly appreciated!

Thanks

iRock
QUOTE Thanks
iRock

 
Member Since: Feb 09, 2005
Posts: 842
iRock will become famous soon enough

iRock is offline
Bump...... anyone able to help me out?
QUOTE Thanks
djames42

 
Member Since: Oct 07, 2005
Location: Seattle
Posts: 346
djames42 has a spectacular aura about
Mac Specs: MBP CD 1.83/2ghz/7200 100g + Mini 2ghz C2D 2gb + Mini 1.42ghz G4 + PM 7200/120 + Newton OMP

djames42 is offline
PHP is great for this because of its built-in (if you compile it that way) mysql (and/or Oracle) libraries and functions. Before I started playing with PHP, I downloaded the DBI and DBD::mysql perl libraries and wrote some simple CGI code for pulling information from a mysql database and displaying it onto a webpage.

I can't help a whole lot beyond that since my time constraints prevented me from getting too far, but I can probably post a little bit of sample code if you want to see how to get started... (Although my PHP scripts are for work and so they're all speaking Oracle -- the mysql stuff I've done on my MBP are written in perl).
QUOTE Thanks
iRock

 
Member Since: Feb 09, 2005
Posts: 842
iRock will become famous soon enough

iRock is offline
Hey, thanks for the reply. yeah that would be great if you could do that. If its not too much bother that is. Thanks alot!
QUOTE Thanks
Thyamine

 
Thyamine's Avatar
 
Member Since: Apr 23, 2007
Location: Coatesville, PA
Posts: 377
Thyamine will become famous soon enough
Mac Specs: MBP 15", 2.33 GHz, 2Gb

Thyamine is offline
Here are some links that should help as well:

PHP and ODBC: http://www.w3schools.com/php/php_db_odbc.asp

PHP and Access: http://aspn.activestate.com/ASPN/Coo.../Recipe/163447

Access ODBC and PHP: http://www.phpfreaks.com/tutorials/61/0.php

Edit: And one question I should have asked: Your title says MySQL, but you only mention Access. Where does the MySQL come in?
QUOTE Thanks
iRock

 
Member Since: Feb 09, 2005
Posts: 842
iRock will become famous soon enough

iRock is offline
Thanks alot Thymine. Ill check those out now.
Actually the mySQL side of things I also have to apply the same principle to a mySQL database.
QUOTE Thanks
Thyamine

 
Thyamine's Avatar
 
Member Since: Apr 23, 2007
Location: Coatesville, PA
Posts: 377
Thyamine will become famous soon enough
Mac Specs: MBP 15", 2.33 GHz, 2Gb

Thyamine is offline
The concept is the same for all databases, with some caveats thrown in here and there. Connection strings will be different, syntax for queries may be different, things like that.

Usually once you do it a handful of times it's no big deal anymore. Open connection, send query, receive results, process results.
QUOTE Thanks
iRock

 
Member Since: Feb 09, 2005
Posts: 842
iRock will become famous soon enough

iRock is offline
Cool! Thanks. I appreciate all the help!
QUOTE Thanks
djames42

 
Member Since: Oct 07, 2005
Location: Seattle
Posts: 346
djames42 has a spectacular aura about
Mac Specs: MBP CD 1.83/2ghz/7200 100g + Mini 2ghz C2D 2gb + Mini 1.42ghz G4 + PM 7200/120 + Newton OMP

djames42 is offline
For what it's worth, here's a very simple snippet of code I just hacked together. This takes a few parameters pushed to it by way of wget (which, if you're not familiar with, is a way of emulating a web browser in code to pass a URL to a server and retrieve any html pushed from that server). It takes the passed parameters and loads them into a local mysql database. You should be able to use this to see a very simple way of putting data in to your database. Getting it out is slightly more complicated, but not much...

Code:
<?PHP

$server=$_GET['server'];
$sessioncnt=$_GET['sessioncnt'];
$totalsessions=$_GET['totalsessions'];
$date=date('Y-m-d H:i:s');

$db_conn = mysql_connect('localhost', 'username', 'password');
if (!$db_conn) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db('database_name', $db_conn);
if (!$db_selected) {
    die ('Can\'t use database_name : ' . mysql_error());
}

$insert=sprintf("insert into session_history values('%s','%s',%d,%d)",
        mysql_real_escape_string($server),
        mysql_real_escape_string($date),
        $sessioncnt, $totalsessions);

mysql_query($insert,$db_conn);
mysql_close($db_conn);

?>

The way this script is called is by running the following command:

Code:
wget -q --delete-after "http://web_url/~user/path/scrpt.php?server=${hostname}&sessioncnt=${usedprocs}&totalsessions=${maxprocs}"
QUOTE Thanks

Post Reply New Thread Subscribe


« Setting up as a freelance web designer? | Web Development »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
activating PHP & MYSQL gotenks05 Web Design and Hosting 5 01-20-2007 07:02 PM
Offline php and MYSQL server. StonePatch OS X - Apps and Games 2 09-10-2006 11:52 AM
Apache PHP MYSQL SQL timboellis Switcher Hangout 2 10-16-2005 08:43 PM
PHP mysql richardmojo Web Design and Hosting 2 05-09-2005 10:05 PM
mac os update 10.3.7 and PHP MYSQL lomokev Web Design and Hosting 2 01-27-2005 03:44 PM

All times are GMT -4. The time now is 06:37 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?