OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 5 Mar 2008 20:13:06 -0000 Issue 5331

php-general-digest-helplists.php.net
Date: Wed Mar 05 2008 - 14:13:06 CST


php-general Digest 5 Mar 2008 20:13:06 -0000 Issue 5331

Topics (messages 270998 through 271050):

Variable post as array
        270998 by: Pieter du Toit
        270999 by: Pieter du Toit
        271000 by: Angelo Zanetti
        271001 by: Colin Guthrie
        271002 by: Pieter du Toit
        271003 by: Pieter du Toit
        271004 by: Pieter du Toit
        271005 by: Pieter du Toit
        271006 by: Angelo Zanetti
        271007 by: Pieter du Toit
        271008 by: Angelo Zanetti
        271009 by: Colin Guthrie
        271010 by: Colin Guthrie
        271011 by: Pieter du Toit
        271012 by: Colin Guthrie
        271013 by: Pieter du Toit
        271014 by: M. Sokolewicz
        271026 by: Jim Lucas
        271027 by: Zoltán Németh
        271030 by: Daniel Brown

Re: regular expressions question
        271015 by: It Maq
        271016 by: Robert Cummings
        271038 by: Al

Array questions...
        271017 by: Jason Pruim
        271019 by: Jason Pruim
        271020 by: Robert Cummings
        271022 by: Ford, Mike
        271024 by: Jason Pruim
        271025 by: Jason Pruim
        271028 by: Robert Cummings

Re: maintaining [user] state without a session ...
        271018 by: Zoltán Németh
        271021 by: Zoltán Németh
        271023 by: Jason Pruim
        271031 by: tedd
        271032 by: Daniel Brown
        271050 by: Thiago Pojda

Re: validating mysql bound date
        271029 by: Daniel Brown

Re: PHP performance
        271033 by: Thiago Pojda

Preserving URL after redirect?
        271034 by: Skip Evans
        271035 by: Wolf
        271036 by: Richard Heyes
        271037 by: Skip Evans
        271041 by: Ray Hauge
        271043 by: Shawn McKenzie
        271048 by: Skip Evans

Pear Installation Problem - Ubuntu
        271039 by: Stephen
        271040 by: Daniel Brown
        271046 by: Stephen
        271047 by: Wolf

Re: imagettftext and utf-8 (swedish characters)
        271042 by: tedd

Re: Logging session timeout in DB
        271044 by: Daniel Brown

Universaly Accepted Naming Conventions..?
        271045 by: John Papas
        271049 by: Eric Butera

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Hi

I have this weird problem, when i select a file to upload, the variable
arrives as an array at the action php file, this is the code, and the
variable name is txtPhoto

<? include ("userpass.inc"); ?>

<html>

<link rel="STYLESHEET" type="TEXT/CSS" href="specials.css">

<title>Specials Update</title>

</head>

<? include ("body_begin.inc"); ?>

<?

echo "<form ENCTYPE=\"multipart/form-data\" method=\"POST\" name=\"Edit
Special\" action=\"specials_proc.php\">\n";

echo "<input type=\"hidden\" name=\"keyClient_Id\" value=\"$g_client_id\">";

echo "<input type=\"hidden\" name=\"keySpecial\" value=\"$special\">";

echo "<input type=\"hidden\" name=\"k_subsystem_id\"
value=\"$k_subsystem_id\">";

echo "<table align=\"center\" class=\"EditView\" border=\"0\"
cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n";

if ($special != "")

