php-windows Digest 26 Mar 2003 21:13:18 -0000 Issue 1654

Topics (messages 19148 through 19156):

Re: Simple Addition issue
        19148 by: Svensson, B.A.T. (HKG)

Re: uploading files
        19149 by: skate
        19152 by: Afan Pasalic
        19153 by: Afan Pasalic

Re: Read COM1
        19150 by: Jill.Ramonsky.Aculab.com
        19155 by: Kasiula Uejzyl

resized image looks baaaaadddd
        19151 by: Afan Pasalic

cURL on WinXP, running ISAPI
        19154 by: Matt Babineau

ISP Blues
        19156 by: Anthony Ritter

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
> $row['CA_state_source_income'] = "14,133";
> $row['IL_state_source_income'] = "10,556";

> When I check the value of $total_state_income it equals 24 not the expected 24,689.

> The datatype of the values returned from SQL Server are Varchar so I tried
> typecasting the values to integers before  adding them to the running total.
> 
> What am I doing wrong??

Try this and see what happend:

declare @Char2Int1 varchar(8)
declare @Char2Int2 varchar(8)
select @Char2Int1 = "14,133"
select @Char2Int2 = "10,556"

select convert(int, stuff(@Char2Int1, charindex(',', @Char2Int1, 1), 1, null)),
       convert(int, stuff(@Char2Int2, charindex(',', @Char2Int2, 1), 1, null))


If you try this:

select convert(int, @Char2Int1), convert(int, @Char2Int2)

It will generate an error since the convert function gets confused
by the comma. If you have bigger numbers like: 1,234,567 then you
need to do the below with each string that might contain a comma:

select @nPos = charindex(',', @Char2Int1, 1)
while (@nPos > 0)
begin
  select @Char2Int1 = stuff(@Char2Int1, @nPos, 1, null)
  select @nPos = charindex(',', @Char2Int1, 1)
end

this will wash away all commas from a string.


--- End Message ---
--- Begin Message ---
i saw a script that was able to do this once, where you'd select an entire
directory and it would upload the whole contents. but i'm not sure exactly
how to do it, as you run into security issues and such. i'm sure the script
was part of the php Gallery suite.

sorry i can't be of more help than that tho...

----- Original Message -----
From: "Bobo Wieland" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 26, 2003 8:45 AM
Subject: [PHP-WIN] uploading files


> Is it possible to upload multiple files at once? ...In a form, using a
> "file" input and being able to select more then one file?
>
>
> .bobo
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>



--- End Message ---
--- Begin Message --- This is a code I use for uploading up to three images at same time. Works fine:

<?php

$PHP_SELF = 'new_product.php';

$query = "select name from categories where cat_id=$cat_id";
$result = mysql_query($query, $db) or die ('Error: wrong query');
$myrow = mysql_fetch_array($result);

include('errors.php');
$error = 'n';
?>

<table width="700" border=0 cellpadding=10 cellspacing="0">
<tr>
<td width="550" align="left" valign="top">
<?php
if($_POST[SubmitAdd])
{
        if(empty($_POST[img_name]))
        {
                $error = 'y';
                print_error(123);
        }

if($_FILES[var1][size] != 0)
{
if(!stristr($_FILES[var1][name], ".jpg"))
{
$error = 'y';
print_error(125);// print: your file does not have .jpg extension
}
else
{
$NoOfImages = 1;
}
}
else
{
$error = 'y';
print_error(102);
}


if(!$_FILES[var2][size] == '0')
{
if(!stristr($_FILES[var2][name], ".jpg"))
{
$error = 'y';
print_error(125);// print: your file does not have .jpg extension
}
else
{
$NoOfImages = 2;
}
}


if($_FILES[var3][size] != '0')
{
if(!stristr($_FILES[var3][name], ".jpg"))
{
$error = 'y';
print_error(125);// print: your file does not have .jpg extension
}
else
{
$NoOfImages = 3;
}
}


if($error == 'n')
{
$img_name = $_POST[img_name];
$img_name = eregi_replace('.jpg', '', $img_name);
$img_name = stripslashes(eregi_replace(' ', '_', $img_name)).".jpg";


for($i=1; $i<=$NoOfImages; $i++)
{
${NewImage.$i} = $i."_".$img_name;
$vars = "var".$i;
copy($_FILES[$vars][tmp_name], "/home/fusionfurnituregallery.com/product_images/".${NewImage.$i});
$NewImages .= "@@".${NewImage.$i};
}


if(is_uploaded_file($_FILES[var1][tmp_name]) or is_uploaded_file($_FILES[var2][tmp_name]) or is_uploaded_file($_FILES[var3][tmp_name])) { print_error(126); }
else { $error = 'y'; print_error(127); }
}
}


