By Tim Perdue on July 30, 2000 PostgreSQL The results for Postgres might surprise a few people, as Postgres has somewhat of a negative reputation among some web developers (initial releases of Postgres had widely-rumored issues in addition to laggard performance). According to my experience, and these benchmarks, most of…
PHP Tutorials
Whether just getting started or an expert, this vast collection of PHP tutorials will help you create dynamic content for powerful web-based applications in no time.
By Tim Perdue on July 30, 2000 <?php /* Sample URLs: /local/2/us/IA/a/50613/apartment/ – apartments in Cedar Falls, IA /local/2/us/IA/a/ – group of cities in Iowa /local/2/us/ – States in the US /local/1/us/IA/a/50301/ – Des Moines City.net */ $url_array=explode(“/”,$REQUEST_URI); //BREAK UP THE URL PATH // USING ‘/’ as delimiter $url_affil_num=$url_array[2]; //Co-Branding info $url_country=$url_array[3]; //Which Country? $url_state=$url_array[4]; //Which State? $url_alpha_state=$url_array[5]; //Cities starting with a-g $url_zip=$url_array[6]; //If present, build thispage $url_content=$url_array[7]; //If present, build a sub- // page for this city /* separate includes were designed to fetch the affiliate cobranding and build appropriate style sheets on the fly. Data validation is done prior to each query. If a URL is incorrect, bow out gracefully or redirect home */ if($url_zip) { /* If present, query the Zip code database and build the page. Inside the city.inc, we will check for which “content page” we are building, if any. */ include(‘include/city.inc’); exit; } elseif ($url_state) { /* If URL PATH ends here, query Zip code database, selecting DISTINCT cities in this state */ if (!$url_alpha_state) { $url_alpha_state=’a’; } include(‘include/state.inc’); exit; } elseif ($url_country) { /*…
By Tim Perdue on July 30, 2000 Figuring out where your hits are coming from and which pages are being viewed is not too difficult if you use a good log analyzer like Analog or something similar. But if you want to pull up reports on the fly at any…
By Tim Perdue on July 30, 2000 REPORTING Reporting all this information is easy with PHP – just write up some SQL, execute it and use the ShowResults class to display it. So now the system is in place and and I can run a report at any time and…
By Tim Perdue on July 30, 2000 Source Code <!– //gif11.php3 accepts these parameters: $c; //correlates to fld_affil_num in the database – //unique for each site $s; //correlates to fld_special in the database $b; //random number – forces the gif to load, even if cached //generated by PHP and discarded –> <?php //gif11.php3 //don’t have any extra spaces outside the <? ?> // or you could have a broken gif come back Header( “Content-type: image/gif”); passthru( “cat clear.gif” ); //send a 1×1 gif $logger_action=5; //impression $logger_special=$s; //move the $s param for the logger $fld_affil_num=$c; //ditto for the $c param include(‘connect.inc’); //connect to the DB SERVER include(‘logger.inc’); //Exanded below ?> PHP Code To Generate The GIF URL: <?php srand((double)microtime()*1000000); $random_num=rand(5,95); ?> <p> <img src=”http://www.yourserver.com/util/gif11.php3?c=4&s=phpbuildercom&b=<? echo $random_num; ?>” height=1 width=1> connect.inc: <?php // //Connect to the PostgreSQL database // $conn = pg_pconnect(“user=myname dbname=my_db”); //I use a persistent connection instead of opening…
By Tim Perdue on July 30, 2000 Server scripting languages like Lasso and Java servlets make sending mail so complicated that you’d rather avoid it at all costs. Until recently, I have been relying on a cheap (read “free”) perl script from cgi-resources.com, but I want to be able to…
By Tim Perdue on July 30, 2000 Basically, you can receive some parameters from a simple form (you can probably handle creating that. If not – take a look at geocrawler.com and steal the HTML from the mail archive – you have my blessing). <?php //$to_email_address – received from the “POST” //$from_email_address – ditto //$subject //$message //…
By Tim Perdue on July 30, 2000 When I compiled PHP on my LinuxPPC box, I didn’t have GD installed and didn’t want to add another layer of complexity by compiling it in. GD will let you do all kinds of cool things – creating gifs, complex charts, etc, if…
By Tim Perdue on July 30, 2000 I wanted to be able to hand a simple database query to a function and have it graph it without me going to a bunch of work, so I whipped up this little function. It takes a database result and a title. The…
By Tim Perdue on July 30, 2000 That function is quite simple. Hand it a result set, it checks for the length, then turns that result set into a set of arrays to pass into my other general function, GraphIt(). GraphIt() can be called directly if you already have an…