{

$new = 0;

echo "<tr class=\"MainHeader\"><th colspan=\"2\">Edit Special</th></tr>\n";

$result = mysql("zululandcoza", "select * from client_specials where
client_id = $g_client_id and special = $special");

if (list($client_id, $special, $description, $special_type, $price,
$discount, $startdate, $enddate) = mysql_fetch_row($result))

{

}

}

else

{

$new = 1;

echo "<tr class=\"Header\"><th colspan=\"2\"><h1>New Special (this page is
undergoing maintenance, please try again later)</h1></th></tr>\n";

$result = mysql("zululandcoza", "select max(special) from client_specials
where client_id = $client_id");

if (list($max_special) = mysql_fetch_row($result))

{

$special = $max_special + 1;

}

}

echo "<tr class=\"Update\">\n";

echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Number</td>\n";

if ($new)

echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
name=\"txtSpecial\" maxlength=\"5\" size=\"5\"
value=\"$special\"></input></td>\n";

else

echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\"
enabled=\"0\"></input></td>\n";

echo "</tr>\n";

echo "<tr class=\"Update\">\n";

echo " <td align=\"left\" class=\"Prompt\">Description</td>\n";

echo " <td align=\"left\" class=\"Text\"><input type=\"text\"
name=\"txtDescription\" maxlength=\"200\" size=\"50\"
value=\"$description\"></input></td>\n";

echo "</tr>\n";

echo "<tr class=\"Update\">\n";

echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Type</td>\n";

echo " <td align=\"left\" class=\"Selection\">\n";

$optPRICE = "";

$optDISC = "";

$optFROM = "";

if ($special_type == "FROM")

$optFROM = " SELECTED";

elseif ($special_type == "DISC")

$optDISC = " SELECTED";

else

$optPRICE = " SELECTED";

echo " <select name=\"cbxSpecial_Type\">\n";

echo " <option value=\"PRICE\"$optPRICE>Special Price</option>\n";

echo " <option value=\"DISC\"$optDISC>Discount %</option>\n";

echo " <option value=\"FROM\"$optFROM>From</option>\n";

echo " </select>\n";

echo " </td>\n";

echo "</tr>\n";

echo "<tr class=\"Update\">\n";

echo " <td align=\"left\" class=\"Prompt\">Price</td>\n";

echo " <td align=\"left\" class=\"Currency\"><input type=\"text\"
name=\"txtPrice\" maxlength=\"20\" size=\"10\"
value=\"$price\"></input></td>\n";

echo "</tr>\n";

if ($k_subsystem_id == 2)

{

if (! $new)

{

echo "<tr class=\"Update\">\n";

echo " <td align=\"left\" class=\"Prompt\">Current Photo</td>\n";

echo " <td align=\"left\" class=\"Currency\"><img
src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$special\"></td>\n";

echo "</tr>\n";

}

echo "<tr class=\"Update\">\n";

echo " <td align=\"left\" class=\"Prompt\">New Photo</td>\n";

echo " <td align=\"left\" class=\"Currency\"><input type=\"file\"
name=\"txtPhoto\" size=\"50\"></input></td>\n";

echo "</tr>\n";

}

echo "<tr class=\"Footer\">\n";

echo " <td colspan=\"2\">\n";

if ($new)

{

echo " <input type=\"submit\" name=\"cmdAdd\" value=\"Add\">&nbsp;\n";

}

else

{

echo " <input type=\"submit\" name=\"cmdUpdate\" value=\"Update\">&nbsp;\n";

echo " <input type=\"submit\" name=\"cmdDelete\" value=\"Delete\">&nbsp;\n";

}

echo " <input type=\"submit\" name=\"cmdCancel\" value=\"Cancel\">\n";

echo " </td>\n";

echo "</tr>\n";

echo "</table>\n";

echo "</form>\n";

?>

<? include ("body_end.inc"); ?>

</html>

attached mail follows:


Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it tells
me that temp_name is also an array, but when i echo
$_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
vardump i can see that temp name is ["tmp_name"]=> string(14)
"/tmp/phplR1WSl" and not an array by itself.

Im going crazy here

""Pieter du Toit"" <pieterlpwebdesign.co.za> wrote in message
news:E7.13.27925.EDE6EC74pb1.pair.com...
> Hi
>
> I have this weird problem, when i select a file to upload, the variable
> arrives as an array at the action php file, this is the code, and the
> variable name is txtPhoto
>
> <? include ("userpass.inc"); ?>
>
> <html>
>
> <link rel="STYLESHEET" type="TEXT/CSS" href="specials.css">
>
> <title>Specials Update</title>
>
> </head>
>
> <? include ("body_begin.inc"); ?>
>
> <?
>
> echo "<form ENCTYPE=\"multipart/form-data\" method=\"POST\" name=\"Edit
> Special\" action=\"specials_proc.php\">\n";
>
> echo "<input type=\"hidden\" name=\"keyClient_Id\"
> value=\"$g_client_id\">";
>
> echo "<input type=\"hidden\" name=\"keySpecial\" value=\"$special\">";
>
> echo "<input type=\"hidden\" name=\"k_subsystem_id\"
> value=\"$k_subsystem_id\">";
>
> echo "<table align=\"center\" class=\"EditView\" border=\"0\"
> cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n";
>
>
>
> if ($special != "")
>
> {
>
> $new = 0;
>
> echo "<tr class=\"MainHeader\"><th colspan=\"2\">Edit
> Special</th></tr>\n";
>
> $result = mysql("zululandcoza", "select * from client_specials where
> client_id = $g_client_id and special = $special");
>
> if (list($client_id, $special, $description, $special_type, $price,
> $discount, $startdate, $enddate) = mysql_fetch_row($result))
>
> {
>
> }
>
> }
>
> else
>
> {
>
> $new = 1;
>
> echo "<tr class=\"Header\"><th colspan=\"2\"><h1>New Special (this page is
> undergoing maintenance, please try again later)</h1></th></tr>\n";
>
> $result = mysql("zululandcoza", "select max(special) from client_specials
> where client_id = $client_id");
>
> if (list($max_special) = mysql_fetch_row($result))
>
> {
>
> $special = $max_special + 1;
>
> }
>
> }
>
>
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Number</td>\n";
>
> if ($new)
>
> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
> name=\"txtSpecial\" maxlength=\"5\" size=\"5\"
> value=\"$special\"></input></td>\n";
>
> else
>
> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
> name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\"
> enabled=\"0\"></input></td>\n";
>
> echo "</tr>\n";
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Description</td>\n";
>
> echo " <td align=\"left\" class=\"Text\"><input type=\"text\"
> name=\"txtDescription\" maxlength=\"200\" size=\"50\"
> value=\"$description\"></input></td>\n";
>
> echo "</tr>\n";
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Type</td>\n";
>
> echo " <td align=\"left\" class=\"Selection\">\n";
>
> $optPRICE = "";
>
> $optDISC = "";
>
> $optFROM = "";
>
> if ($special_type == "FROM")
>
> $optFROM = " SELECTED";
>
> elseif ($special_type == "DISC")
>
> $optDISC = " SELECTED";
>
> else
>
> $optPRICE = " SELECTED";
>
> echo " <select name=\"cbxSpecial_Type\">\n";
>
> echo " <option value=\"PRICE\"$optPRICE>Special Price</option>\n";
>
> echo " <option value=\"DISC\"$optDISC>Discount %</option>\n";
>
> echo " <option value=\"FROM\"$optFROM>From</option>\n";
>
> echo " </select>\n";
>
> echo " </td>\n";
>
> echo "</tr>\n";
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Price</td>\n";
>
> echo " <td align=\"left\" class=\"Currency\"><input type=\"text\"
> name=\"txtPrice\" maxlength=\"20\" size=\"10\"
> value=\"$price\"></input></td>\n";
>
> echo "</tr>\n";
>
> if ($k_subsystem_id == 2)
>
> {
>
> if (! $new)
>
> {
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Current Photo</td>\n";
>
> echo " <td align=\"left\" class=\"Currency\"><img
> src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$special\"></td>\n";
>
> echo "</tr>\n";
>
> }
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">New Photo</td>\n";
>
> echo " <td align=\"left\" class=\"Currency\"><input type=\"file\"
> name=\"txtPhoto\" size=\"50\"></input></td>\n";
>
> echo "</tr>\n";
>
> }
>
> echo "<tr class=\"Footer\">\n";
>
> echo " <td colspan=\"2\">\n";
>
> if ($new)
>
> {
>
> echo " <input type=\"submit\" name=\"cmdAdd\" value=\"Add\">&nbsp;\n";
>
> }
>
> else
>
> {
>
> echo " <input type=\"submit\" name=\"cmdUpdate\"
> value=\"Update\">&nbsp;\n";
>
> echo " <input type=\"submit\" name=\"cmdDelete\"
> value=\"Delete\">&nbsp;\n";
>
> }
>
> echo " <input type=\"submit\" name=\"cmdCancel\" value=\"Cancel\">\n";
>
> echo " </td>\n";
>
> echo "</tr>\n";
>
> echo "</table>\n";
>
> echo "</form>\n";
>
> ?>
>
>
>
> <? include ("body_end.inc"); ?>
>
> </html>
>
>
>
>
>
>

attached mail follows:


Have you tried print_r($_FILES); to see all the values in the variable?

Its difficult to see whats going on as you posted your whole file.

-----Original Message-----
From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
Sent: 05 March 2008 12:38
To: php-generallists.php.net
Subject: [PHP] Re: Variable post as array

Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it tells
me that temp_name is also an array, but when i echo
$_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
vardump i can see that temp name is ["tmp_name"]=> string(14)
"/tmp/phplR1WSl" and not an array by itself.

Im going crazy here

""Pieter du Toit"" <pieterlpwebdesign.co.za> wrote in message
news:E7.13.27925.EDE6EC74pb1.pair.com...
> Hi
>
> I have this weird problem, when i select a file to upload, the variable
> arrives as an array at the action php file, this is the code, and the
> variable name is txtPhoto
>
> <? include ("userpass.inc"); ?>
>
> <html>
>
> <link rel="STYLESHEET" type="TEXT/CSS" href="specials.css">
>
> <title>Specials Update</title>
>
> </head>
>
> <? include ("body_begin.inc"); ?>
>
> <?
>
> echo "<form ENCTYPE=\"multipart/form-data\" method=\"POST\" name=\"Edit
> Special\" action=\"specials_proc.php\">\n";
>
> echo "<input type=\"hidden\" name=\"keyClient_Id\"
> value=\"$g_client_id\">";
>
> echo "<input type=\"hidden\" name=\"keySpecial\" value=\"$special\">";
>
> echo "<input type=\"hidden\" name=\"k_subsystem_id\"
> value=\"$k_subsystem_id\">";
>
> echo "<table align=\"center\" class=\"EditView\" border=\"0\"
> cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n";
>
>
>
> if ($special != "")
>
> {
>
> $new = 0;
>
> echo "<tr class=\"MainHeader\"><th colspan=\"2\">Edit
> Special</th></tr>\n";
>
> $result = mysql("zululandcoza", "select * from client_specials where
> client_id = $g_client_id and special = $special");
>
> if (list($client_id, $special, $description, $special_type, $price,
> $discount, $startdate, $enddate) = mysql_fetch_row($result))
>
> {
>
> }
>
> }
>
> else
>
> {
>
> $new = 1;
>
> echo "<tr class=\"Header\"><th colspan=\"2\"><h1>New Special (this page is

> undergoing maintenance, please try again later)</h1></th></tr>\n";
>
> $result = mysql("zululandcoza", "select max(special) from client_specials
> where client_id = $client_id");
>
> if (list($max_special) = mysql_fetch_row($result))
>
> {
>
> $special = $max_special + 1;
>
> }
>
> }
>
>
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Number</td>\n";
>
> if ($new)
>
> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
> name=\"txtSpecial\" maxlength=\"5\" size=\"5\"
> value=\"$special\"></input></td>\n";
>
> else
>
> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
> name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\"
> enabled=\"0\"></input></td>\n";
>
> echo "</tr>\n";
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Description</td>\n";
>
> echo " <td align=\"left\" class=\"Text\"><input type=\"text\"
> name=\"txtDescription\" maxlength=\"200\" size=\"50\"
> value=\"$description\"></input></td>\n";
>
> echo "</tr>\n";
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Type</td>\n";
>
> echo " <td align=\"left\" class=\"Selection\">\n";
>
> $optPRICE = "";
>
> $optDISC = "";
>
> $optFROM = "";
>
> if ($special_type == "FROM")
>
> $optFROM = " SELECTED";
>
> elseif ($special_type == "DISC")
>
> $optDISC = " SELECTED";
>
> else
>
> $optPRICE = " SELECTED";
>
> echo " <select name=\"cbxSpecial_Type\">\n";
>
> echo " <option value=\"PRICE\"$optPRICE>Special Price</option>\n";
>
> echo " <option value=\"DISC\"$optDISC>Discount %</option>\n";
>
> echo " <option value=\"FROM\"$optFROM>From</option>\n";
>
> echo " </select>\n";
>
> echo " </td>\n";
>
> echo "</tr>\n";
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Price</td>\n";
>
> echo " <td align=\"left\" class=\"Currency\"><input type=\"text\"
> name=\"txtPrice\" maxlength=\"20\" size=\"10\"
> value=\"$price\"></input></td>\n";
>
> echo "</tr>\n";
>
> if ($k_subsystem_id == 2)
>
> {
>
> if (! $new)
>
> {
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">Current Photo</td>\n";
>
> echo " <td align=\"left\" class=\"Currency\"><img
>
src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$speci
al\"></td>\n";
>
> echo "</tr>\n";
>
> }
>
> echo "<tr class=\"Update\">\n";
>
> echo " <td align=\"left\" class=\"Prompt\">New Photo</td>\n";
>
> echo " <td align=\"left\" class=\"Currency\"><input type=\"file\"
> name=\"txtPhoto\" size=\"50\"></input></td>\n";
>
> echo "</tr>\n";
>
> }
>
> echo "<tr class=\"Footer\">\n";
>
> echo " <td colspan=\"2\">\n";
>
> if ($new)
>
> {
>
> echo " <input type=\"submit\" name=\"cmdAdd\" value=\"Add\">&nbsp;\n";
>
> }
>
> else
>
> {
>
> echo " <input type=\"submit\" name=\"cmdUpdate\"
> value=\"Update\">&nbsp;\n";
>
> echo " <input type=\"submit\" name=\"cmdDelete\"
> value=\"Delete\">&nbsp;\n";
>
> }
>
> echo " <input type=\"submit\" name=\"cmdCancel\" value=\"Cancel\">\n";
>
> echo " </td>\n";
>
> echo "</tr>\n";
>
> echo "</table>\n";
>
> echo "</form>\n";
>
> ?>
>
>
>
> <? include ("body_end.inc"); ?>
>
> </html>
>
>
>
>
>
>

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

attached mail follows:


Pieter du Toit wrote:
> Hi
>
> I have this weird problem, when i select a file to upload, the variable
> arrives as an array at the action php file, this is the code, and the
> variable name is txtPhoto

I'd give a shorter example. People don't want to read through all your
code..

Also you shoudl post some sort of indication of what you are trying to
do to get the results you describe... just saying "the variable arrives
as an array" and we don't really know how you are accessing "the variable".

A short example and expected/actual behaviour listing is good :)

Col

attached mail follows:


I ran it, and here is the output

Array ( [txtPhoto] => Array ( [name] => g1.jpg [type] => image/pjpeg
[tmp_name] => /tmp/php3qkA4A [error] => 0 [size] => 17008 ) )

""Angelo Zanetti"" <angeloelemental.co.za> wrote in message
news:20080305110542.67D9E3DD6ctb-mesg5.saix.net...
> Have you tried print_r($_FILES); to see all the values in the variable?
>
> Its difficult to see whats going on as you posted your whole file.
>
>
>
> -----Original Message-----
> From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
> Sent: 05 March 2008 12:38
> To: php-generallists.php.net
> Subject: [PHP] Re: Variable post as array
>
> Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it
> tells
> me that temp_name is also an array, but when i echo
> $_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
> vardump i can see that temp name is ["tmp_name"]=> string(14)
> "/tmp/phplR1WSl" and not an array by itself.
>
> Im going crazy here
>
> ""Pieter du Toit"" <pieterlpwebdesign.co.za> wrote in message
> news:E7.13.27925.EDE6EC74pb1.pair.com...
>> Hi
>>
>> I have this weird problem, when i select a file to upload, the variable
>> arrives as an array at the action php file, this is the code, and the
>> variable name is txtPhoto
>>
>> <? include ("userpass.inc"); ?>
>>
>> <html>
>>
>> <link rel="STYLESHEET" type="TEXT/CSS" href="specials.css">
>>
>> <title>Specials Update</title>
>>
>> </head>
>>
>> <? include ("body_begin.inc"); ?>
>>
>> <?
>>
>> echo "<form ENCTYPE=\"multipart/form-data\" method=\"POST\" name=\"Edit
>> Special\" action=\"specials_proc.php\">\n";
>>
>> echo "<input type=\"hidden\" name=\"keyClient_Id\"
>> value=\"$g_client_id\">";
>>
>> echo "<input type=\"hidden\" name=\"keySpecial\" value=\"$special\">";
>>
>> echo "<input type=\"hidden\" name=\"k_subsystem_id\"
>> value=\"$k_subsystem_id\">";
>>
>> echo "<table align=\"center\" class=\"EditView\" border=\"0\"
>> cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n";
>>
>>
>>
>> if ($special != "")
>>
>> {
>>
>> $new = 0;
>>
>> echo "<tr class=\"MainHeader\"><th colspan=\"2\">Edit
>> Special</th></tr>\n";
>>
>> $result = mysql("zululandcoza", "select * from client_specials where
>> client_id = $g_client_id and special = $special");
>>
>> if (list($client_id, $special, $description, $special_type, $price,
>> $discount, $startdate, $enddate) = mysql_fetch_row($result))
>>
>> {
>>
>> }
>>
>> }
>>
>> else
>>
>> {
>>
>> $new = 1;
>>
>> echo "<tr class=\"Header\"><th colspan=\"2\"><h1>New Special (this page
>> is
>
>> undergoing maintenance, please try again later)</h1></th></tr>\n";
>>
>> $result = mysql("zululandcoza", "select max(special) from client_specials
>> where client_id = $client_id");
>>
>> if (list($max_special) = mysql_fetch_row($result))
>>
>> {
>>
>> $special = $max_special + 1;
>>
>> }
>>
>> }
>>
>>
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Number</td>\n";
>>
>> if ($new)
>>
>> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
>> name=\"txtSpecial\" maxlength=\"5\" size=\"5\"
>> value=\"$special\"></input></td>\n";
>>
>> else
>>
>> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
>> name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\"
>> enabled=\"0\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Description</td>\n";
>>
>> echo " <td align=\"left\" class=\"Text\"><input type=\"text\"
>> name=\"txtDescription\" maxlength=\"200\" size=\"50\"
>> value=\"$description\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Type</td>\n";
>>
>> echo " <td align=\"left\" class=\"Selection\">\n";
>>
>> $optPRICE = "";
>>
>> $optDISC = "";
>>
>> $optFROM = "";
>>
>> if ($special_type == "FROM")
>>
>> $optFROM = " SELECTED";
>>
>> elseif ($special_type == "DISC")
>>
>> $optDISC = " SELECTED";
>>
>> else
>>
>> $optPRICE = " SELECTED";
>>
>> echo " <select name=\"cbxSpecial_Type\">\n";
>>
>> echo " <option value=\"PRICE\"$optPRICE>Special Price</option>\n";
>>
>> echo " <option value=\"DISC\"$optDISC>Discount %</option>\n";
>>
>> echo " <option value=\"FROM\"$optFROM>From</option>\n";
>>
>> echo " </select>\n";
>>
>> echo " </td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Price</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><input type=\"text\"
>> name=\"txtPrice\" maxlength=\"20\" size=\"10\"
>> value=\"$price\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> if ($k_subsystem_id == 2)
>>
>> {
>>
>> if (! $new)
>>
>> {
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Current Photo</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><img
>>
> src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$speci
> al\"></td>\n";
>>
>> echo "</tr>\n";
>>
>> }
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">New Photo</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><input type=\"file\"
>> name=\"txtPhoto\" size=\"50\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> }
>>
>> echo "<tr class=\"Footer\">\n";
>>
>> echo " <td colspan=\"2\">\n";
>>
>> if ($new)
>>
>> {
>>
>> echo " <input type=\"submit\" name=\"cmdAdd\" value=\"Add\">&nbsp;\n";
>>
>> }
>>
>> else
>>
>> {
>>
>> echo " <input type=\"submit\" name=\"cmdUpdate\"
>> value=\"Update\">&nbsp;\n";
>>
>> echo " <input type=\"submit\" name=\"cmdDelete\"
>> value=\"Delete\">&nbsp;\n";
>>
>> }
>>
>> echo " <input type=\"submit\" name=\"cmdCancel\" value=\"Cancel\">\n";
>>
>> echo " </td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "</table>\n";
>>
>> echo "</form>\n";
>>
>> ?>
>>
>>
>>
>> <? include ("body_end.inc"); ?>
>>
>> </html>
>>
>>
>>
>>
>>
>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


I ran a print_r on it and this is the results

Array ( [txtPhoto] => Array ( [name] => g1.jpg [type] => image/pjpeg
[tmp_name] => /tmp/php3qkA4A [error] => 0 [size] => 17008 ) )

The image received here must be inserted into a database as binary it looks
like it.
"Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
news:fqlupu$mm7$1ger.gmane.org...
> Pieter du Toit wrote:
>> Hi
>>
>> I have this weird problem, when i select a file to upload, the variable
>> arrives as an array at the action php file, this is the code, and the
>> variable name is txtPhoto
>
> I'd give a shorter example. People don't want to read through all your
> code..
>
> Also you shoudl post some sort of indication of what you are trying to
> do to get the results you describe... just saying "the variable arrives
> as an array" and we don't really know how you are accessing "the
> variable".
>
> A short example and expected/actual behaviour listing is good :)
>
> Col
>

attached mail follows:


This is my problem

Warning: fopen() expects parameter 1 to be string, array given in
/usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

"Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
news:fqlupu$mm7$1ger.gmane.org...
> Pieter du Toit wrote:
>> Hi
>>
>> I have this weird problem, when i select a file to upload, the variable
>> arrives as an array at the action php file, this is the code, and the
>> variable name is txtPhoto
>
> I'd give a shorter example. People don't want to read through all your
> code..
>
> Also you shoudl post some sort of indication of what you are trying to
> do to get the results you describe... just saying "the variable arrives
> as an array" and we don't really know how you are accessing "the
> variable".
>
> A short example and expected/actual behaviour listing is good :)
>
> Col
>

attached mail follows:


This is my problem

Warning: fopen() expects parameter 1 to be string, array given in
/usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

""Angelo Zanetti"" <angeloelemental.co.za> wrote in message
news:20080305110542.67D9E3DD6ctb-mesg5.saix.net...
> Have you tried print_r($_FILES); to see all the values in the variable?
>
> Its difficult to see whats going on as you posted your whole file.
>
>
>
> -----Original Message-----
> From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
> Sent: 05 March 2008 12:38
> To: php-generallists.php.net
> Subject: [PHP] Re: Variable post as array
>
> Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it
> tells
> me that temp_name is also an array, but when i echo
> $_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
> vardump i can see that temp name is ["tmp_name"]=> string(14)
> "/tmp/phplR1WSl" and not an array by itself.
>
> Im going crazy here
>
> ""Pieter du Toit"" <pieterlpwebdesign.co.za> wrote in message
> news:E7.13.27925.EDE6EC74pb1.pair.com...
>> Hi
>>
>> I have this weird problem, when i select a file to upload, the variable
>> arrives as an array at the action php file, this is the code, and the
>> variable name is txtPhoto
>>
>> <? include ("userpass.inc"); ?>
>>
>> <html>
>>
>> <link rel="STYLESHEET" type="TEXT/CSS" href="specials.css">
>>
>> <title>Specials Update</title>
>>
>> </head>
>>
>> <? include ("body_begin.inc"); ?>
>>
>> <?
>>
>> echo "<form ENCTYPE=\"multipart/form-data\" method=\"POST\" name=\"Edit
>> Special\" action=\"specials_proc.php\">\n";
>>
>> echo "<input type=\"hidden\" name=\"keyClient_Id\"
>> value=\"$g_client_id\">";
>>
>> echo "<input type=\"hidden\" name=\"keySpecial\" value=\"$special\">";
>>
>> echo "<input type=\"hidden\" name=\"k_subsystem_id\"
>> value=\"$k_subsystem_id\">";
>>
>> echo "<table align=\"center\" class=\"EditView\" border=\"0\"
>> cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n";
>>
>>
>>
>> if ($special != "")
>>
>> {
>>
>> $new = 0;
>>
>> echo "<tr class=\"MainHeader\"><th colspan=\"2\">Edit
>> Special</th></tr>\n";
>>
>> $result = mysql("zululandcoza", "select * from client_specials where
>> client_id = $g_client_id and special = $special");
>>
>> if (list($client_id, $special, $description, $special_type, $price,
>> $discount, $startdate, $enddate) = mysql_fetch_row($result))
>>
>> {
>>
>> }
>>
>> }
>>
>> else
>>
>> {
>>
>> $new = 1;
>>
>> echo "<tr class=\"Header\"><th colspan=\"2\"><h1>New Special (this page
>> is
>
>> undergoing maintenance, please try again later)</h1></th></tr>\n";
>>
>> $result = mysql("zululandcoza", "select max(special) from client_specials
>> where client_id = $client_id");
>>
>> if (list($max_special) = mysql_fetch_row($result))
>>
>> {
>>
>> $special = $max_special + 1;
>>
>> }
>>
>> }
>>
>>
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Number</td>\n";
>>
>> if ($new)
>>
>> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
>> name=\"txtSpecial\" maxlength=\"5\" size=\"5\"
>> value=\"$special\"></input></td>\n";
>>
>> else
>>
>> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
>> name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\"
>> enabled=\"0\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Description</td>\n";
>>
>> echo " <td align=\"left\" class=\"Text\"><input type=\"text\"
>> name=\"txtDescription\" maxlength=\"200\" size=\"50\"
>> value=\"$description\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Special&nbsp;Type</td>\n";
>>
>> echo " <td align=\"left\" class=\"Selection\">\n";
>>
>> $optPRICE = "";
>>
>> $optDISC = "";
>>
>> $optFROM = "";
>>
>> if ($special_type == "FROM")
>>
>> $optFROM = " SELECTED";
>>
>> elseif ($special_type == "DISC")
>>
>> $optDISC = " SELECTED";
>>
>> else
>>
>> $optPRICE = " SELECTED";
>>
>> echo " <select name=\"cbxSpecial_Type\">\n";
>>
>> echo " <option value=\"PRICE\"$optPRICE>Special Price</option>\n";
>>
>> echo " <option value=\"DISC\"$optDISC>Discount %</option>\n";
>>
>> echo " <option value=\"FROM\"$optFROM>From</option>\n";
>>
>> echo " </select>\n";
>>
>> echo " </td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Price</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><input type=\"text\"
>> name=\"txtPrice\" maxlength=\"20\" size=\"10\"
>> value=\"$price\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> if ($k_subsystem_id == 2)
>>
>> {
>>
>> if (! $new)
>>
>> {
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Current Photo</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><img
>>
> src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$speci
> al\"></td>\n";
>>
>> echo "</tr>\n";
>>
>> }
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">New Photo</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><input type=\"file\"
>> name=\"txtPhoto\" size=\"50\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> }
>>
>> echo "<tr class=\"Footer\">\n";
>>
>> echo " <td colspan=\"2\">\n";
>>
>> if ($new)
>>
>> {
>>
>> echo " <input type=\"submit\" name=\"cmdAdd\" value=\"Add\">&nbsp;\n";
>>
>> }
>>
>> else
>>
>> {
>>
>> echo " <input type=\"submit\" name=\"cmdUpdate\"
>> value=\"Update\">&nbsp;\n";
>>
>> echo " <input type=\"submit\" name=\"cmdDelete\"
>> value=\"Delete\">&nbsp;\n";
>>
>> }
>>
>> echo " <input type=\"submit\" name=\"cmdCancel\" value=\"Cancel\">\n";
>>
>> echo " </td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "</table>\n";
>>
>> echo "</form>\n";
>>
>> ?>
>>
>>
>>
>> <? include ("body_end.inc"); ?>
>>
>> </html>
>>
>>
>>
>>
>>
>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


What is on line 49?

What variable are you passing as the parameter?

-----Original Message-----
From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
Sent: 05 March 2008 13:36
To: php-generallists.php.net
Subject: [PHP] Re: Variable post as array

This is my problem

Warning: fopen() expects parameter 1 to be string, array given in
/usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

"Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
news:fqlupu$mm7$1ger.gmane.org...
> Pieter du Toit wrote:
>> Hi
>>
>> I have this weird problem, when i select a file to upload, the variable
>> arrives as an array at the action php file, this is the code, and the
>> variable name is txtPhoto
>
> I'd give a shorter example. People don't want to read through all your
> code..
>
> Also you shoudl post some sort of indication of what you are trying to
> do to get the results you describe... just saying "the variable arrives
> as an array" and we don't really know how you are accessing "the
> variable".
>
> A short example and expected/actual behaviour listing is good :)
>
> Col
>

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

attached mail follows:


This is line 49

$txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
filesize($txtPhoto)));

the $txtPhoto is the parameter

""Angelo Zanetti"" <angeloelemental.co.za> wrote in message
news:20080305113934.591FBD019ctb-mesg-1-3.saix.net...
> What is on line 49?
>
> What variable are you passing as the parameter?
>
>
>
> -----Original Message-----
> From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
> Sent: 05 March 2008 13:36
> To: php-generallists.php.net
> Subject: [PHP] Re: Variable post as array
>
> This is my problem
>
> Warning: fopen() expects parameter 1 to be string, array given in
> /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49
>
> "Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
> news:fqlupu$mm7$1ger.gmane.org...
>> Pieter du Toit wrote:
>>> Hi
>>>
>>> I have this weird problem, when i select a file to upload, the variable
>>> arrives as an array at the action php file, this is the code, and the
>>> variable name is txtPhoto
>>
>> I'd give a shorter example. People don't want to read through all your
>> code..
>>
>> Also you shoudl post some sort of indication of what you are trying to
>> do to get the results you describe... just saying "the variable arrives
>> as an array" and we don't really know how you are accessing "the
>> variable".
>>
>> A short example and expected/actual behaviour listing is good :)
>>
>> Col
>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Well check what the value is. I think you must do more testing yourself
instead of just posting here because then you will not learn and also if you
trouble shoot it yourself it will allow you to fix errors in the future.