if(!$_POST[SubmitAdd] or $error != 'n')
{
?>

<form ENCTYPE=multipart/form-data action="<?php echo $PHP_SELF; ?>" name=qmform method=post>
<table border="0" cellspacing="0" cellpadding="1" width=300>
<tr>
<td align="left" valign="top">Product name:<br>
<input name=prod_name value="<?php echo $_POST[prod_name]; ?>" type=text size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align="left" valign="top">Product Ser.# <span style="font-size:10px;">(no space or spec. char.):</span><br>
<input name=img_name value="<?php echo $_POST[img_name]; ?>" type=text size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align="left" valign="top">Upload 1st image:<br>
<input name=var1 type=file size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align="left" valign="top">Upload 2nd image:<br>
<input name=var2 type=file size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align="left" valign="top">Upload 3rd image:<br>
<input name=var3 type=file size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align=left valign="top">
<INPUT type=hidden name=MAX_FILE_SIZE value="<?php echo $my_max_file_size; ?>">
<input type=submit name=SubmitAdd value=" Upload ! " style="border:1 solid; font-size: 10px;"></td>
</tr></form>
</table>




Afan


At 09:45 AM 3/26/2003 +0100, Bobo Wieland wrote:
Is it possible to upload multiple files at once? ...In a form, using a
"file" input and being able to select more then one file?


.bobo



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


--- End Message ---
--- Begin Message --- Sorry, there is some part of code you don't need (as $cat_id) - I just grab it from activ file...


Afan



At 09:02 AM 3/26/2003 -0500, Afan Pasalic wrote:
This is a code I use for uploading up to three images at same time. Works fine:

<?php

$PHP_SELF = 'new_product.php';

$query = "select name from categories where cat_id=$cat_id";
$result = mysql_query($query, $db) or die ('Error: wrong query');
$myrow = mysql_fetch_array($result);

include('errors.php');
$error = 'n';
?>

<table width="700" border=0 cellpadding=10 cellspacing="0">
<tr>
<td width="550" align="left" valign="top">
<?php
if($_POST[SubmitAdd])
{
        if(empty($_POST[img_name]))
        {
                $error = 'y';
                print_error(123);
        }

if($_FILES[var1][size] != 0)
{
if(!stristr($_FILES[var1][name], ".jpg"))
{
$error = 'y';
print_error(125);// print: your file does not have .jpg extension
}
else
{
$NoOfImages = 1;
}
}
else
{
$error = 'y';
print_error(102);
}


if(!$_FILES[var2][size] == '0')
{
if(!stristr($_FILES[var2][name], ".jpg"))
{
$error = 'y';
print_error(125);// print: your file does not have .jpg extension
}
else
{
$NoOfImages = 2;
}
}


if($_FILES[var3][size] != '0')
{
if(!stristr($_FILES[var3][name], ".jpg"))
{
$error = 'y';
print_error(125);// print: your file does not have .jpg extension
}
else
{
$NoOfImages = 3;
}
}


if($error == 'n')
{
$img_name = $_POST[img_name];
$img_name = eregi_replace('.jpg', '', $img_name);
$img_name = stripslashes(eregi_replace(' ', '_', $img_name)).".jpg";


for($i=1; $i<=$NoOfImages; $i++)
{
${NewImage.$i} = $i."_".$img_name;
$vars = "var".$i;
copy($_FILES[$vars][tmp_name], "/home/fusionfurnituregallery.com/product_images/".${NewImage.$i});
$NewImages .= "@@".${NewImage.$i};
}


if(is_uploaded_file($_FILES[var1][tmp_name]) or is_uploaded_file($_FILES[var2][tmp_name]) or is_uploaded_file($_FILES[var3][tmp_name])) { print_error(126); }
else { $error = 'y'; print_error(127); }
}
}


if(!$_POST[SubmitAdd] or $error != 'n')
{
?>

<form ENCTYPE=multipart/form-data action="<?php echo $PHP_SELF; ?>" name=qmform method=post>
<table border="0" cellspacing="0" cellpadding="1" width=300>
<tr>
<td align="left" valign="top">Product name:<br>
<input name=prod_name value="<?php echo $_POST[prod_name]; ?>" type=text size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align="left" valign="top">Product Ser.# <span style="font-size:10px;">(no space or spec. char.):</span><br>
<input name=img_name value="<?php echo $_POST[img_name]; ?>" type=text size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align="left" valign="top">Upload 1st image:<br>
<input name=var1 type=file size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align="left" valign="top">Upload 2nd image:<br>
<input name=var2 type=file size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align="left" valign="top">Upload 3rd image:<br>
<input name=var3 type=file size=30 style="border:1 solid; font-size: 10px;"><br><br></td>
</tr>
<tr>
<td align=left valign="top">
<INPUT type=hidden name=MAX_FILE_SIZE value="<?php echo $my_max_file_size; ?>">
<input type=submit name=SubmitAdd value=" Upload ! " style="border:1 solid; font-size: 10px;"></td>
</tr></form>
</table>




Afan


At 09:45 AM 3/26/2003 +0100, Bobo Wieland wrote:
Is it possible to upload multiple files at once? ...In a form, using a
"file" input and being able to select more then one file?


.bobo



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


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


--- End Message ---
--- Begin Message ---
I can't see why this shouldn't work:

        $fh = fopen("COM1","rb");

then just treat $fh as a normal filehandle and read as normal.
Jill


-----Original Message-----
From: Waldemar Brand Neto [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 25, 2003 6:47 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Read COM1


Hy guys

I need to read the COM1 port from de server. Can I do this with PHP. 

Thank´s, Waldemar

--- End Message ---
--- Begin Message ---
Will somebody help me with unsubscribing ?! from this list?! I don't know
why I'm on this list but I can't unsubscribe...I'm trying as they wrote on
the website but I'm receiving reply that my address wasn't on the list!
please..help..

Katherine





----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, March 26, 2003 1:44 PM
Subject: RE: [PHP-WIN] Read COM1


I can't see why this shouldn't work:

$fh = fopen("COM1","rb");

then just treat $fh as a normal filehandle and read as normal.
Jill


-----Original Message-----
From: Waldemar Brand Neto [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 25, 2003 6:47 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Read COM1


Hy guys

I need to read the COM1 port from de server. Can I do this with PHP.

Thank´s, Waldemar

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



--- End Message ---
--- Begin Message --- Hi,
just installed php 4.3.0 and enabled gdlib. Script to upload file (image) and resize it works fine but quality of resized image is bad, bad... Quality is set up to 100.
I checked the same code on other server - pics are good.


What could be a problem? While Installation? Or there is a bug in gd? Or php 4.3.0 doesn't support gd 2.0 well? Any differences between GD for Win or for Linux?

Any ideas?

Afan


--- End Message ---
--- Begin Message ---
Got a hell of a problem.....
 
I just cant seem to get CURL working properly on WinXP, IIS 5.1, PHP
4.3.1, libcurl/7.10.2 OpenSSL/0.9.6g- Running PHP as an ISAPI Plugin,
NTFS Filesystem.
 
I have enabled my extensions folder to be d:\php\extensions in the
PHP.ini
 
the DLL files do in fact exist. I copied everything from d:\php\dlls ->
c:\windows\system32
 
PHP seems to be functioning normally, but I need to use cURL now and it
isn't working.
 
Anyone have any insight on this?
 
Thx-


 
-------------------------------
Matt Babineau
criticalcode.com
e::  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] p::
603.943.4237

 

--- End Message ---
--- Begin Message ---
The following script works fine when I test it at home using localhost on:

MS Win 98
Apache Server
PHP 4.1.1
php_gd.dll

I then publish the script to my web at my ISP's MS IIS server which is the
host and get an undefined function call of:

ImageCreate()

The ISP has said that they have installed php_gd.dll on their server but I
get that error.

I have run php scripts on this site _without_ the gd libraries.

Could somebody please advise how they should be installing the .dll file so
I can utlize the gd_libraries with php?

Many thanks,
Tony Ritter
..............................................................

The script...
<?
$new_w=50;
$new_h=50;

header("Content-type: image/png");
header("Content-type: text/html");
$dst_img=ImageCreate($new_w,$new_h);
$src_img=ImageCreateFromPng("./square.png");

ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I
mageSY($src_img));

ImagePng($dst_img);

echo "This is a square.";
?>




--- End Message ---

Reply via email to