Re: [PHP] Arrays

2005-07-12 Thread Justin Gruenberg
On 12/07/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,
 
 How can i destroy an array?
 I mean i have a loop and for each new value in the loop i want to destroy the 
 array. Something like that:
 
  while($row = mysql_fetch_array($result))
   {
 
   $product[] = $product_id;
 
  // some code here
 
  }
 
 I've tried this but doesn't work
 
  while($row = mysql_fetch_array($result))
   {
 
   $product = array();
 
   $product[] = $product_id;
 
  // some code here
 
  }


To destroy an array? 

First of all, where does $product_id come from?  You gave us no code
that gives us that.

Second, if you're trying to make an array populated with a feild from
each row returned, your first example will work, but not the second. 
The second example will empty the array, and start a new one (which
doesn't make sense to me why you would do that--because in the end,
you're only going to have the array with the last row returned).

But if you're trying to destroy an array doing either:
unset($an_array)
or $an_array = array();
will do the job.

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



Re: [PHP] what am I missing..interpolation?

2005-05-15 Thread Justin Gruenberg
On 15/05/05, blackwater dev [EMAIL PROTECTED] wrote:
 Hello,
 
 this works fine:
 
 $name=fido;
 $string=my dog's name is $name;
 echo $string;//prints my dog's name is fido
 
 but when I store the string my dog's name is $name in the db and pull it 
 out:
 
 //do the query
 $row=$datab-fetch();
 $name=fido;
 $string=$name['db_column'];
 echo $string//prints my dog's name is $name
 
 How can I get it to work with the db?

Not exactly sure if this will work, but try

echo eval($string)

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



Re: [PHP] radio buttons in $_POST

2005-04-23 Thread Justin Gruenberg
 None input type=radio checked name=radio_test  value=None /

And if you didn't want it to show to the user (because they have to
make a choice anyway) . . . you can use this css:

input[value=None]
{
display: none;
}

You should then always have a value to play with in PHP, and the user
doesn't see any extra clutter.

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



Re: [PHP] image handling

2005-04-16 Thread Justin Gruenberg
On 4/16/05, Dasmeet Singh [EMAIL PROTECTED] wrote:
 I have a form on my website that allows users to upload photographs..
 
 1. How to find out the file type they are uploading..like jpeg or png or
 gif?
 
 2. Also is there any way to find out size and resolution of the image?

http://us3.php.net/manual/en/function.getimagesize.php

You can use getimagesize to get the size and type of the image as well
as some other information possibly usefull information.

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



Re: [PHP] (noob) listing folder content

2005-04-03 Thread Justin Gruenberg
On Apr 3, 2005 3:32 PM, p80 [EMAIL PROTECTED] wrote:
 I have a folder let's call it /rep and would like to list all files in it
 and for each file $f I would like to check if $f == $some_value and if it
 does echo $f any idea how to do that?
 
 thanx in advance
 
 Pat

See the directory functions:
http://us4.php.net/manual/en/ref.dir.php

See the examples for readdir, which is going to be very similar to
what you're trying to do.
http://us4.php.net/manual/en/function.readdir.php

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



Re: [PHP] Changing numbers

2003-07-21 Thread justin gruenberg
Curt Zirzow wrote:

* Thus wrote zavaboy ([EMAIL PROTECTED]):
 

I have the following numbers:

12.400
666.75
23
369.2
3.234
How can I make them have at least 2 decimal places?
So, they will output:
12.40
666.75
23.00
269.20
3.234
Thanks in advance!

What I dont understand is that your examples are not consitant.  You 
want 2 or more decimal positions, so as if there are more than 2, to 
leave what exists.  But your first example, you truncate the last 0.  Is 
that a typo, or intentional?

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


[PHP] Re: [PHP-DB] How to get PHP to download web contents

2003-07-03 Thread justin gruenberg
Steve B. wrote:

How would you get PHP to download a file such as a web page and put it in a string?

What keywords would relate to this (besides php download)

I need a user to be able to put in a name and pass and have PHP go to a cetain site.
The site can take the user/pass in the url so I do not need a form submit.
Then I need the site contents to be in a php variable.
Any tips on parsing html out of it would be great.
Thanks