-----Original Message-----
From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
Sent: 05 March 2008 13:43
To: php-generallists.php.net
Subject: Re: [PHP] Re: Variable post as array

This is line 49

$txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
filesize($txtPhoto)));

the $txtPhoto is the parameter

""Angelo Zanetti"" <angeloelemental.co.za> wrote in message
news:20080305113934.591FBD019ctb-mesg-1-3.saix.net...
> What is on line 49?
>
> What variable are you passing as the parameter?
>
>
>
> -----Original Message-----
> From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
> Sent: 05 March 2008 13:36
> To: php-generallists.php.net
> Subject: [PHP] Re: Variable post as array
>
> This is my problem
>
> Warning: fopen() expects parameter 1 to be string, array given in
> /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49
>
> "Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
> news:fqlupu$mm7$1ger.gmane.org...
>> Pieter du Toit wrote:
>>> Hi
>>>
>>> I have this weird problem, when i select a file to upload, the variable
>>> arrives as an array at the action php file, this is the code, and the
>>> variable name is txtPhoto
>>
>> I'd give a shorter example. People don't want to read through all your
>> code..
>>
>> Also you shoudl post some sort of indication of what you are trying to
>> do to get the results you describe... just saying "the variable arrives
>> as an array" and we don't really know how you are accessing "the
>> variable".
>>
>> A short example and expected/actual behaviour listing is good :)
>>
>> Col
>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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

