php-general Digest 28 Mar 2005 17:39:08 -0000 Issue 3364

Topics (messages 211687 through 211701):

array sorting
        211687 by: Merlin

Re: file upload
        211688 by: Burhan Khalid

Counting numbers on while..
        211689 by: Louie Miranda
        211690 by: Devraj Mukherjee

Re: So this isnt a bug?
        211691 by: Jochem Maas

Re: world write access
        211692 by: Jochem Maas

Re: Help!
        211693 by: Jason Barnett

Oracle rpm?
        211694 by: D A GERM
        211701 by: Raj Shekhar

failed to open stream?!?
        211695 by: afan.afan.net
        211698 by: Fernando Cosso

Re: Illegal string offset error in array
        211696 by: Johannes Findeisen

Re: failed to open stream?!? - SOLVED!
        211697 by: afan.afan.net

PHP CODE TO DISPLAY ISP
        211699 by: jenny mathew
        211700 by: A. S. Milnes

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 ---
Hi there,

I would like to save some db power by putting values into a file which are often used. They basicly populate a select field.
So I placed those values into associative arrays:
$code[language] = array("1"=> "php", "2"=> "asp");

Now I would like to sort those for displaying after my preference, not by lets say alphabet. The easiest thing I could think of, is just to move the entry:
$code[language] = array("2"=> "asp", "1"=> "php");