$fp = fopen(/http://site.com/path/to/file/;, r);
while (!feof($fp)) {
   $buf .= fread($fp, 1024);
}
fclose($fp);
I like this method more than using file(), just because I have more 
control over what happens.  Since you're reading as its downloading, you 
can do stuff with the data before you're finished. 

As for parsing HTML... regular expressions are very cool.

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


Re: [PHP] Red Hat 9, Apache 2, and PHP

2003-07-03 Thread justin gruenberg
Jeff Schwartz wrote:

The PHP site (under Servers-Apache 2.0) says Do not use Apache 2.0 and PHP in a production environment neither on Unix nor on Windows but isn't clear whether Linux is included or whether it applies to all Apache 2 releases (such as 2.0.46) or just the original 2.0.

And, Red Hat 9 comes with 2.0 so it's really confusing. Has anyone had any experience with this combo?

Thanks,
Jeff
 

When someone says UNIX, they're generally including Linux and BSD, as 
both are UNIX clones.  At this point anyone in their right mind is going 
to suggest you stick with Apache 1.3.x.

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


Re: [PHP] Java Applet to PHP Communication

2003-07-02 Thread justin gruenberg
Sharat Hegde wrote:

Hello,

I need to be able to communicate from a Java Applet to a PHP program on the
server to enable Live Connect for data. This is what I intend to do:
In my web application, a Java Script program will call a Java Applet which
then calls the PHP program on the server. The PHP program works like a
servlet and passes the result back to the Java applet which passes the
information back to the JavaScript program.
How can a Java applet work with a PHP program? Are there any special
precautions / programming issues involved?
Thanks in advance

With Regards,
Sharat
Not anything that you wouldn't have to pay attention to in passing stuff 
between applications in other instances.

I'd use XML/SOAP to pass around the data.  There are many reasons to do 
this, I wont list them here just because there are plenty of articles on 
the web advocating the use of XML.  The added bonus is the buzzword factor.



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


Re: [PHP] a question, need an answer

2003-06-22 Thread justin gruenberg

what is the diffirent between :
//
session_start ();
$_SESSION['eventid'] = 'arma2';
///
and
/
session_start ();
session_register('arama2');
///
Regards
Nabil
 

Both accomplish the same thing, except how you are using it might not be 
what you expect.

$_SESSION['eventid'] = 'arma2'; 
will assign the string arma2 to $_SESSION['eventid'] (obviously).

session_register('arama2');
will make the variable $arma2 a session variable.  I believe you want 
session_register('eventid')
The session_register way of doing things makes it act a lot like register_globals is on.  It seems like we're trying to move away from this style of coding, so I'd suggest you use the first method with the $_SESSION variable.



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


Re: [PHP] TIP parsing form row data into variables

2003-06-22 Thread justin gruenberg
Nothing appears blatently wrong in the code you provided, but it's 4am 
here, so I might be off.

This comes to my mind:
1.  $_REQUEST was available from PHP 4.1.0 and later, are you using 
somthing before that?
2.  I assume you're doing somthing with $e_id within your loop, or else 
you're just resetting the contents of it.
3.  You might want to try print_r($_REQUEST) to see if it contains what 
you think it contains.

George Pitcher wrote:

Hi all,

This might be well known, so apologies if I'm going over old ground - I've
not seen this explained this way.
Last year I did a site using the variable variables method to parse row
data.
Now that I've moved to globals=off, I couldn't get that to work so I tried a
few other options settling for the following:
('howmany' is  the number of form rows on the previous page)

$howmany = $_REQUEST['howmany'];
for ($index = 1; $index  $howmany; $index++){
  $e_id = 'e_id'.$index;
  $e_id = $_REQUEST[$e_id];
Then do something with it.

Hope this helps someone.

George in Oxford

 



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


Re: [PHP] Embedding image a PHP file

2002-12-29 Thread justin gruenberg
yy.php should contain
?php
header(Content-type: image/jpeg);  /* or gif or whatever... you can 
also take a look at getimagesize() to get the type of the image 
automatically */
readfile(THE FILE);
?

it's extremely important that there is no whitespace before the ?php 
tag and after the ? tag.

empty wrote:

Hi

Anybody knows how to embed a image file to a php file, not as html;

for example;

img src=yy.php /

embedding a image file in yy.php file.

Thanks everybody


 



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