Hi all

for some reason this script keeps dispaying the url of the script instead of its text.

Im using php 5.2

apache v2.0.xx

<?php
// Set the content-type
header("Content-type: image/jpg");

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

all i get is http://localhost/gddemo.php

any ideas

thanks

    One problem I see is that you're sending a PNG image, but telling the client it's a JPEG.

      Nah its more then that

      Tried it all ways

      phpinfo shows no gd lib installed. Yet in php.ini it is there without the ;

      It is on windows so might a file needed or something..

      any install suggestions

      I had the same outcome with php4.4.4

        1. Where is the php.ini file located, and

        2. Did you use PHPIniDir to tell Apache where it is?

          yes to both

          still comes up with an error

            the image works but only displays the script url location

              ;extension=php_mbstring.dll
              ;extension=php_bz2.dll
              ;extension=php_curl.dll
              ;extension=php_dba.dll
              ;extension=php_dbase.dll
              ;extension=php_exif.dll
              ;extension=php_fdf.dll
              ;extension=php_filepro.dll
              extension=php_gd2.dll
              ;extension=php_gettext.dll
              ;extension=php_ifx.dll
              ;extension=php_imap.dll
              ;extension=php_interbase.dll
              ;extension=php_ldap.dll
              ;extension=php_mcrypt.dll
              ;extension=php_mhash.dll
              ;extension=php_mime_magic.dll
              ;extension=php_ming.dll
              ;extension=php_mssql.dll
              ;extension=php_msql.dll
              ;extension=php_mysql.dll
              ;extension=php_oci8.dll
              ;extension=php_openssl.dll
              ;extension=php_oracle.dll
              ;extension=php_pgsql.dll
              ;extension=php_shmop.dll
              ;extension=php_snmp.dll
              ;extension=php_sockets.dll
              ;extension=php_sqlite.dll
              ;extension=php_sybase_ct.dll
              ;extension=php_tidy.dll
              ;extension=php_xmlrpc.dll
              ;extension=php_xsl.dll

              these are the extensions in php.ini

              http config

              #
              LoadModule access_module modules/mod_access.so
              LoadModule actions_module modules/mod_actions.so
              LoadModule alias_module modules/mod_alias.so
              LoadModule asis_module modules/mod_asis.so
              LoadModule auth_module modules/mod_auth.so
              #LoadModule auth_anon_module modules/mod_auth_anon.so
              #LoadModule auth_dbm_module modules/mod_auth_dbm.so
              #LoadModule auth_digest_module modules/mod_auth_digest.so
              LoadModule autoindex_module modules/mod_autoindex.so
              #LoadModule cern_meta_module modules/mod_cern_meta.so
              LoadModule cgi_module modules/mod_cgi.so
              #LoadModule dav_module modules/mod_dav.so
              #LoadModule dav_fs_module modules/mod_dav_fs.so
              LoadModule dir_module modules/mod_dir.so
              LoadModule env_module modules/mod_env.so
              #LoadModule expires_module modules/mod_expires.so
              #LoadModule file_cache_module modules/mod_file_cache.so
              #LoadModule headers_module modules/mod_headers.so
              LoadModule imap_module modules/mod_imap.so
              LoadModule include_module modules/mod_include.so
              #LoadModule info_module modules/mod_info.so
              LoadModule isapi_module modules/mod_isapi.so
              LoadModule log_config_module modules/mod_log_config.so
              LoadModule mime_module modules/mod_mime.so
              #LoadModule mime_magic_module modules/mod_mime_magic.so
              #LoadModule proxy_module modules/mod_proxy.so
              #LoadModule proxy_connect_module modules/mod_proxy_connect.so
              #LoadModule proxy_http_module modules/mod_proxy_http.so
              #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
              LoadModule negotiation_module modules/mod_negotiation.so
              LoadModule rewrite_module modules/mod_rewrite.so
              LoadModule setenvif_module modules/mod_setenvif.so
              #LoadModule speling_module modules/mod_speling.so
              #LoadModule status_module modules/mod_status.so
              #LoadModule unique_id_module modules/mod_unique_id.so
              LoadModule userdir_module modules/mod_userdir.so
              #LoadModule usertrack_module modules/mod_usertrack.so
              #LoadModule vhost_alias_module modules/mod_vhost_alias.so
              #LoadModule ssl_module modules/mod_ssl.so

              LoadModule php5_module c:/php/php5apache2.dll

              AddType application/x-httpd-php .php

              PHPIniDir C:/php

              They are correct I think

                So you're saying that when you run that code, instead of an image that says "Testing...." in a shadowed black-on-white Arial font (which is what I get), you get an image that says "http://localhost/gddemo.php" in a shadowed black-on-white Arial font?!

                I have to admit I have no idea why the value of $text should suddenly be replaced by the value of $_SERVER['REQUEST_URI'].

                  Any chance you can post an URL to this script for us to see?

                    Uh... well that would have been nice to know. It doesn't "[display] the script url location" ... it displays the URL inside of an error message.

                    1. Did you fix your header() statement to correctly identify the image type, as per Weedpacket's suggestion?

                    2. Is display_errors set to On and error_reporting set to E_ALL (or, numerically, 2047).

                    3. Since you're getting an error, have you tried commenting out the header() call completely to see the raw text being outputted (possibly along with an error message, assuming you've answered affirmatively to point #2 above)?

                      yes png

                      still the same I was told that if cmyk is outputed via moz/ie it produces that error.

                      phpinfo doesnt show gd2 either

                      something dodgy

                      thing is its all setup so might have to do a reinstall

                        without the header

                        Fatal error: Call to undefined function imagecreatetruecolor() in C:\Apache\Apache2\htdocs\gddemo.php on line 7

                          jamma-pcb wrote:

                          phpinfo doesnt show gd2 either

                          Yet another vital piece of information.

                          If GD isn't installed, of course this entire script is using functions that don't exist. Try installing the GD extension.

                            I have it is in the php.ini file

                            Look above and you`ll see it without the ;

                            Any ideas

                              Where does phpinfo() say that php.ini is being read from?

                                did a reinstall and php rebootnd it works. The problem was the manual install vs MSI install. Strange it now works.

                                sp php 5.2

                                apache 2.0.59

                                use php 5.2 msi and use the default install location. GD2 you cn select with the msi file.

                                Thanks guys for the help the other settings are duely noted.

                                  Write a Reply...