Tag Archive for 'php'

23
May

ADODB on FreeBSD

Recently I’ve had one of my student assistants working on setting up a web server. She’s pretty much got it, except that she hasn’t been able to establish a connection from the web server to our database server.

We’re wanting to use ADODB to connect to a mssql server. She figured out how to install the databases/adodb5 port (and how to get ADODB included in the PHP configuration), but that wasn’t enough by itself. I thought there might be a PHP extension required, and a little Unix pipe revealed the missing module:

# grep -i ^php /usr/ports/INDEX-7 | grep -v ^php4 | grep -i adodb

The command above searches the ports index for lines starting with “php” (or “PHP”), ignores those which begin with “php4″ (I’m not interested in version 4 stuff), and searches everything that’s matched so far for “adodb” (or “ADODB”). Results:

php-adodb-ext... (long index line snipped)

A quick check of /var/db/pkg verified that this module hadn’t been installed yet. I installed the module via portmaster(8) and added the new extension per the pkg-message instructions:

# portmaster databases/php-adodb-ext
.
.
.
(installation stuff snipped)
# cat >>/usr/local/etc/php/extensions.ini
extension=adodb.so

Now we’re getting a different error:

PHP Fatal error:  Call to undefined function mssql_get_last_message() in /usr/local/share/adodb/drivers/adodb-mssql.inc.php on line 501

Google indicates the problem is likely that the mssql extension for PHP isn’t installed. I ran the same pipe that I did for ADODB, this time searching for mssql:

# grep -i ^php /usr/ports/INDEX-7 | grep -v ^php4 | grep -i adodb

php5-mssql... (long index line snipped)

So another portmaster(8) installation, this time for php5-mssql. One of php5-mssql’s dependencies is freetds-msdblib, which has some configuration options. The only one I’m setting is MSDBLIB, which enables MS SQLserver (in lieu of the old Sybase DB).

This port (php5-mssql) automatically registers itself as a PHP extension, so you don’t have to add a line to /usr/local/etc/php/extensions.ini yourself.

I’m still getting errors, but they’re starting to look like problems with the database connection string instead of server configuration now. Progress, of a sort. But that’s enough for now–It’s almost 8:00 pm on Friday night before a 3-day weekend, long past time for me to get on with my own life!

03
Feb

Doh!

I am so screwed… I ran the portupgrade utility on one of our FreeBSD servers at work. This was a production system that we used for printing certificates for our students, preparing address labels for USPS shipments, and several other small (but crucial!) database applications. When I realized that the upgrade had roached all these business-critical apps, I tried to restore the system and found that my backups weren’t usable. ARRRRGH! From now on, I’m going to verify my backups by generating a “table of contents” from the backup media after the backup is complete.

for ($i=1; $i<=100; $i++) {
    print "$i. I will *never* run portupgrade(1) again without making sure I have a *known good* backup!\n";
}
31
Aug

Displaying (vs executing) PHP code on web pages

While working on an earlier post, I needed to find a way to display a PHP module on a web page without having it executed. I knew this was fairly simple and involved the .phps file extension, but I hadn’t done it before. A quick search of the PHP site pointed me to the highlight_file function. About halfway down the page there is a blurb about the MIME type that I needed. It turns out that my web hosting service already has this enabled, so all I needed to do was get a .phps extension on my file. I did it the easy way, with a softlink:

ln -s myfile.php myfile.phps

For those who don’t know Unix, this effectively creates another name for the same file, which is exactly what I want. This leaves the original .php alone, so that it can be run by the web server. But is also allows me to post the code on the web, using the .phps “file” which the web server will display instead of executing. The elegance of this solution is that if/when I modify the original code, I won’t have to make any changes to the displayable code because there is really only one file (with two distinct names).

08
Jul

Awesome “cheat sheets” for web authors

Joseph found a bunch of handy reference sheets on Dave Child’s blog, I love Jack Daniels.

The most useful (for WordPress developers, anyway) will probably be the PHP and CSS pages. Dave has also provided web-safe colors, mod_rewrite, and MySQL reference sheets. Thanks, Dave!

17
Jun

Internet programming language?

I stumbled across this post from almost exactly one year ago. Joseph, I salute your effort, and the fact that you made this work is very cool, but I think this approach (relatively low-level network programming) may be the wrong track to pursue. I think a more appropriate method would be network API’s for new or existing applications, or at least higher-level libraries.

Network overhead is obviously vastly more “expensive” than local function calls, so you should probably reserve network functions for heavyweight applications. You mentioned databases–I think this is actually a good use of network programming! I have in mind something like the USPS’s ZIP code lookup. There is obviously a database backend on this web app. Granted, one cannot make arbitrary database queries (nor inserts, updates, deletes), but it does serve up the data quickly and competently. The database sits on the same machine (or topologically “close”) to the API server. Google is another example, and smarter people than I will come up with many more already-existing web services with DB backends. I think this is where Internet programming can really shine!




September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Tags