But this of course does not work. I would like to be able to place values later on inbetween. So if somebody comes up with a language called ".net" :-) I would like to place it in the middle, but I cant get it to work like that :-(

To build the select box I use following code:

<select name="education">
<option value ="0" selected>---</option>
';
################################################
# build the select field
for ($i=1; $i <= count($code[education]); $i++){
if ($education)
$isselected = ($i == $education) ? " selected" : ""; // select the active row
else
$isselected = FALSE;
printf ("<option value =\"%s\"%s>%s</option>\n", $i, $isselected, $code[education][$i]);
};
################################################
echo'
</select>

Has anybody an idea which could help me on that? Thank you for any help.

Merlin
--- End Message ---
--- Begin Message --- William Stokes wrote:
Okl I can't reverse engineer that...

I just need to know how to set the path.
now I have it like this and it wont work. $fileame comes from a form.

if (copy($filename, "/imagedir/" . $filename_name))
   print "<H2>upload succesful!</H2>";

Don't use copy(), use move_uploaded_file()

See http://www.php.net/manual/en/features.file-upload.php
--- End Message ---
--- Begin Message ---
Hi, im trying to create a number loop on a table where the data came
in a database.

I have tried the for "loop" and counted $countCards_result from the
table where im going to get all the data.

## code ##
while ($profile->fetchInto($row)) {

for ($i = 1; $i <= $countCards_result; $i++) {
$num = $i;

print("
<tr>
<td>$num</td>
<td>" .$row[2]. "</td>
</tr>
");

} // end of for loop
} // end of while
## code ##

Well, it did loop the numbers from what did came out of
$countCards_result but, the results are wrong because it loops each
row from 1 to 10.

Here's the example:

1       louie   edit | delete
2       louie   edit | delete
3       louie   edit | delete
4       louie   edit | delete
5       louie   edit | delete
6       louie   edit | delete
7       louie   edit | delete
8       louie   edit | delete
9       louie   edit | delete
10      louie   edit | delete
1       miranda         edit | delete
2       miranda         edit | delete
3       miranda         edit | delete
4       miranda         edit | delete
5       miranda         edit | delete
6       miranda         edit | delete
7       miranda         edit | delete
8       miranda         edit | delete
9       miranda         edit | delete
10      miranda         edit | delete

And so on..

What i wanted it to do was..

1       louie   edit | delete
2       miranda         edit | delete

And so on..

I was wondering how can i get it to count only the rows, and dont
repeat from 1 to 10 on all rows.

Please help!

--
Louie Miranda
http://www.axishift.com

--- End Message ---
--- Begin Message --- You basically dont need the for loop all you have to do is increment the value of the variable by one each time in the while loop

Devraj

Louie Miranda wrote:
Hi, im trying to create a number loop on a table where the data came
in a database.

I have tried the for "loop" and counted $countCards_result from the
table where im going to get all the data.

## code ##
while ($profile->fetchInto($row)) {

for ($i = 1; $i <= $countCards_result; $i++) {
$num = $i;

print("
<tr>
<td>$num</td>
<td>" .$row[2]. "</td>
</tr>
");

} // end of for loop
} // end of while
## code ##

Well, it did loop the numbers from what did came out of
$countCards_result but, the results are wrong because it loops each
row from 1 to 10.

Here's the example:

1       louie   edit | delete
2       louie   edit | delete
3       louie   edit | delete
4       louie   edit | delete
5       louie   edit | delete
6       louie   edit | delete
7       louie   edit | delete
8       louie   edit | delete
9       louie   edit | delete
10      louie   edit | delete
1       miranda         edit | delete
2       miranda         edit | delete
3       miranda         edit | delete
4       miranda         edit | delete
5       miranda         edit | delete
6       miranda         edit | delete
7       miranda         edit | delete
8       miranda         edit | delete
9       miranda         edit | delete
10      miranda         edit | delete

And so on..

What i wanted it to do was..

1       louie   edit | delete
2       miranda         edit | delete

And so on..

I was wondering how can i get it to count only the rows, and dont
repeat from 1 to 10 on all rows.

Please help!

--
Louie Miranda
http://www.axishift.com



--
Devraj Mukherjee ([EMAIL PROTECTED])
Eternity Technologies Pty. Ltd. ACN 107 600 975
P O Box 5949 Wagga Wagga NSW 2650 Australia
Voice: +61-2-69717131 / Fax: +61-2-69251039
http://www.eternitytechnologies.com/

--- End Message ---
--- Begin Message --- Aaron wrote:
Ive made it clear.

the reproduce code in the bug report references a whole load of functions which are not defined in the reproduce code... meaning the code is useless to everyone but YOU.


If I use the success_box function that uses java to redirect it works

do you really expect people on this list to know what success_box() is/does??

perfectly, but if I use the header command the variables are stripped.

maybe: work around you problems - don't use the header() function in this instance.


This is only when a $_FILE is passed.


Its a guess but.... I wouldn't hold your breath waiting for a proper answer, you'll asphixiate


"A. S. Milnes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]

Aaron wrote:
http://bugs.php.net/bug.php?id=32449
I dont see how its not a bug.

You might find the advice here helpful as well:-

http://www.catb.org/~esr/faqs/smart-questions.html

Alan



--- End Message ---
--- Begin Message --- Evert|Rooftop Solutions wrote:
Thanx Johannes,

how about making the webserver the owner of the files? Would that be a good idea?
The problem is that I have a framework deployed at several clients. Because this are some big clients and demand high security they won't give me a login to their ftp or consoles.

these 'big' clients are rather missing the point aren't they? they trust your code but not you???

Understandable, but everytime there's an update I need to mail the files and they have to install it. Imagine how much time that costs when there's a problem after the update and they need files again. Very annoying.

send them big bills for wasting your time.... and make it known how such bills can be avoided :-)


I consider myself a good php scripter and I will be able to make my scripts secure, so I need a good reason not to build in the auto-updater. I can tell the server is a dedicated server for my project, only has a webserver running (apache).

Argue with me :)

argue with the clients: giving you limited (maybe also time limited) shell access via SSH (using public key encryption to login in) and logging all activity is a lot securer, quick _and_ less error-prone than having you send all your files by email, and definitely more secure than having a webbased update tool running on their server(s).



grt, Evert

Johannes Findeisen wrote:

Hello,

It is generally not a good idea to make scripts to everybody writeable. I think that if you're implementing auto-update features in PHP scripts they only could be insecure. Okay, you have one more feature but what if this feature goes out of control? Be really carefull when writing such applications. Maybe there are nice and secure solutions which maybe work but you really should set a focus on security.

More info:
http://www.php.net/manual/en/function.chmod.php

Regards

hanez




--- End Message ---
--- Begin Message ---
Please read the first link below.

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message --- Is there an rpm to install the oracle compnents for version 4.3.4 php?
--- End Message ---
--- Begin Message ---
D A GERM <[EMAIL PROTECTED]> writes:

> Is there an rpm to install the oracle compnents for version 4.3.4 php?

I don't think so.  The way to do it is to download the SRPM for the
php from your vendor's web site, do a rpm -ivh php-blah.srpm.  This
will give you a spec file in the /usr/src/SOMETHING/SPEC .  Open the
spec file in your editor and add "--with-oci8" to the compile
options. (I think you will find a comment in the spec file which will
tell exactly what options to use to get the oracle support)

After that you need to do a rpmbuild -bb php-blah.spec to get the rpm
that you can then install.

PS : Congratulations on getting Oracle installed on Linux :P

-- 
Raj Shekhar                          Y!   : Operations Engineer
MySQL DBA, programmer and  slacker   Y!IM : lunatech3007
home : http://rajshekhar.net         blog : http://rajshekhar.net/blog/

--- End Message ---
--- Begin Message --- Hi to all.
I'm uploading file and use this
copy($_FILES['NewImage']['tmp_name'], 'temp/'.$item_number.'.jpg') or die (mysql_error());*

*I have this Warning:*
Warning*: copy(temp/05V0115.jpg): failed to open stream: Permission denied in */var/www/html/afan/admin/add_image.php* on line *12
*
chmods:
admin 0755
temp 0777

admin/
|_temp/
|_add_image.php

What could cause this Warning? Can't find a problem.

thanks for any help

-afan
--- End Message ---
--- Begin Message ---
Use move_uploaded_file instead of copy

Hi to all.
I'm uploading file and use this
copy($_FILES['NewImage']['tmp_name'], 'temp/'.$item_number.'.jpg') or die (mysql_error());*

*I have this Warning:*
Warning*: copy(temp/05V0115.jpg): failed to open stream: Permission denied in */var/www/html/afan/admin/add_image.php* on line *12
*
chmods:
admin 0755
temp 0777

admin/
|_temp/
|_add_image.php

What could cause this Warning? Can't find a problem.

thanks for any help

-afan





--- End Message ---
--- Begin Message ---
Hello Jasper and Rasmus,

thanks for reply! I have found out why this does not work. Take a look below.

On Monday 28 March 2005 02:33, Rasmus Lerdorf wrote:
> Jasper Bryant-Greene wrote:
> > Rasmus Lerdorf wrote:
> >>>> Jasper Bryant-Greene wrote:
> >>>>> You can't access string offsets with square brackets [] in PHP5.
> >>>>> You need to use curly braces {} instead.

I have replaced all square brackets with curly braces when using string 
offsets. This didn't helped but worked on PHP4 and 5.

> > Yes, but he's talking about PHP5. He probably has E_STRICT on, which is
> > why he's getting that error.
> >
> > I was telling him to use the correct syntax, which will cause him to not
> > get that error.

I have E_STRICT on but the same behaviour with E_STRICT off

> I know we are talking about PHP5, and that syntax does not throw an
> E_STRICT error.
>

Right!!

Okay, lets see my original function again (copied from first post):

function getNavigationContent($content_path) {
  $i = 0;
  $dir = opendir($content_path);
  while ($file = readdir ($dir))  Â{
    if ($file != "." && $file != ".." && !in_array($file, explode(',', 
$this->arrConf['default_filtered_files']))) {
      $arrAvailableContent[$i] = $file;
      if(is_dir($content_path . $file)) {
        echo $n = 0;
        $subdir = opendir($content_path . $file);
        while ($subfile = readdir ($subdir)) Â{
          if ($subfile != "." && $subfile != "..") {
          
            /*
            Â* This line does not work in PHP5 cause 
off an 
illegal string offset in an array ERROR
            Â*/
            
$arrAvailableContent[$i]['submenu'][$n]['file'] = 
$subfile;
          $n++;
          }
        }
        closedir($subdir);
      }
    $i++;
    }
  }
  closedir($dir);
  return $arrAvailableContent;
}

In the code take a look at the following line:

$arrAvailableContent[$i] = $file;

I am assiging a string to the var $arrAvailableContent[$i] .

Now lets take a look at the line i thought which was wrong:

$arrAvailableContent[$i]['submenu'][$n]['file'] = $subfile;

Now i am assigning a string to $arrAvailableContent[$i]['submenu'][$n]['file'] 
and this is what doesn't work. Now i have var_dump'ed all the arrays and i 
found out, that there are no values in $arrAvailableContent[$i]['submenu']
[$n]['file'] in PHP4. In PHP5 the script exits because of a Fatal Error.  But 
if i set the line:

$arrAvailableContent[$i] = $file;

To:

$arrAvailableContent[$i]['file'] = $file;

Everything works fine in PHP4 and PHP5. 

My function now looks like this:

function getNavigationContent($content_path) {
  $i = 0;
  $dir = opendir($content_path);
  while ($file = readdir ($dir))  Â{
    if ($file != "." && $file != ".." && !in_array($file, explode(',', 
$this->arrConf['default_filtered_files']))) {
      $arrAvailableContent[$i]{'file'} = $file;
      if(is_dir($content_path . $file)) {
        echo $n = 0;
        $subdir = opendir($content_path . $file);
        while ($subfile = readdir ($subdir)) Â{
          if ($subfile != "." && $subfile != "..") {
          
            
$arrAvailableContent[$i]{'submenu'}[$n]{'file'} = 
$subfile;
          $n++;
          }
        }
        closedir($subdir);
      }
    $i++;
    }
  }
  closedir($dir);
  return $arrAvailableContent;
}

This works in PHP4 (4.3.10) and PHP5 (5.0.3)!

Okay, after this my array doesn't look like the application wants it but this 
is because i never had this problem before and it should be fixed at all. I 
can change it quickly in my app since it is designed very clean but i just 
wanted you to know my conclusion.

I have developed many lines of code in PHP4 in the last years but this weekend 
i gave PHP5 a try. I must say i am impressed. PHP4 really is missing some 
features but it is great too. Thanks Rasmus for inventing this scripting 
language. I will become a better PHP programmer just only with the new 
features in PHP5!

Have a nice day!

Regards
-- 
# Johannes Findeisen

--- End Message ---
--- Begin Message --- The problem was that uploaded images already were there and didn't want to overwrite.

-afan


[EMAIL PROTECTED] wrote:

Hi to all.
I'm uploading file and use this
copy($_FILES['NewImage']['tmp_name'], 'temp/'.$item_number.'.jpg') or die (mysql_error());*

*I have this Warning:*
Warning*: copy(temp/05V0115.jpg): failed to open stream: Permission denied in */var/www/html/afan/admin/add_image.php* on line *12
*
chmods:
admin 0755
temp 0777

admin/
|_temp/
|_add_image.php

What could cause this Warning? Can't find a problem.

thanks for any help

-afan


--- End Message ---
--- Begin Message ---
hello to all,
i am making a website in php and i will appreciate if anybody can tell
me the php code to :-
(1)display isp name,
(2) country of the visitor,
(3)operatng system of the visitors.
thanks,
waiting for your reply.
Regards,
Jenny

--- End Message ---
--- Begin Message ---
On Mon, 2005-03-28 at 17:36, jenny mathew wrote:
> hello to all,
> i am making a website in php and i will appreciate if anybody can tell
> me the php code to :-
> (1)display isp name,
> (2) country of the visitor,
> (3)operatng system of the visitors.

Have a look at http://uk2.php.net/reserved.variables.

To get a guess of the country you then need to do a lookup on the IP
address.

Alan 

--- End Message ---

Reply via email to