PHP / mySQL Project help

Joined
Feb 9, 2005
Messages
842
Reaction score
10
Points
18
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
 
Joined
Oct 7, 2005
Messages
346
Reaction score
14
Points
18
Location
Seattle
Your Mac's Specs
MBP CD 1.83/2ghz/7200 100g + Mini 2ghz C2D 2gb + Mini 1.42ghz G4 + PM 7200/120 + Newton OMP
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).
 
OP
I
Joined
Feb 9, 2005
Messages
842
Reaction score
10
Points
18
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!
 
Joined
Apr 23, 2007
Messages
377
Reaction score
4
Points
18
Location
Coatesville, PA
Your Mac's Specs
MBP 15", 2.33 GHz, 2Gb
OP
I
Joined
Feb 9, 2005
Messages
842
Reaction score
10
Points
18
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.
 
Joined
Apr 23, 2007
Messages
377
Reaction score
4
Points
18
Location
Coatesville, PA
Your Mac's Specs
MBP 15", 2.33 GHz, 2Gb
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.
 
Joined
Oct 7, 2005
Messages
346
Reaction score
14
Points
18
Location
Seattle
Your Mac's Specs
MBP CD 1.83/2ghz/7200 100g + Mini 2ghz C2D 2gb + Mini 1.42ghz G4 + PM 7200/120 + Newton OMP
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', '[I]username[/I]', '[I]password[/I]');
if (!$db_conn) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db('[I]database_name[/I]', $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}"
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top