attached mail follows:


Pieter du Toit wrote:
> I ran a print_r on it and this is the results
>
> Array ( [txtPhoto] => Array ( [name] => g1.jpg [type] => image/pjpeg
> [tmp_name] => /tmp/php3qkA4A [error] => 0 [size] => 17008 ) )
>
> The image received here must be inserted into a database as binary it looks
> like it.

"on it" is very vague dude. Be more specific... show code!!!

From later posts it appears you are using register_globals to access the
file as if it is a local variable.

$txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
filesize($txtPhoto)));

For file upload elements $txtPhoto will be an array. use
$txtPhoto['tmp_name'] or something. It's all in the manual.

PS just avoid register globals anyway, it's evil.

Col

attached mail follows:


Pieter du Toit wrote:
> This is my problem
>
> Warning: fopen() expects parameter 1 to be string, array given in
> /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

Dude, just as a general observation, when you are asking for help, don't
just describe what you do, post the code. But don't post full files,
just post what's absolutely needed.

In this case you don't understand how file uploads work. Just read the
PHP manual and you'll see what needs to be done.

http://uk.php.net/manual/en/features.file-upload.php

Col

attached mail follows:


That is the problem, i can see the name of the file with $txtPhoto['name']
but when i use the same with temp_name, i get nothing, one weird thing is
this [error] => 0 [size] => 17008 , what is that?

