PHP - Strange Black Line In An Image
This is kind of weird, I've tried to figure out what is wrong for a while now, but I really can't seem to figure it out.
My script does seem to work with the values I think it works with, but that might be where the error is. I've messed around a lot with it, but I still can't seem to understand what the problem is... I do realize I can just use the filledrectangle function instead of creating a new image for each background color, but the problem itself really annoys me. The black line doesn't appear anywhere but between the two first background colors and only if both background colors are visible... o.O Might be I need to use some other imagecopy function, but this is all so weird! <?php // image size $x=500; $y=100; // creating transparent image $im=imagecreatetruecolor($x,$y); $tc=imagecolorallocatealpha($im,255,255,255,0); imagefill($im,0,0,$tc); // background colors // the escaped lines is for making a background image transparent, to see where the black line appears $bgc[]=array(255,0,0,0); //$bgc[0]=array(255,0,0,127); $bgc[]=array(0,255,0,0); //$bgc[1]=array(0,255,0,127); $bgc[]=array(0,0,255,0); $bgc[]=array(0,255,255,0); // adding backgrounds // background count: $bgcq=count($bgc); // backgroundsize x,y: $bgs=array(ceil($x),($y+1)/$bgcq); // location: $bgsl=0; // last height: $bgsh=0; for($i=0;$i<$bgcq;$i++){ // start location for this background: $bgsl+=$bgsh; // calculating a round number for the background height if($bgsl+$bgs[1]<round($bgs[1]+($bgs[1]*$i))){ $bgsh=ceil($bgs[1]); }else{ $bgsh=floor($bgs[1]); } // creating background image: $bg=imagecreatetruecolor($bgs[0],$bgsh); // filling background image with set color $abgc=imagecolorallocatealpha($bg,$bgc[$i][0],$bgc[$i][1],$bgc[$i][2],$bgc[$i][3]); imagefill($bg,0,0,$abgc); // pasting background on image (imagecopy gives the same result) imagecopyresampled($im,$bg,0,$bgsl,0,0,$bgs[0],$bgsh,$bgs[0],$bgsh); // to see the values (test purpose), must escape header and imagepng functions //echo $bgsl.'-'.($bgsl+$bgsh).'<br />'.$bgsh.'<br />'; } // output, remember to escape it to echo variables header('Content-type: image/png'); imagepng($im,NULL,0); ?> I've tried to make the script as understandable and easy as possible... anyone got any ideas about what is wrong here, and how to maybe fix it? Similar TutorialsI am having an issue with this code. Im trying to find the problem listed as the error but i might need someone from the outside to look at it for me. Code: [Select] <?php if (empty($_GET['email']) || empty($_GET['email_confirm']) || empty($_GET['password']) || empty($_GET['password_confirm'])) exit("<p>You must enter values in all fields of the Frequent Flyer Registration form! Click your browser's Back button to return to the previous page.</p>"); else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_GET['email'])) exit("<p>You must enter a valid e-mail address! Click your browser's Back button to return to the previous page.</p>"); else if ($_GET['email'] != $_GET['email_confirm']) exit("<p>You did not enter the same e-mail address! Click your browser's Back button to return to the previous page.</p>"); else if ($_GET['password'] != $_GET['password_confirm']) exit("<p>You did not enter the same password! Click your browser's Back button to return to the previous page.</p>"); else if (strlen($_GET['password']) < 5 || strlen($_GET['password']) > 10) exit("<p>Your password must be between 5 and 10 characters! Click your browser's Back button to return to the previous page.</p>"); $DBConnect = @mysqli_connect("localhost", "********", "********") Or die("<p>Unable to connect to the database server.</p>" . "<p>Error code " . mysqli_connect_errno() . ": " . mysqli_connect_error()) . "</p>"; $DBName = "skyward_aviation"; @mysqli_select_db($DBConnect, $DBName) Or die("<p>Unable to select the database.</p>" . "<p>Error code " . mysqli_errno($DBConnect) . ": " . mysqli_error($DBConnect)) . "</p>"; $TableName = "frequent_flyer"; $Email = addslashes($_GET['email']); $Password = addslashes($_GET['password']); $SQLstring = "SELECT * FROM $TableName"; $QueryResult = @mysqli_query($DBConnect, $SQLstring); if (mysqli_num_rows($QueryResult) > 0) { $Row = mysqli_fetch_row($QueryResult); do { if (in_array($Email, $Row)) exit("<p>The e-mail address you entered is already registered! Click your browser's Back button to return to the previous page.</p>"); $Row = mysqli_fetch_row($QueryResult); } while ($Row); mysqli_free_result($QueryResult); $SQLstring = "INSERT INTO $TableName VALUES(NULL, '$Email', '$Password', NULL, NULL, NULL, NULL, NULL, NULL, NULL)"; $QueryResult = @mysqli_query($DBConnect, $SQLstring) Or die("<p>Unable to execute the query.</p>" . "<p>Error code " . mysqli_errno($DBConnect) . ": " . mysqli_error($DBConnect)) . "</p>"; $FlyerID = mysqli_insert_id($DBConnect); mysqli_close($DBConnect); ?> <p>Your new frequent flyer ID is <strong> <?= $FlyerID ?></strong>.</p> here is the error on the page Parse error: syntax error, unexpected $end in C:\xampp\htdocs\PHP_Projects\Chapter.10\RegisterFlyer.php on line 73 Thanks for any help on this issue, ive been going crazy function buildAvatar(array $imgArray = array()) { $img1 = imagecreatefrompng($phpbb_root_path.'images/spacer.png'); foreach($imgArray as $img) { $img2 = imagecreatefrompng($phpbb_root_path.'avatars/equip_img/'.$img); $this->imagecopymerge_alpha($img1, $img2, 0, 0, 0, 0, 210, 300, 100); } imagealphablending($img1, false); imagesavealpha($img1, true); return $img1; } The background of my PNG was transparent, I don't know what I did, but it's now black! I'm thinking it's the image! Not the code, this same code worked before, and I've tried tons of different ways of fixing it. How should I save the image to work correctly? this is the code <?php $image = imagecreatefromjpeg("9t4i_200xX.jpg"); $new_image = imagecreatetruecolor(120,90); imagecopyresampled($new_image, $image, 0, 0, 0, 0, 120, 90, imagesx($image), imagesy($image)); $image = $new_image; imagejpeg($image,"images/test.jpg"); ?> result is black jpeg image of size 120,90 I dont understand where could be the problem SimpleImage.php script doesnt work either I am trying to copy an image into another image. Code: [Select] $im = imagecreatefrompng("/oldimg.png"); //this is a semi-transparent image where I want the new image to be copied imagealphablending($im, 1); //this seems to remove the black background header('Content-type: image/png'); //outputs old image with a transparent background (YAY!) imagepng($im); imagecopy($im, $newimage, 32, 0, 0, 0, 32, 32); //I want to replace a part of the old image with a new semi-transparent image header('Content-type: image/png'); //outputs image with a black background (noooooooooo!) imagepng($im); Can anyone help me? I'm trying to convert a grayscale image to pure black and white in php using the GD library. The purpose would be to detect the cervical cells within the image. I'll leave the php code and a matlab one (i wrote this code in matlab and i'm trying to obtain the same result in php). Basically, im having troubles accessing each individual pixel's color and modifying it. MATLAB: clear all, clc, close all; I = imread('celule.jpg'); imshow(I) title('original'); a=rgb2gray(I); figure; imshow(a) title('grayscale'); s=size(a); for i=1:s(1) for j=1:s(2) if a(i,j)>190 a(i,j)=0; else a(i,j)=255; end end end figure; imshow(a) title('pure black and white'); PHP: <?php $im = imagecreatefromjpeg("celule.jpg"); function imagetograyscale($im) { if (imageistruecolor($im)) { imagetruecolortopalette($im, false, 256); } for ($c = 0; $c < imagecolorstotal($im); $c++) { $col = imagecolorsforindex($im, $c); $gray = round(0.299 * $col['red'] + 0.587 * $col['green'] + 0.114 * $col['blue']); imagecolorset($im, $c, $gray, $gray, $gray); } } imagetograyscale($im); //imagefilter($im, IMG_FILTER_CONTRAST, -255); //i'm not looking for this effect header('Content-type: image/jpeg'); imagejpeg($im); $C = imagesx($im); //width $L = imagesy($im); //height echo "Dimensiuni imagine: latime $C, inaltime $L <br>"; //scanning through the image for($x = 0; $x < $L; $x++) { //each line for($y = 0; $y < $C; $y++) { //each collumn // pixel color at (x, y) $color = imagecolorat($im, $y, $x); $color = imagecolorsforindex($im, $color); //getting rgb values $RED[$x][$y] = $color["red"]; //each rgb component $GREEN[$x][$y] = $color["green"]; $BLUE[$x][$y] = $color["blue"]; } } ?> image "celule.jpg": https://i.ibb.co/6Ffj6sc/celule.jpg I don`t get it, waht is wrong?! Code: [Select] <?php require_once 'auth.php'; if (!isset($_SESSION['SESS_VERIFY'])) { header("location: access-denied.php"); exit(); } if ($_SESSION['lang'] == 'Ro') { // setare data romania date_default_timezone_set('Europe/Bucharest'); $today = getdate(); $zi = $today['mday']; $luna = $today['mon']; $lunastring = $today['month']; $an = $today['year']; $data = $zi.$luna.$an; $data = (string)$data; $ora = date('H:i:s'); $msg = array(); $err = array(); $luni = array ( 1=>'Ianuarie', 2=>'Februarie', 3=>'Martie', 4=>'Aprilie', 5=>'Mai', 6=>'Iunie', 7=>'Iulie', 8=>'August', 9=>'Septembrie', 10=>'Octobrie', 11=>'Noiembrie', 12=>'Decembrie'); // comun const SQL_ERR = 'SQL statement failed with error: '; const ADD_MODEL = 'ADAUGA UN MODEL NOU'; . .many constants.. . } elseif ($_SESSION['lang'] == 'It') {... Thank you! I am trying to produce a thresholded image with only an rgb value of zero or 255. As you can see, although I only output 0 and 255, I am finding that if I output as jpg file, I get other values in there as well. If I output as gif, I also get other values in there too. I am sure I am doing something stupid as there must be a way to do this. My test file is this attached jpg greyscale file. Is there a way to process this test file so that only 0 or 255 appears in the output image please? Thanks. Here is my program <?php $url = 'greyscale_image.jpg'; $outfile = 'greyscaleout'; $src = imagecreatefromjpeg($url); $w = imagesx($src);$h = imagesy($src); $loband = 80;$hiband = 255; $im_r = imagecreatetruecolor($w,$h); imagefill($im_r,0,0,imagecolorallocate($im_r,255,0,0)); $im_j = imagecreatetruecolor($w,$h); imagefill($im_j,0,0,imagecolorallocate($im_j,255,0,0)); for ($x=0;$x<$w;$x++) { for ($y=0;$y<$h;$y++) { $idx = imagecolorat($src,$x,$y); $rgb = imagecolorsforindex($src,$idx); // this is safest (for gifs) rather than some calculation - apparently $r =$rgb['red']; $g = $rgb['green']; $b = $rgb['blue']; $gryout = $r; if ($r <= $loband) { $gryout = 0; // everything less than= loband is black } if ($r > $loband) { $gryout = 255; // everything else is white } if ( ($gryout == 0) || ($gryout == 255) ) { // only zero or 255 allowed $idx = imagecolorallocate($im_r,$gryout,$gryout,$gryout); imagesetpixel($im_r,$x,$y,$idx); // imagesetpixel($im_j,$x,$y,$idx); // $idx2 = imagecolorat($im_r,$x,$y);// if ($idx != $idx2) { die($idx2." at x,y ".$x.",".$y); } $rgb = imagecolorsforindex($im_r,$idx); // this is safest (for gifs) rather than some calculation - apparently $r =$rgb['red']; $g = $rgb['green']; $b = $rgb['blue']; if ($r != 0) { if ($r != 255) { die($r." at x,y ".$x.",".$y); } } } else { die('<br>Grey going out to image is '.$gryout); } } } imagegif($im_r,$outfile.'.gif');imagedestroy($im_r); imagejpeg($im_j,$outfile.'.jpg');imagedestroy($im_j); // ========================== // done the writing, now check it // ========================== // $outfile = 'greyscale_image'; // test using original $src = imagecreatefromjpeg($outfile.'.jpg'); $w = imagesx($src);$h = imagesy($src); $errcount = 0; $x = 0; while($x<$w) { $y = 0; while($y<$h) { $idx = imagecolorat($src,$x,$y);// $rgb = imagecolorsforindex($src,$idx); // this is safest (for gifs) rather than some calculation $r =$rgb['red']; $g = $rgb['green']; $b = $rgb['blue']; if ($r != 0) { if ($r != 255) { echo sprintf('<br>r(%d,%d) r=%d g=%d b=%d',$x,$y,$r,$g,$b);$errcount++; } } if ($g != 0) { if ($g != 255) { echo sprintf('<br>g(%d,%d) r=%d g=%d b=%d',$x,$y,$r,$g,$b);$errcount++; } } if ($b != 0) { if ($b != 255) { echo sprintf('<br>b(%d,%d) r=%d g=%d b=%d',$x,$y,$r,$g,$b);$errcount++; } } if ($errcount > 10) {break 2;} $y++; } $x++; } if ($errcount == 0) {die( ' Checked OK' );} die( ' Checked NOT OK' ); // ================= ?> Hello, I've had success creating a cool vanity QR code with rounded edges for my organization by generating a standard QR code, then applying a noise -> median effect in Photoshop to get the edges rounded among some other effects. Photoshop is great, but I want to automate this. I found a great PHP library to generate QR codes. The part I don't get is the rounding of the hard edges. I've seen other sites do it like this one. So far google searches are yielding rounded corner tutorials. Any thoughts on how to do this with GD or ImageMagic? Best regards, Chris Can anyone see anything wrong with this? <?php $filename = "aircraft/".$reg."1.jpg"; ?> Its meant to be aircraft/xxx1.jpg Thanks hi guys i need some help i am trying to create a resized image with a watermark, from an uploaded image.. the image is getting uploaded and resized but the watermark doesnt appear correct. instead of a transparent watermark, there's a black square in it's place. this is my code Code: [Select] $tempfile = $_FILES['filename']['tmp_name']; $src = imagecreatefromjpeg($tempfile); list($origWidth, $origHeight) = getimagesize($tempfile); // creating png image of watermark $watermark = imagecreatefrompng('../imgs/watermark.png'); // getting dimensions of watermark image $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); // placing the watermark $dest_x = $origWidth / 2 - $watermark_width / 2; $dest_y = $origHeight / 2 - $watermark_height / 2; imagecopyresampled($src, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $origWidth, $origHeight); imagealphablending($src, true); imagealphablending($watermark, true); imagejpeg($src,$galleryPhotoLocation,100); // $galleryPhotoLocation is correct. the image gets uploaded successfully.. hey im new to this web site im looking for some help with my code its suppose to be a black jack game im trying to make an array that can hold the value of the cards once the person presses the hit me button please help me i havent fully develop code yet so you can ignore the comments code if you like thanks for looking at it. Code: [Select] <html> <head> <title>poker dice</title> <style type = "text/css"> body { background: green; color: tan; } </style> </head> <body> <center> <h1>Poker Dice</h1> <form> <? $number = $_REQUEST["number"]; $statue = $_REQUEST["statue"]; $number2 = unserialize(urldecode($number)); //check to see if this is first time on the page. if ($statue == null){ if ((!$cash) && (!$card_counter)){ Print "You will start out with a value of 100 dollars and points of 0."; $cash = 100; $card_counter = 0; } // end if Cards($number); printPage(); }else if($statue == 1){ Cards2($number); printPage(); // print "this is the second page"; }else if($statue == 2){ Cards3($number); printPage(); // print "this is the second page"; }else if($statue == 3){ Cards4($number); printPage(); // print "this is the second page"; }else if($statue == 4){ Cards5($number); printPage(); // print "this is the second page"; }else if($statue == 5){ Cards6($number); printPage(); // print "this is the second page"; }else if($statue == 6){ Cards7($number); printPage(); // print "this is the second page"; }else if($statue == 7){ Cards8($number); printPage(); // print "this is the second page"; }else{ Cards9($number); printPage(); // print "this is the second page"; } //rollDice(); if ($secondRoll == TRUE){ print "<h2>Second roll</h2>\n"; $secondRoll = FALSE; evaluate(); } else { print "<h2>First roll</h2>\n"; $secondRoll = TRUE; } // end if printStuff(); function Cards($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); $num2 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; echo $Cards[$num2]; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[0] = $Cards[$num1]; $cards_array[1] = $Cards[$num2]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print $cards_array[0]; print $cards_array[1]; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "1"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; // by using the number and requestinh it will store the value of that array. //it good using a hidden box for this method. //if ($Deck[$num1] == TRUE || $Deck[$num2] == TRUE) { //} //$CurrentHand = $Deck[$num1]; //$Deck = explode(",",$CurrentHand[0]); //$Hit = array_shift($Deck); //$Cards = implode(",",$Deck); //if (isset($CurrentHand[1])) // $PlayersHand = explode("~", $CurrentHand[1]); //$PlayersHand[] = $Hit; //$CardCount = 0; /*$Aces = 0; for ($i=0; $i<count($PlayersHand); ++$i) { if (strpos($PlayersHand[$i], "Ace") !== FALSE) ++$Aces; else if (strpos($PlayersHand[$i], "Two") !== FALSE) $CardCount += 2; else if (strpos($PlayersHand[$i], "Three") !== FALSE) $CardCount += 3; else if (strpos($PlayersHand[$i], "Four") !== FALSE) $CardCount += 4; else if (strpos($PlayersHand[$i], "Five") !== FALSE) $CardCount += 5; else if (strpos($PlayersHand[$i], "Six") !== FALSE) $CardCount += 6; else if (strpos($PlayersHand[$i], "Seven") !== FALSE) $CardCount += 7; else if (strpos($PlayersHand[$i], "Eight") !== FALSE) $CardCount += 8; else if (strpos($PlayersHand[$i], "Nine") !== FALSE) $CardCount += 9; else if (strpos($PlayersHand[$i], "Ten") !== FALSE) $CardCount += 10; else if (strpos($PlayersHand[$i], "Jack") !== FALSE) $CardCount += 10; else if (strpos($PlayersHand[$i], "Queen") !== FALSE) $CardCount += 10; else if (strpos($PlayersHand[$i], "King") !== FALSE) $CardCount += 10; } $Cards = $Cards .implode("~", $PlayersHand); if ($Aces > 0) { for ($i=1; $i<=$Aces;++$i) { if ($CardCount+11 <= 21) $CardCount += 11; else $CardCount += 1; } } if ($CardCount == 21) $Cards = $Cards . "\nYou win!"; else if ($CardCount> 21) $Cards = $Cards . "\nYou lose!"; //print $Deck; print <<<HERE </tr></td> <tr> <td colspan = "7"> <center> <input type = "submit" value = "play hand"> </center> </td> </tr> </table> HERE;*/ }//end function function Cards2($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[2] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print $cards_array[0]; print $cards_array[1]; print $cards_array[2]; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "2"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards3($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[3] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print $cards_array[0]; print $cards_array[1]; print $cards_array[2]; print $cards_array[3]; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "3"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards4($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[4] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "4"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards5($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); $num2 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[5] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "5"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards6($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[6] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "6"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards7($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); $num2 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[7] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "7"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards8($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[8] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "8"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards9($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[9] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; // print <<<HERE // </tr></td> // <tr> // <td colspan = "5"> // <center> //<form methods = "post" // action = "PokerFinal.php"> //<input type = "submit" // value = "Hit Me"> // <input type = "hidden" // name = "number" // value = "$serialCards"> // <input type ="hidden" // name ="statue" // value = "9"> //</form> //</center> // </td> // </tr> // </table> //HERE; print "No more HIT ME button"; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function printPage(){ }//end functon //function rollDice(){ // global $die, $secondRoll, $keepIt; //print "<table border = 1><td><tr>"; //for ($i = 0; $i < 5; $i++){ //if ($keepIt[$i] == ""){ //$die[$i] = rand(1, 6); //} else { //$die[$i] = $keepIt[$i]; //} // end if //$theFile = "die" . $die[$i] . ".jpg"; //print out dice images // print <<<HERE // <td> // <img src = "$theFile" // height = 50 // width = 50><br> //HERE; //print out a checkbox on first roll only // if ($secondRoll == FALSE){ // print <<<HERE // <input type = "checkbox" // name = "keepIt[$i]" //value = $die[$i]> //</td> //HERE; // } // end if // } // end for loop //print out submit button and end of table //print <<<HERE //</tr></td> //<tr> // <td colspan = "5"> // <center> //<input type = "submit" // value = "roll again"> //</center> // </td> //</tr> //</table> //HERE; //} // end rollDice function evaluate(){ global $die, $cash; //set up payoff $payoff = 0; //subtract some money for this roll $cash -= 2; //count the dice for ($theVal = 1; $theVal <= 6; $theVal++){ for ($dieNum = 0; $dieNum < 5; $dieNum++){ if ($die[$dieNum] == $theVal){ $numVals[$theVal]++; } // end if } // end dieNum for loop } // end theVal for loop //print out results // for ($i = 1; $i <= 6; $i++){ // print "$i: $numVals[$i]<br>\n"; // } // end for loop //count how many pairs, threes, fours, fives $numPairs = 0; $numThrees = 0; $numFours = 0; $numFives = 0; for ($i = 1; $i <= 6; $i++){ switch ($numVals[$i]){ case 2: $numPairs++; break; case 3: $numThrees++; break; case 4: $numFours++; break; case 5: $numFives++; break; } // end switch } // end for loop //check for two pairs if ($numPairs == 2){ print "You have two pairs!<br>\n"; $payoff = 1; } // end if //check for three of a kind and full house if ($numThrees == 1){ if ($numPairs == 1){ //three of a kind and a pair is a full house print "You have a full house!<br>\n"; $payoff = 5; } else { print "You have three of a kind!<br>\n"; $payoff = 2; } // end 'pair' if } // end 'three' if //check for four of a kind if ($numFours == 1){ print "You have four of a kind!<br>\n"; $payoff = 5; } // end if //check for five of a kind if ($numFives == 1){ print "You got five of a kind!<br>\n"; $payoff = 10; } // end if //check for flushes if (($numVals[1] == 1) && ($numVals[2] == 1) && ($numVals[3] == 1) && ($numVals[4] == 1) && ($numVals[5] == 1)){ print "You have a flush!<br>\n"; $payoff = 10; } // end if if (($numVals[2] == 1) && ($numVals[3] == 1) && ($numVals[4] == 1) && ($numVals[5] == 1) && ($numVals[6] == 1)){ print "You have a flush!<br>\n"; $payoff = 10; } // end if print "You bet 2<br>\n"; print "Payoff is $payoff<br>\n"; $cash += $payoff; } // end evaluate function printStuff(){ global $cash, $secondRoll; print "Cash: $cash\n"; //store variables in hidden fields print <<<HERE <input type = "hidden" name = "secondRoll" value = "$secondRoll"> <input type = "hidden" name = "cash" value = "$cash"> HERE; } // end printStuff ?> </form> </center> </html> Hi all, can anyone see why my function is not running? im not getting the form output now. Code: [Select] <?php /* NEW.PHP Allows user to create a new entry in the database */ // creates the new record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($Name, $Rank, $error) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>New Record</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="wrapper"> <p> <?php // if there are any errors, display them if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } ?> </p> <p> </p> <form action="" method="post"> <div> <table width="842" border="0" class="styletable" style="border: 1px solid #000000"> <tr> <td width="255"><strong>Name: *</strong></td> <td width="577"><input type="text" name="Name" value="<?php echo $Name; ?>" /></td> </tr> <tr> <td><strong>Rank:</strong></td> <td><input type="text" name="Rank" value="<?php echo $Rank; ?>" /></td> </tr> <tr> <td><strong>Contact Email: *</strong></td> <td><input type="text" name="ContactEmail" value="<?php echo $ContactEmail; ?>" /></td> </tr> <tr> <td><strong>Website: (omitting http://)</strong></td> <td><input type="text" name="Website" value="<?php echo $Website; ?>" /></td> </tr> <tr> <td><strong>Location:</strong></td> <td><select name="Location" id="Location"> <option value="East Midlands">East Midlands</option> <option value="East Of England">East Of England</option> <option value="Greater London">Greater London</option> <option value="North East England">North East England</option> <option value="North West England">North West England</option> <option value="South East England">South East England</option> <option value="South West England">Soth West England</option> <option value="West Midlands">West Midlands</option> <option value="Yorkshire And The Humber">Yorkshire And The Humber</option> </select> </td> </tr> <tr> <td><strong>Bio:</strong></td> <td><textarea name="BIO" id="BIO" cols="60" rows="5"></textarea></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <p>* required</p> <input type="submit" name="submit" value="Submit"> <a href="view.php">Cancel - View Records</a> </div> </form> </div> </body> </html> <?php } // connect to the database include('../connect-db.php'); // check if the form has been submitted. If it has, start to process the form and save it to the database if (isset($_POST['submit'])) { // get form data, making sure it is valid $Name = mysql_real_escape_string(htmlspecialchars($_POST['Name'])); $Rank = mysql_real_escape_string(htmlspecialchars($_POST['Rank'])); $ContactEmail = mysql_real_escape_string(htmlspecialchars($_POST['ContactEmail'])); $Website = mysql_real_escape_string(htmlspecialchars($_POST['Website'])); $Location = mysql_real_escape_string(htmlspecialchars($_POST['Location'])); $BIO = mysql_real_escape_string(htmlspecialchars($_POST['BIO'])); // check to make sure both fields are entered if ($Name == '' || $ContactEmail == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; // if either field is blank, display the form again renderForm($Name, $Rank, $error); } else { // save the data to the database mysql_query("INSERT members SET Name='$Name', Rank='$Rank',ContactEmail='$ContactEmail', Website='$Website', Location='$Location', BIO='$BIO'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: view.php"); // if the form hasn't been submitted, display the form } renderForm('','',''); } ?> I'm importing a CSV using the fgetcsv() function, which is working all good. However, when I take a look at the data in the database, I see black diamonds with question marks. This isn't too much of an issue when echoing the data back out again, as they don't appear, but when I want to use one of the CSV fields as a MySQL date, it isn't recognised as a date and is stored as 0000-00-00. e.g. I think this issue is something to do with encoding of the CSV? Can anyone offer any advice? If it helps here is my import script, and the encode type is ASCII according to mb_detect_encoding Code: [Select] <?php include 'config.php'; include 'opendb.php'; ini_set("auto_detect_line_endings", true); $row = 0; $tmpName = $_FILES['csv']['tmp_name']; if (($handle = fopen($tmpName, "r")) !== FALSE) { $num = count($data); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $noQuotes = str_replace("\"", '', $data); $originalDate = $noQuotes[1]; //$delivery_date = date('Y-m-d', strtotime($originalDate)); $parts = explode('/', $originalDate); $delivery_date = $parts[2] . '-' . $parts[1] . '-' . $parts[0]; $row++; $import="INSERT into dispatch (delivery_note_number, delivery_date, dispatch_date, customer_delivery_date, delivery_line, produce, variety, quantity, pallets, count, depot, customer, grower, haulier, status) values ('$noQuotes[0]', '$delivery_date', '$noQuotes[2]', '$noQuotes[3]', '$noQuotes[4]', '$noQuotes[5]', '$noQuotes[6]', '$noQuotes[7]', '$noQuotes[8]', '$noQuotes[9]', '$noQuotes[10]', '$noQuotes[11]', '$noQuotes[12]', '$noQuotes[13]', '$noQuotes[14]')"; echo $import; mysql_query($import) or die(mysql_error()); } //header("location:list_dispatch.php?st=recordsadded"); fclose($handle); } ?> I have a picture (attached), where I find the coordinates of black points, because I do not remember any point, so you want every point at which I find coordinates with mark a red cross as watermark. At the coordinates using this script: <?php if(isset($_GET["obrazek_x"])) file_put_contents("soubor.txt",$_GET["obrazek_x"].",".$_GET["obrazek_y"]."\n",FILE_APPEND); ?> Coordinates I save to an external file in this format: Code: [Select] 602;744 Could you advise me a solution to mark black points? hi, i am trying to generate image gallery. but the problem is that when i upload the png files its thumbnail is generated with black background. JPEG an GIF thumbnail are generated successfully. i want to make background transparent. is there any solution that how i can get rid of it. i am using imagecreatetruecolor($thumbwidth, $thumbheight ); to generate thumbnail Hey all. I'm getting down the basics of the GD Library's image creation processes. I'm trying to test out creating png images. However, where there should be transparency there is a black background. Here's my code mostly based on the image tutorial found here at phpfreaks. Code: [Select] <?php // font $font = 'c:\windows\fonts\arial.ttf'; $fontsize = 12; // array of quotes $quotes = array( "I like pie.", "Surf's Up.", "Smoke em if you got em.", "Game on.", "I need TP for my bunghole."); // select quote $pos = rand(0,count($quotes)-1); $quote = $quotes[$pos]; // image $image = imagecreatefrompng('quote.png'); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); imagettftext($image, 11, 0, 107, 32, $black, $font, $quote); imagettftext($image, 11, 0, 105, 30, $white, $font, $quote); // tell the browser that the content is an image header('Content-type: image/png'); // output image to the browser imagepng($image); // delete the image resource imagedestroy($image); ?> Cheers all, thanks! Hi All, Everything is working pretty good, its just the thumbnail portion that adds a black background to every picture it converts. When the user uploads a picture, I take the original picture and then make a thumbnail, so I have 2 images in my fileroot. The original picture looks just fine, its just when I open the thumbnail. Attached is a sample of the black background picture. Below is just the thumbnail portion of the code. Code: [Select] include('uploads/image.php'); $image = $path; $thumb = new SimpleImage(); $thumb->load($image); $width = 150; $height = 95; $thumb->resize($width,$height); $thumb->save('uploads/thumbnails/'.$filename); image.php Code: [Select] class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } what im trying to do is take a youtube embed code find the URL code for that video and remove all other parts of the code keeping only the URL of the video after i get the URL by it self then replace the http://www.youtube.com/ part of the URL with http://i2.ytimg.com/vi/ to do this i know that i need something like this to get the URL of the video http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+) but how to only return just the URL is something idk how to do then use str_replace http://www.youtube.com/(?:v|cp)/" with http://i2.ytimg.com/vi/ so in the end im asking if anyone know how to remove all other codes i dont want and only keep the URL this may have to be done using "regex" im not sure as i dont know to much about regex and what it can do but does sound like it would help lol Dear All Good Day, i am new to PHP (a beautiful server side scripting language). i want to send a mail with line by line message i tried with different types like by placing the things in table and using <br /> but the thing is the tags are also visible in the message of the mail. Here is my code: $message1 = "Name :". $_REQUEST['name']."<br />"; $message1 .= "Surname :". $_REQUEST['surname']."<br />"; $message1 .= "Cellphone :". $_REQUEST['mobileno']."<br />"; $message1 .= "Telephone :". $_REQUEST['landno']."<br />"; $message1 .= "Fax :". $_REQUEST['fax']."<br />"; $message1 .= "Company :". $_REQUEST['company']."<br />"; $message1 .= "Email :". $_REQUEST['email']."<br />"; $message1 .= "Country :". $_REQUEST['country']."<br />"; $message1 .= "Enquity :". $_REQUEST['enquiry']."<br />"; $message1 .= "Date&Time :". $date."<br />"; For this code if try to print/echo it it is working fine it is displaying line by line, but using this variable ($message1) in the mail these <br /> are also visible. Can any one guide me to resolve(to remove these tags from the message part) this issue. Thanks in Advance. :confused: i have to read a single line from a csv, its a really big file and i only need one column.
i need the response to be a string ,i made a search and found the following code but i dont have any idea how to get a single line from a single string per run .
<?php $row = 1; //open the file if (($handle = fopen("file.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } ?> Edited by bores_escalovsk, 16 May 2014 - 06:38 PM. |