473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Variable passing to script to fill html <img src="MyScript.Php?ImageName=KnownGoodData" >

Hello,

I'm trying to do the above in order to process an image and return the
result to an html image control. It fails and my key suspects are either
the variable that I'm passing in - ImageName - for processing, or the return
data which is done (or not as the case may be) by imagejpeg($img) in the
script, after header("Content-type: image/jpeg").

Any insights would be most welcome, especially debugging techniques and a
pointer to resources to help me get a better feel for this complex
landscape.

Many thanks,

Gregory
Jul 17 '05 #1
14 13033
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
I'm trying to do the above in order to process an image and return the
result to an html image control. It fails and my key suspects are either
the variable that I'm passing in - ImageName - for processing, or the
return data which is done (or not as the case may be) by imagejpeg($img)
in the
script, after header("Content-type: image/jpeg").


Hi Gregory,

It would help if you could post the relevant code and error messages.

Stab in the dark:

Do you use $_GET['ImageName'] to retrieve the value?

JOn
Jul 17 '05 #2
Hello Jon,

No, I wasn't, but it still doesn't work.

Here's part of the loop that prints details and tries to print the image:

<?php $FilNam = $row_PrpSummary['FileName']; ?>
<td><img src="mkimg.php?ImageName=$FilNam" ></td>
<td>

Then mkimg.php starts like this (and maybe there needs to be header info):

<?php
echo $_GET['ImageName']; //--- debug attempt!
$image_path = 'e:\property\\data\\images\\' . $_GET['ImageName'];

There are no error messages.

Many thanks,

Gregory.

"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:bn*************@ID-175424.news.uni-berlin.de...
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
I'm trying to do the above in order to process an image and return the
result to an html image control. It fails and my key suspects are either the variable that I'm passing in - ImageName - for processing, or the
return data which is done (or not as the case may be) by imagejpeg($img)
in the
script, after header("Content-type: image/jpeg").


Hi Gregory,

It would help if you could post the relevant code and error messages.

Stab in the dark:

Do you use $_GET['ImageName'] to retrieve the value?

JOn

Jul 17 '05 #3
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:bn*************@ID-175424.news.uni-berlin.de...
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
> the variable that I'm passing in - ImageName - for processing, or the
> return data which is done (or not as the case may be) by
> imagejpeg($img) in the
> script, after header("Content-type: image/jpeg").


Do you use $_GET['ImageName'] to retrieve the value?


No, I wasn't, but it still doesn't work.

Here's part of the loop that prints details and tries to print the image:

<?php $FilNam = $row_PrpSummary['FileName']; ?>
<td><img src="mkimg.php?ImageName=$FilNam" ></td>
<td>


Hi Gregory,

The above should be:

<td><img src="mkimg.php?ImageName=<?php echo urlencode($FilNam); ?>" ></td>

HTH;
JOn
Jul 17 '05 #4
Gregory wrote:
Then mkimg.php starts like this (and maybe there needs to be header info):

<?php
echo $_GET['ImageName']; //--- debug attempt!
$image_path = 'e:\property\\data\\images\\' . $_GET['ImageName'];


I would assume then you are doing something like this to output the data:

mkimg.php:
==========
<?php
$image_path = 'e:\property\\data\\images\\' . $_GET['ImageName'];
$fp=fopen($image_path,'rb');
$data=fread($fp,filesize($image_path));
header("Content-type: image/jpeg");
echo $data;
?>

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #5
Thanks Jon and Justin, but it still fails. Is there any way that I can
check for the value inside the scrip file? Both files are in the same
directory. When I test for $_GET['ImageName'] back in the main file,
nothing is displayed.

Gregory.
"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:bn*************@ID-175424.news.uni-berlin.de...
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:bn*************@ID-175424.news.uni-berlin.de...
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:

> the variable that I'm passing in - ImageName - for processing, or the
> return data which is done (or not as the case may be) by
> imagejpeg($img) in the
> script, after header("Content-type: image/jpeg").

