troubleshooting Question

having trouble displaying ph generated image

Avatar of paries
paries asked on
PHP
20 Comments1 Solution363 ViewsLast Modified:
hello,
if i call this page directly
http://mydomain/inc/utils/generateTicket.php
i get an image displayed in the browser

now i am trying to display this image with a jquery/ajax call.

if i call printTicket and the URL is generateTicket.php
the display is a bunch of unprintable characters

so then i tried
url: "/inc/utils/eticket.php", which is basically ::
<?php
    print "<img src = 'generateTicket.php'>";
?>
this displayed nothing

then i tried
<?php
    require_once 'generateTicket.php';
?>
and got the garbage again (see image )

thanks for any help





<?php

// PHP File used to quickly put some text over a poster image - for video or other.

// To use:  Use this file as the source file of an image.  Pass it two GET variables:  pat=path of image&text=text to overlay

header("Content-Type: image/jpeg");

// Open the image:

$image = imagecreatefromjpeg('/home/events/html/templates/ticket.jpg');

$width = imagesx($image); // Gets the width - better to use imagesx here as we don't need to feed it a path, just a handle.

$rectCol = imagecolorallocatealpha($image, 0, 0, 0, 100); // Create a black colour, slightly transparent
$textCol = imagecolorallocate($image, 255, 255, 255); // Create a white colour

// Fill the top of the image with this rectangle...

//imagefilledrectangle($image, 350, 10, 730, 150, $rectCol);

//imagefilledrectangle($image, 0, 0, $width, 50, $rectCol);

//Title
$textX = 350;
$textY = 50; // X and Y values for the text generation

$font = '/home/events/html/templates/verdanab.ttf'; // Replace this with the path to your font file.

// Write Text:
imagettftext($image, 18, 0, $textX, $textY, $textCol, $font, 'test');

// Now we're done editing... output the final image:

imagejpeg($image);

// Free up some space:

imagedestroy($image);


?>
function printTicket(e, f){
   $('#shadowBox').height($('#mainBody').height()).fadeIn('fast',
     function(){
       $.ajax({
          url: "/inc/utils/eticket.php",
          type: 'GET',
          data:'e='+e,
          beforeSend: function(){
            $('#popup').animate({width: "750px"}, 330);
          },
          error: function(jqXHR, textStatus, errorThrown){
            $('#popupContent').html(
              '<div class="error">'
                +'<div class="errorLine">'+textStatus+': '+errorThrown+'</div>'
              +'</div>'
            ).fadeIn(250);
          },
          success: function(data){
             $('#popupContent').html(data).fadeIn(250);
          }
       });
    });
}
Capture2a.PNG
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 20 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros