Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   Web Design and Hosting (http://www.mac-forums.com/forums/web-design-hosting/)
-   -   PHP / mySQL Project help (http://www.mac-forums.com/forums/web-design-hosting/62649-php-mysql-project-help.html)

iRock 05-15-2007 09:22 PM

PHP / mySQL Project help
 
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;D

iRock 05-16-2007 06:48 AM

Bump...... anyone able to help me out?

djames42 05-16-2007 10:01 AM

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).

iRock 05-16-2007 02:10 PM

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!

Thyamine 05-16-2007 03:15 PM

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?

iRock 05-16-2007 03:21 PM

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.

Thyamine 05-16-2007 03:53 PM

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.

iRock 05-16-2007 06:02 PM

Cool! Thanks. I appreciate all the help!

djames42 05-17-2007 06:33 PM

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}"


All times are GMT -4. The time now is 04:13 PM.

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