hsmoore.com
Members
-
Joined
-
Last visited
Reputation Activity
-
hsmoore.com got a reaction from rallport in Dependable DropdownNobody's answering your thread because you're basically asking someone to do it for you rather than researching online and trying out some more javascript/jquery interactions with your dropdowns.
-
hsmoore.com got a reaction from Frisby in PNG Resampling Program not working.Here's a function you can use to rather pass the image and dimensions you want output!
function resizeImage($image, $width, $height){ $tmp = split("\.", basename($image)); $ext = $tmp[1]; $src_img = ""; foreach($tmp as $t) { $ext = $t; } switch( $ext ){ case "jpg": case "JPG": case "jpeg": case "JPEG": $src_img = imagecreatefromjpeg($image); break; case "png": case "PNG": $src_img = imagecreatefrompng($image); break; } $dst_img = imagecreatetruecolor($width, $height); $src_dimensions = getimagesize($image); $src_width = $src_dimensions[0]; $src_height = $src_dimensions[1]; //proportions $prop_src = $src_width/$src_height; $prop_dst = $width/$height; //automate if($prop_src > $prop_dst){ $dst_height = $height; $dst_width = $src_width*$height/$src_height; //crops positions $prop_crop = $src_height/$height; $src_point_x = abs($src_width-$width*$prop_crop)/2; $src_point_y = 0; }else{ $dst_width = $width; $dst_height = $src_height*$width/$src_width; //crops positions $prop_crop = $src_width/$width; $src_point_x = 0; $src_point_y = abs($src_height-$height*$prop_crop)/2; } //application of the parameters imagecopyresized($dst_img, $src_img, 0, 0, $src_point_x, $src_point_y, $dst_width, $dst_height, $src_width, $src_height); imagecopyresampled($dst_img, $src_img, 0, 0, $src_point_x, $src_point_y, $dst_width, $dst_height, $src_width, $src_height); switch( $ext ){ case "jpg": case "JPG": case "jpeg": case "JPEG": imagejpeg($dst_img, $image); break; case "png": case "PNG": imagepng($dst_img, $image); break; } }
-
hsmoore.com got a reaction from Pondering tea drinker in Connecting to a MYSQL database in a seperate file (PHP)Create a config.php file:
<?php $DB_HOST = "localhost"; $DB_USER = "root"; $DB_PASS = "password"; $DB_DBNAME = "database_name"; mysql_connect($DB_HOST, $DB_USER, $DB_PASS); mysql_select_db($DB_DBNAME); ?>
Then just use it!
<?php include ("config.php") $query = mysql_query("SELECT * FROM `sometable`"); while ($result=mysql_fetch_object($query)) { echo $result->columnname."<br/>"; } ?>
This way you dont have to reconnect and reconnect all the time!
-
hsmoore.com got a reaction from Jo 90 in PNG Resampling Program not working.Here's a function you can use to rather pass the image and dimensions you want output!
function resizeImage($image, $width, $height){ $tmp = split("\.", basename($image)); $ext = $tmp[1]; $src_img = ""; foreach($tmp as $t) { $ext = $t; } switch( $ext ){ case "jpg": case "JPG": case "jpeg": case "JPEG": $src_img = imagecreatefromjpeg($image); break; case "png": case "PNG": $src_img = imagecreatefrompng($image); break; } $dst_img = imagecreatetruecolor($width, $height); $src_dimensions = getimagesize($image); $src_width = $src_dimensions[0]; $src_height = $src_dimensions[1]; //proportions $prop_src = $src_width/$src_height; $prop_dst = $width/$height; //automate if($prop_src > $prop_dst){ $dst_height = $height; $dst_width = $src_width*$height/$src_height; //crops positions $prop_crop = $src_height/$height; $src_point_x = abs($src_width-$width*$prop_crop)/2; $src_point_y = 0; }else{ $dst_width = $width; $dst_height = $src_height*$width/$src_width; //crops positions $prop_crop = $src_width/$width; $src_point_x = 0; $src_point_y = abs($src_height-$height*$prop_crop)/2; } //application of the parameters imagecopyresized($dst_img, $src_img, 0, 0, $src_point_x, $src_point_y, $dst_width, $dst_height, $src_width, $src_height); imagecopyresampled($dst_img, $src_img, 0, 0, $src_point_x, $src_point_y, $dst_width, $dst_height, $src_width, $src_height); switch( $ext ){ case "jpg": case "JPG": case "jpeg": case "JPEG": imagejpeg($dst_img, $image); break; case "png": case "PNG": imagepng($dst_img, $image); break; } }
-
hsmoore.com got a reaction from Pondering tea drinker in Securing a guestbook scriptThis is called "sanitizing" your form data and should always be done before inserting the data directly to your database.
Take a look at this site for some examples, it covers multiple languages too! bobby-tables.com