a wok for all seasons abramoff accessibility acetylene active directory activism adodb aerial photo afrofunk aim4tree air america airport express alite alito amtrak andante andy antenna anti failure any browser apache appetizer apple apple pie applescript arden arcade arden park ariana arnold artichoke ashland astronomy attic attika audio avid reader backup baen bart bash batch bathroom bbq bee beef begonia bgg bike bike hikers bike journal bikejournal biketalk bill oreilly bittorrent blacklist blog bloggercode blogroll blueberry boardgamegeek boardgames bonjour book bookcrossing boot failure bootcamp borderline chaos bugmenot bush business card butter cabinetry caira caitlin california callsign candamir caroline carpet cat cateye cdrom celebration cellular phone century cfengine cheese chicken chico chile chili chimney chinese chipotle chocolate christmas city bikes civilization cjd claire club club fed co op coconut coffee comfort food community computer concord congress conquest conservation consumer reports copyright costco crazybikerchick crepe crock pot cruftbox css csus curl currency custard cvntrak dagoba daniel goetz darwinports database datarescue date format death delicious monster democracy now Democrat demolition dessert dhcp dickens diff disaster discrimination discworld dishwasher disk mirror diskutil diskutility diskwarrior dixie belle dock doors downing street memo drm dryer drywall dtv dump ed burke eff eggs eject election electric car electric truck electrical electricity elvgren emacs email energy efficiency eric meyer esr etext euthanasia facebook family faq faux news fcc feed feedreader fence finder firefox fireworks first4internet first amendment fishmeal flash flickr flooring fondue foreign exchange foundation fox and goose framing freebsd freedback freetds fsck fundraiser fyq garage garden geek geotag geourl ginger gnutar go gonuls google google earth google maps gpl gracenote graywater greek green group concat gtd gunthers gutters gwbush gymnastics hacking halloween ham ham radio handspring hardwood harry potter headmeta heimdal high speed photograph high tech inv hoax hobbies hobby hodgins holiday holly home power magazine horcrux houseblogs how to html https humor hvac ilovejackdaniels imac impeach init inspection insulation intel internet iostat ipod ipodder iq iraq isight iso itunes ivins iwantsandy java city javascript jean reno jet lag joint chiefs joseph jott journalized blue judges cup juliette binoche kale kctc kerberos khs kimkerry kitchen kyocera la salles la times labor landscape laundry law leatherbys legal lego leopard lhc liberal library linkedin ljurban lodi logic logo lungren lynx maaloufs mac macaroni macbook mafc mailinator make.conf malware map marin markdown martin yan mason media media clip media reform meetup metric mexican microsoft mike comfort military milonic mindstorms mlk model railroading modoc hall monterey morning sedition motorcycle movie moving mssql munchkin murray mushroom music mynetflix mysql n3jim nagios naked lounge neon nerd score netflix network new urbanism new year New Yorker nofollow nut nutella oatmeal obama obcz occidental occupation omni openssl oracle organic osx owp paint pair palast palm panasonic parallels party patch peak adventures peak oil pear pedestrian village perl petaluma php ping pingback pingomatic pingomation pingqueue pirate pl sql planet bike plasma playroom entertainment plugin plugin:preview theme plugin:text control plugin:ultimate tag warrior plumbing podcast podsite politics portaudit portmaster ports portupgrade postfix potato powerbook Pozsars printer programming project gutenberg pryde punk puzzle qiana qrz quilt quilt shop quiz quote r5 records racism radio RAID railroad recent comments recipe redalt remodel repairmirror resaurant resolution restaurant restore review richmond rio americano robotics roger niello ron montana roof rootkit rss sacbee sacog sacramento sacramento spotlight magazine salad samba san francisco sandwich santa cruz scam scandal school days scplugin screen security session report shakespeare shuffle sigma siriradha sitemap slim jim snl snopes social social network software soma somafab sonicchicken sonicchicken blog sony spam spam karma spellcheck spinach spinner spirit spoiler etiquette spring hill cheese sql sqlserver stairs standards statcounter stephen king stop loss stucco stunt subversion sudo sudoku superbowl superhero supreme court sushi svn sysadmin tacoma tags plugin takara technology telephone television template terms and conditions textcontrol thai kitchen thanksgiving the well seasoned wok theater theme theme:borderline chaos theme:elvgren theme:elvgren wordpress google code theme:fluid blue theme:fullwidth theme:head theme:journalized theme:journalized blue theme:psycho theme:redoable theme:sharepoint like theme:simple green theme:spirit theme:steam theme:wuhan theme:yadda theme switcher thomas tigris euphrates tile tinfoil hat toc tofu tower theater training transit transit oriented development tribute u haul uneasy rhetoric university village unix ad notes ups van zant veal veterans day video vie viking hobby vote smart w3c wall warboss washer washington post weather web web developer web server wikipedia windows windows server 2003 wishlist woodworking wordpress workplace wpblacklist wpgatekeeper wsj xserve yaaarr yard