Do you use $_GET['ImageName'] to retrieve the value?


No, I wasn't, but it still doesn't work.

Here's part of the loop that prints details and tries to print the image:
<?php $FilNam = $row_PrpSummary['FileName']; ?>
<td><img src="mkimg.php?ImageName=$FilNam" ></td>
<td>


Hi Gregory,

The above should be:

<td><img src="mkimg.php?ImageName=<?php echo urlencode($FilNam); ?>"
</td>

HTH;
JOn

Jul 17 '05 #6
Justin Koivisto <sp**@koivi.com> wrote:
I would assume then you are doing something like this to output the data:

mkimg.php:
==========
<?php
$image_path = 'e:\property\\data\\images\\' . $_GET['ImageName']; ^ ^^

In a string created with single quotes, 1 \ is sufficient AFAIK. It's
been a while I used a MS OS but to play it save e:/foo/bar should work
well.
$fp=fopen($image_path,'rb');
$data=fread($fp,filesize($image_path));
Barf.

1) opening a file without checking if it exists.
2) why do it the hardway if you only going to push it to the client?
header("Content-type: image/jpeg");
echo $data;
?>


<?php

if(file_exists($image_path))
{
header("Content-type: image/jpeg");
readfile($image_path);
}
else
{
die("file does not exist: $image_path");
}
--

Daniel Tryba

Jul 17 '05 #7
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
Thanks Jon and Justin, but it still fails. Is there any way that I can
check for the value inside the scrip file? Both files are in the same
directory. When I test for $_GET['ImageName'] back in the main file,
nothing is displayed. Gregory.


I beleive, to pass parameters after I think php 4.2?
Default setting of register_globals is off instead
of on. Can you validate what version you are using?
This would explain you getting nothing back.

if so, contain the following in .htaccess
php_flag register_globals on

look at ..
http://us3.php.net/manual/en/languag...s.superglobals

Hope this helps.
-Walt
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #8
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
"Jon Kraft" <jo*@jonux.co.uk> wrote:
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
> "Jon Kraft" <jo*@jonux.co.uk> wrote:
>> Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
>>
>> > the variable that I'm passing in - ImageName - for processing, or
>> > the return data which is done (or not as the case may be) by
>> > imagejpeg($img) in the
>> > script, after header("Content-type: image/jpeg").
>>
>> Do you use $_GET['ImageName'] to retrieve the value?
>>
> No, I wasn't, but it still doesn't work.


Thanks Jon and Justin, but it still fails. Is there any way that I can
check for the value inside the scrip file? Both files are in the same
directory. When I test for $_GET['ImageName'] back in the main file,
nothing is displayed.


Which version of PHP are you running? If less than 4.2.x try using:

$HTTP_GET_VARS['ImageName'];

JOn
Jul 17 '05 #9
I don't think that the script is even being called.

I've tried
<td width="150"><img src="mkimg.php?ImageName=<?php echo urlencode($FilNam);
?>" ></td>
and
<td width="150"><img src="c:\InetPub\wwwroot\property\test.php" ></td>
and put a die statement as the first command, but it lives. Perhaps my set
up is wrong.

Thanks,

Gregory

"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:bn*************@ID-175424.news.uni-berlin.de...
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
"Jon Kraft" <jo*@jonux.co.uk> wrote:
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:

> "Jon Kraft" <jo*@jonux.co.uk> wrote:
>> Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
>>
>> > the variable that I'm passing in - ImageName - for processing, or
>> > the return data which is done (or not as the case may be) by
>> > imagejpeg($img) in the
>> > script, after header("Content-type: image/jpeg").
>>
>> Do you use $_GET['ImageName'] to retrieve the value?
>>
> No, I wasn't, but it still doesn't work.


Thanks Jon and Justin, but it still fails. Is there any way that I can
check for the value inside the scrip file? Both files are in the same
directory. When I test for $_GET['ImageName'] back in the main file,
nothing is displayed.