this is the code that is giving the problem
$txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
filesize($txtPhoto)));

And this is the error

Warning: fopen() expects parameter 1 to be string, array given in
> /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49

I did not do the code im just trying to help out, if never use this kind of
code to work with photos, i normally use move_uploaded_file and put the path
in the databse, but it look like this code puts the photo in the database as
binary or something.

"Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
news:fqm3de$6k1$1ger.gmane.org...
> Pieter du Toit wrote:
>> I ran a print_r on it and this is the results
>>
>> Array ( [txtPhoto] => Array ( [name] => g1.jpg [type] => image/pjpeg
>> [tmp_name] => /tmp/php3qkA4A [error] => 0 [size] => 17008 ) )
>>
>> The image received here must be inserted into a database as binary it
>> looks
>> like it.
>
> "on it" is very vague dude. Be more specific... show code!!!
>
> From later posts it appears you are using register_globals to access the
> file as if it is a local variable.
>
> $txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
> filesize($txtPhoto)));
>
> For file upload elements $txtPhoto will be an array. use
> $txtPhoto['tmp_name'] or something. It's all in the manual.
>
> PS just avoid register globals anyway, it's evil.
>
> Col
>

attached mail follows:


Pieter du Toit wrote:
> That is the problem, i can see the name of the file with $txtPhoto['name']
> but when i use the same with temp_name, i get nothing, one weird thing is
> this [error] => 0 [size] => 17008 , what is that?
>
> this is the code that is giving the problem
> $txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
> filesize($txtPhoto)));
>
> And this is the error
>
> Warning: fopen() expects parameter 1 to be string, array given in
>> /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49
>
> I did not do the code im just trying to help out, if never use this kind of
> code to work with photos, i normally use move_uploaded_file and put the path
> in the databse, but it look like this code puts the photo in the database as
> binary or something.

