[PHP] Trouble with thumbnail generation using GD

2004-04-21 Thread Haddad Said
Hi, i was trying to create thumbnail using a tutorial on image galleries,
I am having problems creating thumbnail images using GD. The thumbnail is
created with the sizes prorerly, however the image is black.

I have posted a temporary php file i created to investigate the problem
below.

I suspect the problem is with the imagecopyresampled function.

I am using php version 4.3.4 with GD ver 2.0.x in windows XP for the test
machine

I appreciate any help


Thanks
PHP:


?php
$submit = $_POST['submit'];
if(isset($submit))
{
$file = $_FILES['file'];
$filename = any.jpg;
move_uploaded_file($file['tmp_name'], $filename);

$height = get_size($filename, height);
$width = get_size($filename, width);

$source_handle = ImageCreateFromJPEG($filename);
$destination_handle = ImageCreateTrueColor($width, $height);

ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0,
$width, $height, $size[0], $size[1]);
ImageJPEG($source_handle, './tb_' . $filename);

echo Success!!?brbrbrimg src=./tb_any.jpg /?
exit();
}
function get_size($filename, $dimension)
{
global $images_dir;
$size = GetImageSize($filename);
// Wide Image
if($size[0]  $size[1])
{
  $thumbnail_width = 100;
  $thumbnail_height = (int)(100 * $size[1] / $size[0]);
}
// Tall Image
else
{
   $thumbnail_width = (int)(100 * $size[0] / $size[1]);
   $thumbnail_height = 100;
}
if($dimension == width)
{
  return $thumbnail_width;
}
else
{
  return $thumbnail_height;
}
}
?

form action=?=$PHP_SELF? name=frmAdd method=post
enctype=multipart/form-data 
pTitle:brinput type=text size=54 name=article_title //p

pDescription:brtextarea name=article_text rows=10
cols=40/textarea/p
pFile:brinput name=file type=file size=54 //p
pinput type=submit name=submit value=Submit //p/form

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passing variable arguments from select

2002-06-27 Thread Haddad Said

I still cant get it right,

in query.php i have this piece of code;

echo form action='test2.php' action='post'
select name='language'
option value='0'selected='yes'one/option
option value='1'two/option
/select
input type=text name=query
input type=submit name=submit
/form;

and in test2.php i have this;

if ($_POST['language'] = 1)
{$lang = EngP=1;}
else {$lang = EngP=0;}
echo $lang ;

But it always echoes EngP=1 no matter what I choose, what is wrong here??



Erik Price [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 On Wednesday, June 26, 2002, at 02:51  PM, Haddad Said wrote:

  Hi, i am having a problem passing variables from a drop down menu in a
  form;
 
  from action=test.php action=post
  select name=example
  option selected one/option
  option two/option
  /form

 You should do it like this (be sure to properly quote your attributes,
 and use the 'value' attribute of the 'option' tag):

 print form action='test.php' method='post'
 select name='example'
 option selected='yes' value='1'One/option
 option value='2'Two/option
 /select
   /form\n;

 In the test.php page, the selected value will be found in the
 $_POST['example'] variable.


 Erik





 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] passing variable arguments from select

2002-06-27 Thread Haddad Said

Yes I changed that, but now it always echoes EngP=0

Mark Heintz Php Mailing Lists [EMAIL PROTECTED] wrote in
message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Thu, 27 Jun 2002, Haddad Said wrote:

  in query.php i have this piece of code;
 
  echo form action='test2.php' action='post'
  select name='language'
  option value='0'selected='yes'one/option
  option value='1'two/option
  /select
  input type=text name=query
  input type=submit name=submit
  /form;
 
  and in test2.php i have this;
 
  if ($_POST['language'] = 1)
  {$lang = EngP=1;}
  else {$lang = EngP=0;}
  echo $lang ;
 
  But it always echoes EngP=1 no matter what I choose, what is wrong
here??


 if ($_POST['language'] == 1)


 You have an assignment operator instead of a comparison in your if
 statement.

 mh.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] passing variable arguments from select

2002-06-27 Thread Haddad Said

I just found out the $_POST['language'] is always assigned the value Array.
Since a user must choose either of the options and not both, I would rather
do this without arrays, is there another way?


Haddad Said [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Yes I changed that, but now it always echoes EngP=0

 Mark Heintz Php Mailing Lists [EMAIL PROTECTED] wrote in
 message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  On Thu, 27 Jun 2002, Haddad Said wrote:
 
   in query.php i have this piece of code;
  
   echo form action='test2.php' action='post'
   select name='language'
   option value='0'selected='yes'one/option
   option value='1'two/option
   /select
   input type=text name=query
   input type=submit name=submit
   /form;
  
   and in test2.php i have this;
  
   if ($_POST['language'] = 1)
   {$lang = EngP=1;}
   else {$lang = EngP=0;}
   echo $lang ;
  
   But it always echoes EngP=1 no matter what I choose, what is wrong
 here??
 
 
  if ($_POST['language'] == 1)
 
 
  You have an assignment operator instead of a comparison in your if
  statement.
 
  mh.
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] passing variable arguments from select

2002-06-26 Thread Haddad Said

Hi, i am having a problem passing variables from a drop down menu in a form;

from action=test.php action=post
select name=example
option selected one/option
option two/option
/form

So how will the values of $example be assigned in test.php?

THanks



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Remote cgi script function

2002-06-24 Thread Haddad Said

Thanks John,

See when i echo $contents, the page displayed contains backgrounds and other
text from the remote site, how can i crop only the returned query and
display it in a page with my backgrounds etc

thanks

John Holmes [EMAIL PROTECTED] wrote in message
000a01c21aef$f58fc0a0$b402a8c0@mango">news:000a01c21aef$f58fc0a0$b402a8c0@mango...
  I am new to php, I would like to create a function that when called
  sends text from a text box as a query to a remote cgi script ,e.g
  http://www.anydomain.com/cgi-bin/script.cgi, and return the results as
 a
variable so that i can echo the returned variable to an html page.

 ?
 $contents = ;
 $text = whatever...;

 $ftext = urlencode($text);

 $fp = fopen(http://www.example.com/cgi-bin/script.cgi?text=; . $ftext,
 r);

 while($data = fread($fp,1000))
 { $contents .= $data; }

 fclose ($fd);

 ?

 The response is now in $contents. Adapt to your needs.

 ---John Holmes...




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Remote cgi script function

2002-06-23 Thread Haddad Said

Hi,

I am new to php, I would like to create a function that when called
sends text from a text box as a query to a remote cgi script ,e.g
http://www.anydomain.com/cgi-bin/script.cgi, and return the results as a
  variable so that i can echo the returned variable to an html page.

I would appreciate any help on this

Thanks




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php