Which version of PHP are you running? If less than 4.2.x try using:

$HTTP_GET_VARS['ImageName'];

JOn

Jul 17 '05 #10
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:

"Jon Kraft" <jo*@jonux.co.uk> wrote:
>> >>
>> >> Do you use $_GET['ImageName'] to retrieve the value?
>> >>
>> > No, I wasn't, but it still doesn't work.
>
> Thanks Jon and Justin, but it still fails. Is there any way that I can
> check for the value inside the scrip file? Both files are in the same
> directory. When I test for $_GET['ImageName'] back in the main file,
> nothing is displayed.
Which version of PHP are you running? If less than 4.2.x try using:

I don't think that the script is even being called.

I've tried
<td width="150"><img src="mkimg.php?ImageName=<?php echo
urlencode($FilNam); ?>" ></td>
and
<td width="150"><img src="c:\InetPub\wwwroot\property\test.php" ></td>


The second line would be wrong; the first line should at least call the PHP
script. Make sure the PHP script does actually echo an appropriate image
header, like image/jpeg. We replied each other so many times, I think it'd
be good if you could post the whole mkimg.php?

JOn
Jul 17 '05 #11
VVVVVVVVVVVVVVVVV

Key question has been asked several times WHAT VERSION of
php are you running? Your question is pivotal on 4.2!

-Walt

Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
I don't think that the script is even being called. I've tried
<td width="150"><img src="mkimg.php?ImageName=<?php echo urlencode($FilNam);
?>" ></td>
and
<td width="150"><img src="c:\InetPub\wwwroot\property\test.php" ></td>
and put a die statement as the first command, but it lives. Perhaps my set
up is wrong. Thanks, Gregory


Which version of PHP are you running? If less than 4.2.x try using:

$HTTP_GET_VARS['ImageName'];

JOn


--
Reply to innkeepATcapitalDOTnet to email questions.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #12
Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
Hello Jon, No, I wasn't, but it still doesn't work. Here's part of the loop that prints details and tries to print the image: <?php $FilNam = $row_PrpSummary['FileName']; ?>
<td><img src="mkimg.php?ImageName=$FilNam" ></td>
<td>
Ahhhh this should read ..... ?ImageName={$FilNam}" .........

don't you agree?

-Walt
Then mkimg.php starts like this (and maybe there needs to be header info): <?php
echo $_GET['ImageName']; //--- debug attempt!
$image_path = 'e:\property\\data\\images\\' . $_GET['ImageName'];


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #13
PenguinsAnonymous wrote:
I beleive, to pass parameters after I think php 4.2?
Default setting of register_globals is off instead
of on. Can you validate what version you are using?
This would explain you getting nothing back. if so, contain the following in .htaccess
php_flag register_globals on look at ..
http://us3.php.net/manual/en/languag...s.superglobals

Also it turns out this was bad advice...
On rereading the doc I pointed to several times I
had missed a subtlty.
enablement of register_globals leaves the passed
&xxx variables in a global space. This clutter
was abandoned in 4.2 with the super global usage
of $_GET. (internal to php)
so it is a deprecated functionality
also $HTTP_GET_VARS is deprecated.
check the missing '{}' I pointed to bet that works.

Sorry to confuse :)
-Walt
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #14
Hi Walt, Jon and Daniel,

Sorry to be slow on that. I had to attend to some other things, and I also
have cleaned up the examples that I'm sending here. It's php 4.3.3. Global
vars in the ini are set to off as recommended in the ini file itself, but
does not the $_GET function allow access to variables? - Ah I've just seen
your new post re globals. I'll have to re-read the manual.

Ok, here's the main file, which does display the original images. I've left
that functionality in to show that it works. I used dreamweaver to create
it in the first place, but the trial period's run out and I haven't decided
wherther or not to buy it yet.

