Progged programming site

Programming source code, articles, tutorials, links and chat

create a MySQL database using PHP

This code snippet example shows how to  create a MySQL database using PHP
<?php
$result = mysql_create_db(”mydb”);
if ($result == false)
echo (”failure to create database”);
?>

Bookmark It

Hide Sites

[ Back to top ]

page last accessed with PHP

 This php snippet will display when a page was last accessed

<?php
//displays the time / date a page was last accessed
echo """"Last viewed on: """" . date( """"D m/d/Y h:i:s a"""", fileatime( $PATH_TRANSLATED ) );
?>

Bookmark It

Hide Sites

[ Back to top ]

GIF creation using PHP

This example shows how to create a gif using PHP
<?php
Header(””Content-type: image/gif””);
$string=implode($argv,”” “”);
$im = imagecreatefromgif(””images/button1.gif””);
$orange = ImageColorAllocate($im, 220, 210, 60);
$px = (imagesx($im)-7.5*strlen($string))/2;
ImageString($im,3,$px,9,$string,$orange);
ImageGif($im); ImageDestroy($im);
?>

Bookmark It

Hide Sites

[ Back to top ]

Generate your email address using the GD library

This will create a jpeg image of your email address which should help avoid email harvesters finding this on your site.
<?php
Header(””Content-type: image/jpeg””);
//create a new image
$image = ImageCreate(200,200);
//create white (for background )
$white = ImageColorAllocate($image ,255,255,255);
//create blue for text
$blue = ImageColorAllocate($image , 0,0,255);
//OK lets create our white background
ImageFilledRectangle($image ,0,0,200,200,$white);
//display some text
ImageString($image,10,15,10,’test@test.com’,$blue);
//output image to browser as a JPEG
ImageJPEG($image);
//clean [...]

[ Back to top ]

Sponsors