OK, I'll try and spell it out seeing as the link to the PHP Manual
didn't take ;)

The variable $txtPhoto exists because you have register global option set.

It will be the same value as $_FILES['txtPhoto'].

This variable *is an array*. It is not meant to contain just a filename.

Your fopen() statement assumes that this variable *is a string* and this
is fundamentally wrong.

The PHP Manula page cannot be more clear about what the various elements
in this array mean:

http://uk.php.net/manual/en/features.file-upload.php
(here their element is called 'userfile', yours is called 'txtPhoto'.

$_FILES['userfile']['name']
    The original name of the file on the client machine.

$_FILES['userfile']['type']
    The mime type of the file, if the browser provided this information.
An example would be "image/gif". This mime type is however not checked
on the PHP side and therefore don't take its value for granted.

$_FILES['userfile']['size']
    The size, in bytes, of the uploaded file.

$_FILES['userfile']['tmp_name']
    The temporary filename of the file in which the uploaded file was
stored on the server.

$_FILES['userfile']['error']
    The error code associated with this file upload. This element was
added in PHP 4.2.0

The ['name'] is the original name of the file the person uploaded. Your
code tries to load the contents of the file into a variable. To do this,
this simplest way is to do:

$photoData = file_get_contents($_FILES['txtPhoto']['tmp_name']);

Your code calls addslashes() on it but that's pretty braindead as it's
binary data. If it's going into a database you'd be better formatting it
using a database formatting function (e.g. mysql_real_escape_string) and
not just relying on an ad-hoc method.

HTHs

Col

attached mail follows:


Thanks Colin this will help me, like i said im just trying to help its not
my code and i dont work with photos like this, but i Do appreciate your
patience with me.
"Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
news:fqm88a$q4n$1ger.gmane.org...
> Pieter du Toit wrote:
>> That is the problem, i can see the name of the file with
>> $txtPhoto['name']
>> but when i use the same with temp_name, i get nothing, one weird thing is
>> this [error] => 0 [size] => 17008 , what is that?
>>
>> this is the code that is giving the problem
>> $txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
>> filesize($txtPhoto)));
>>
>> And this is the error
>>
>> Warning: fopen() expects parameter 1 to be string, array given in
>>> /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line
>>> 49
>>
>> I did not do the code im just trying to help out, if never use this kind
>> of
>> code to work with photos, i normally use move_uploaded_file and put the
>> path
>> in the databse, but it look like this code puts the photo in the database
>> as
>> binary or something.
>
> OK, I'll try and spell it out seeing as the link to the PHP Manual
> didn't take ;)
>
> The variable $txtPhoto exists because you have register global option set.
>
> It will be the same value as $_FILES['txtPhoto'].
>
> This variable *is an array*. It is not meant to contain just a filename.
>
> Your fopen() statement assumes that this variable *is a string* and this
> is fundamentally wrong.
>
> The PHP Manula page cannot be more clear about what the various elements
> in this array mean:
>
> http://uk.php.net/manual/en/features.file-upload.php
> (here their element is called 'userfile', yours is called 'txtPhoto'.
>
>
> $_FILES['userfile']['name']
> The original name of the file on the client machine.
>
> $_FILES['userfile']['type']
> The mime type of the file, if the browser provided this information.
> An example would be "image/gif". This mime type is however not checked
> on the PHP side and therefore don't take its value for granted.
>
> $_FILES['userfile']['size']
> The size, in bytes, of the uploaded file.
>
> $_FILES['userfile']['tmp_name']
> The temporary filename of the file in which the uploaded file was
> stored on the server.
>
> $_FILES['userfile']['error']
> The error code associated with this file upload. This element was
> added in PHP 4.2.0
>
>
>
> The ['name'] is the original name of the file the person uploaded. Your
> code tries to load the contents of the file into a variable. To do this,
> this simplest way is to do:
>
> $photoData = file_get_contents($_FILES['txtPhoto']['tmp_name']);
>
> Your code calls addslashes() on it but that's pretty braindead as it's
> binary data. If it's going into a database you'd be better formatting it
> using a database formatting function (e.g. mysql_real_escape_string) and
> not just relying on an ad-hoc method.
>
> HTHs
>
> Col
>
>
>
>
>
>

attached mail follows:


And you don't do:

$txtPhotoData = addslashes(fread(fopen($_FILES['txtPhoto']['tmp_name'],
"r"), filesize($_FILES['txtPhoto']['tmp_name'])));

because.... ?

- Tul

P.S. if you want more readable code (PHP >= 4.3.0, which you should have
anyway) use:
$txtPhotoData = file_get_contents($_FILES['txtPhoto']['tmp_name']);

Pieter du Toit wrote:
> This is line 49
>
> $txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
> filesize($txtPhoto)));
>
> the $txtPhoto is the parameter
>
> ""Angelo Zanetti"" <angeloelemental.co.za> wrote in message
> news:20080305113934.591FBD019ctb-mesg-1-3.saix.net...
>> What is on line 49?
>>
>> What variable are you passing as the parameter?
>>
>>
>>
>> -----Original Message-----
>> From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
>> Sent: 05 March 2008 13:36
>> To: php-generallists.php.net
>> Subject: [PHP] Re: Variable post as array
>>
>> This is my problem
>>
>> Warning: fopen() expects parameter 1 to be string, array given in
>> /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49
>>
>> "Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
>> news:fqlupu$mm7$1ger.gmane.org...
>>> Pieter du Toit wrote:
>>>> Hi
>>>>
>>>> I have this weird problem, when i select a file to upload, the variable
>>>> arrives as an array at the action php file, this is the code, and the
>>>> variable name is txtPhoto
>>> I'd give a shorter example. People don't want to read through all your
>>> code..
>>>
>>> Also you shoudl post some sort of indication of what you are trying to
>>> do to get the results you describe... just saying "the variable arrives
>>> as an array" and we don't really know how you are accessing "the
>>> variable".
>>>
>>> A short example and expected/actual behaviour listing is good :)
>>>
>>> Col
>>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>