<?php require_once('Connections/connProperty.php'); ?>
<?php
# Constants
//define(IMAGE_BASE, '/var/www/html/mbailey/images');
define(MAX_WIDTH, 150);
define(MAX_HEIGHT, 150);

$maxRows_PrpSummary = 9;
$pageNum_PrpSummary = 0;
if (isset($_GET['pageNum_PrpSummary'])) {
$pageNum_PrpSummary = $_GET['pageNum_PrpSummary'];
}
$startRow_PrpSummary = $pageNum_PrpSummary * $maxRows_PrpSummary;

mysql_select_db($database_connProperty, $connProperty);
$query_PrpSummary = "SELECT Prp.PreStreet House, Str.Name Street, sCi.Name
Borough, Cit.Name City,
ssC.Name District, sCy.Name County, Cry.Name
Country, PcX.Pic PcXPic,
Pic.Id PicId, Pic.FileName FileName,
Pic.FileLocation Location
FROM Property AS Prp
Left Outer Join Country Cry On Cry.Id = Prp.Cry
Left Outer Join sCountry sCy On sCy.Id = Prp.sCy
Left Outer Join ssCountry ssC On ssC.Id = Prp.ssC
Left Outer Join City Cit On Cit.Id = Prp.Cit
Left Outer Join sCity sCi On sCi.Id = Prp.sCi
Left Outer Join Street Str On Str.Id = Prp.Str
Left Outer Join PicToX PcX On PcX.TargetId =
Prp.Id And PcX.TargetType = 21
And PcX.Priority = 1
Left outer join Picture Pic On Pic.Id = PcX.Pic
";
$query_limit_PrpSummary = sprintf("%s LIMIT %d, %d", $query_PrpSummary,
$startRow_PrpSummary, $maxRows_PrpSummary);
$PrpSummary = mysql_query($query_limit_PrpSummary, $connProperty) or
die(mysql_error());
$row_PrpSummary = mysql_fetch_assoc($PrpSummary);

if (isset($_GET['totalRows_PrpSummary'])) {
$totalRows_PrpSummary = $_GET['totalRows_PrpSummary'];
} else {
$all_PrpSummary = mysql_query($query_PrpSummary);
$totalRows_PrpSummary = mysql_num_rows($all_PrpSummary);
}
$totalPages_PrpSummary = ceil($totalRows_PrpSummary/$maxRows_PrpSummary)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="image/jpeg; charset=iso-8859-1">
</head>

<body>
<table width="487" border="2" align="left" bgcolor="#99FFCC" frame="below">
<tr><td width="291">Address</td></tr>
<?php do { ?>
<tr>
<td height="107">
<?php echo $row_PrpSummary['House']; ?><br>
<?php echo $row_PrpSummary['Street']; ?><br>
<?php echo $row_PrpSummary['Borough']; ?><br>
<?php echo $row_PrpSummary['City']; ?><br>
<?php echo $row_PrpSummary['District']; ?><br>
<?php echo $row_PrpSummary['County']; ?> <?php echo
$row_PrpSummary['Country']; ?>
</td>
<td> <! Orig image.
<img src="<?php echo 'e:\\property\\data\\images\\' .
$row_PrpSummary['FileName'];?>">
</td>
<td> <! Try to call mkimg.php.
<img src="mkimg.php?ImageName=<?php echo 'e:\\property\\data\\images\\'
.. $row_PrpSummary['FileName'];?>" >
</td>
<td>
<?php echo 'e:\\property\\data\\images\\' .
$row_PrpSummary['FileName'];?> <! testing that data's ok.
</td>
</tr>
<?php } while ($row_PrpSummary = mysql_fetch_assoc($PrpSummary)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($PrpSummary);
?>
And here is the script to make a smaller image. Again, this worked in it's
original form. I tested it with a single known image and it worked, but I
haven't tested it since messing around with it. I don't think that it's
actually being called, as it won't even die().

<?php
define(MAX_WIDTH, 150);
define(MAX_HEIGHT, 150);
die('here I am');
echo $image_path = 'e:\\property\\data\\images\\' . $_GET['ImageName'];
$img = null;
$ext = strtolower(end(explode('.', $image_path)));
if ($ext == 'jpg' || $ext == 'jpeg') {
$img = @imagecreatefromjpeg($image_path);
} else if ($ext == 'png') {
$img = @imagecreatefrompng($image_path);
# Only if your version of GD includes GIF support
} else if ($ext == 'gif') {
$img = @imagecreatefrompng($image_path);
}

# If an image was successfully loaded, test the image for size
if ($img) {
# Get image size and scale ratio
$width = imagesx($img);
$height = imagesy($img);
$scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);

# If the image is larger than the max shrink it
if ($scale < 1) {
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);

# Create a new temporary image
$tmp_img = imagecreatetruecolor($new_width, $new_height);

# Copy and resize old image into new image
imagecopyresized($tmp_img, $img, 0, 0, 0, 0,
$new_width, $new_height, $width, $height);
imagedestroy($img);
$img = $tmp_img;
}
}

# Create error image if necessary
if (!$img) {
$img = imagecreate(MAX_WIDTH, MAX_HEIGHT);
imagecolorallocate($img,0,0,0);
$c = imagecolorallocate($img,70,70,70);
imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2);
imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2);
}

header("Content-type: image/jpeg");
imagejpeg($img);
?>

Thanks,

Gregory.

<PenguinsAnonymous> wrote in message news:3f********@corp.newsgroups.com...
VVVVVVVVVVVVVVVVV

Key question has been asked several times WHAT VERSION of
php are you running? Your question is pivotal on 4.2!

-Walt

Gregory <php at neutrino-soft @@@ ware.co.uk> wrote:
I don't think that the script is even being called.

I've tried
<td width="150"><img src="mkimg.php?ImageName=<?php echo urlencode($FilNam);
?>" ></td>
and
<td width="150"><img src="c:\InetPub\wwwroot\property\test.php" ></td>
and put a die statement as the first command, but it lives. Perhaps my set up is wrong.

Thanks,

Gregory


Which version of PHP are you running? If less than 4.2.x try using:

$HTTP_GET_VARS['ImageName'];

JOn


--
Reply to innkeepATcapitalDOTnet to email questions.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Jul 17 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Rigga | last post by:
Hi, Ok first please bear with me as I am a total Python n00b.. Can anyone explain why this does not like me using % FileLoc in the os.system call??? #!/usr/bin/python import sys import os
6
by: Hansan | last post by:
Hi all. I am working on a webpage where I use python and html. When I want to send one variable to a new script/page I use the following code: 0) print '''<input type=hidden name="eventid"...
2
by: Holger Butschek | last post by:
Hi folks, first of all, I'm absolutly new to javascript. I have designed a html-form and am trying to path parameters with the suffix of i.e. ?Seminartitel=hallowelt in the url. In the head...
0
by: Khairol | last post by:
Hi, how to use cookies in asp.net in code behind and also how to use script in html... its seem an error occurs when i want to use script. example: when i select a drop down or a check box...
3
by: John Baker | last post by:
Hi:7 Newby here to ASP, and using the ASP.NET Web Matrix development tool. While that tool looks great for a Newby, I have run into a snag. I have an HTML Text Box which I have named HireInput,...
7
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it...
2
by: pradnya | last post by:
How to share/use a variable between PHP and HTML on the same page ? ( i.e. without using GET/ POST etc.... ) Is it possible ? And what about same with PHP and JavaScript ?
1
rajiv07
by: rajiv07 | last post by:
Hi to All, I have try to execute a perl script in html.But nothing get display What i have tried so for is The referrer.pl --------------- #!/usr/bin/perl
7
by: nassausky | last post by:
I acquired a very basic redirect script from: http://www.minisitegallery.com/blog/php-javascript-countdown-script-with-timezone-setting.html which is supposed to count down to a specified date and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.