attached mail follows:


Pieter du Toit wrote:
> Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it tells

The above reference is wrong. 'temp_name' should be 'tmp_name'

> me that temp_name is also an array, but when i echo
> $_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
> vardump i can see that temp name is ["tmp_name"]=> string(14)
> "/tmp/phplR1WSl" and not an array by itself.

So, like I said before. Use the right key name, and all will be one with your
universe.

>
> Im going crazy here

That question is best answered by a professional

>

--
Jim Lucas

    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
     by William Shakespeare

attached mail follows:


2008. 03. 5, szerda keltezéssel 13.42-kor Pieter du Toit ezt írta:
> This is line 49
>
> $txtPhotoData = addslashes(fread(fopen($txtPhoto, "r"),
> filesize($txtPhoto)));

add this before:
$txtPhoto = $_FILES['txtPhoto']['tmp_name'];

and don't use addslashes but rather mysql_real_escape_string or whatever
suits your database most

greets,
Zoltán Németh

>
> the $txtPhoto is the parameter
>
> ""Angelo Zanetti"" <angeloelemental.co.za> wrote in message
> news:20080305113934.591FBD019ctb-mesg-1-3.saix.net...
> > What is on line 49?
> >
> > What variable are you passing as the parameter?
> >
> >
> >
> > -----Original Message-----
> > From: Pieter du Toit [mailto:pieterlpwebdesign.co.za]
> > Sent: 05 March 2008 13:36
> > To: php-generallists.php.net
> > Subject: [PHP] Re: Variable post as array
> >
> > This is my problem
> >
> > Warning: fopen() expects parameter 1 to be string, array given in
> > /usr/www/users/zululr/marketplace/myzululand/specials_proc.php on line 49
> >
> > "Colin Guthrie" <gmanecolin.guthr.ie> wrote in message
> > news:fqlupu$mm7$1ger.gmane.org...
> >> Pieter du Toit wrote:
> >>> Hi
> >>>
> >>> I have this weird problem, when i select a file to upload, the variable
> >>> arrives as an array at the action php file, this is the code, and the
> >>> variable name is txtPhoto
> >>
> >> I'd give a shorter example. People don't want to read through all your
> >> code..
> >>
> >> Also you shoudl post some sort of indication of what you are trying to
> >> do to get the results you describe... just saying "the variable arrives
> >> as an array" and we don't really know how you are accessing "the
> >> variable".
> >>
> >> A short example and expected/actual behaviour listing is good :)
> >>
> >> Col
> >>
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>

attached mail follows:


On Wed, Mar 5, 2008 at 4:58 AM, Pieter du Toit <pieterlpwebdesign.co.za> wrote:

    And unless you have your (Apache|IIS|etc.) web server set to
disable direct-access and/or web serving of *.inc files, you should
change these to *.php or *.inc.php files ASAP. Especially the first. <