Re: [PHP] Question

2003-03-10 Thread Mark Heintz PHP Mailing Lists

if($recordcount % 4 == 0)
{
  echo '';
}

mh.

On Mon, 10 Mar 2003, Clint Tredway wrote:

> I have a display of images that every fourth image I want to start a new
> column. In ColdFusion I would use the MOD operator like this:
>
> if query.recordcount MOD 4 eq 0
>   
>   
> /if
>
> I am just having a brain lapse today, can someone help me do this same
> functionality in PHP?
>
> Thanks!


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



Re: [PHP] Multi-select inputs and naming

2003-03-10 Thread Mark Heintz PHP Mailing Lists
On Mon, 10 Mar 2003, Dan Phiffer wrote:

> I guess this question was coming from a "couldn't they have designed in a
> cleaner way?" perspective. Don't get me wrong, I think the way PHP does an
> outstanding job of handling these particular kinds of form submissions, I
> just figured there might be an alternative syntax.

That is a good question...  I've had the (privelege?) of working with php
almost exclusively for the past 3-4 years, to the point where I've rarely
had to deal with other web-targeted languages (something I'm in the
process of changing).  To others on the list:  how do perl, jsp, asp, etc.
handle the passing of multiple selects?  What is their equivalent of php's
"var[]" syntax for handling form values?

mh.


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



Re: [PHP] A question of time...

2003-03-10 Thread Mark Heintz PHP Mailing Lists
On Mon, 10 Mar 2003, Robert Cummings wrote:

> All in all I spent 20 hours total for the client at a rate of $40 USD/hr
> which I believe is on the low end of freelance. I myself have 3 years
> experience devloping PHP web applications. So the question I ask is whther
> this time frame is reasonable, or am I just a slow crappy programmer that is
> ripping these people off? They seem to think I should have had this done in
> just a few hours, but my experience thus far indicates to me that they got
> just service. Additionally it seems before I took the job, they had went
> through several other PHP developers would said they couldn't do it (and I
> don't really blame them considering the VNC connection and lack of comments or
> error feedback).
>
> If it turns out that I am incompetent, then I will happily send them a
> bill for zero hours, otherwise I would like to take comfort that I am not
> ripping them off.

It sounds very fair to me.  My time would have been similar if not more
(esp. not knowing the state of the existing code), and my hourly rate
2-3 times yours.

mh.



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



Re: [PHP] Is the problem a server setting?

2003-03-10 Thread Mark Heintz PHP Mailing Lists
It sounds like either allow_url_fopen is set to false or php was compiled
with --disable-url-fopen-wrapper.  Either way, checking the output of
phpinfo() should give you your answer.

mh.

On Mon, 10 Mar 2003, Chad Henderson wrote:

> Thanks for the reply. If they did upgrade PHP, which I am fairly sure they
> did, are there changes to the new PHP that would prevent the script from
> working?  Or is it a matter of them not setting up the upgrade the same as
> the previous installation?
>
>
>
> "Ray Hunter" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> You should contact the web hosting system administrator and verify that
> they upgraded php.  From what i can tell it seems that they did upgrade
> php.
>
> --
> Ray
>
> On Mon, 2003-03-10 at 10:58, Chad Henderson wrote:
> > I have a number of websites that are on a hosting company, that I have
> been
> > using for a year or so. Suddenly, this morning, all of the websites began
> to
> > have PHP script errors on scripts that have run without fail for a long
> > period of time. I think the server setup must have been altered this
> weekend
> > but do not know how to look for or prove this. Any ideas would be greatly
> > appreciated.
> >
> > Here is the error you get when you try to load http://www.afgaonline.com
> >
> > --paste--
> >
> > Warning: file(http://www.afgaonline.com/templates/tem4.tem)
> [function.file]:
> > failed to create stream: HTTP request failed! ¿¯wT in
> > /home/afgaonli/public_html/includes/Template.php on line 15
> >
> >  --end paste --
> >
> > The text that follows failed! above always changes.
> >
> > Here is the code that is failing:
> >
> > 12function Template ($template)
> > 13 {
> > 14   $this->template = $template;
> > 15   $this->html = implode ("",(file($this->template)));
> > 16 }
> >
> > What should I look for?
> > thanks!
> >
> > Chad


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



Re: [PHP] Multi-select inputs and naming

2003-03-10 Thread Mark Heintz PHP Mailing Lists
On Mon, 10 Mar 2003, Dan Phiffer wrote:

> Am I correct in my understanding that for a multi-select input, PHP requires
> that the name attribute end with square brackets (i.e.  name="my_select[] multiple>") in order for the submission be handled
> properly?

As far as I know, that is correct.  I'd love to hear otherwise.

> I know this is somewhat nit-picky, but this seems to unnecessarily expose
> the underlying technology such that scanning the HTML source reveals that a
> PHP script will ultimately parse the submission.

Unless you're ashamed to be running php, or don't intend to be spending as
much time on security as you should, why would this be an issue?  If your
app is well-written, the knowledge that it's implemented with php
shouldn't benefit a potential attacker.  You know what they say about
security through obscurity...

> I'm hoping there's some alternative technique I've missed...

I guess you could use javascript to create/set individual hidden form
fields for the items selected, but if the user has javascript disabled
your form ceases to function.

mh.


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



Re: [PHP] form submission and storing variables

2003-03-10 Thread Mark Heintz PHP Mailing Lists
You can initiate a POST from within your script using cURL, assuming your
php installation has cURL support enabled.  Check http://www.php.net/curl
for details.

mh.

On Mon, 10 Mar 2003, Doug Parker wrote:

> I'm sending information to be processed by a third party site.  I need
> to store the inputted information in my site, via session or whatever,
> at some point.  However, the 3rd part site only accepts the information
> via a POST form submission, so I can't record the variables, then
> redirect them to the 3rd party site via a header function.  What should
> I do?
>
> any help would be greatly appreciated.
>
>
> --
> 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



Re: [PHP] html mail

2003-03-10 Thread Mark Heintz PHP Mailing Lists
The PEAR Mail_mime class tends to take the headache out of this sort of
thing.  See the example at the bottom of the manual page:
http://pear.php.net/manual/en/core.mail.mime.php

mh.

On Mon, 10 Mar 2003, [iso-8859-1] Ian A. Gray wrote:

> Hi,
> I am quite new to php and I am trying to find a way of
> sending details of a web form over e-mail in both text
> and html format.  There are numerous sites on the web
> that try and explain how to do this but they are
> worded very complicated and to be honest I haven't
> found one that is particularly good.
>
> I want to send an e-mail that contains html code, with
> the option of attatching images and other files as
> well as a text version of the email so that the viewer
> can read the same e-mail whether or not he can view
> html email or not.
>
> Any ideas?
>
> Ian Gray.


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



Re: [PHP] Easy Way.

2003-03-09 Thread Mark Heintz PHP Mailing Lists
You're looking for the str_pad function.
http://www.php.net/str_pad

$i = 3;
$i = str_pad($i, 5, '0', STR_PAD_LEFT);
echo $i;  // outputs '3'

Just keep in mind that it won't help you if your input is greater than 5
to begin with, you'll have to check that seperately.

$j = 123456;
$j = str_pad($j, 5, '0', STR_PAD_LEFT);
echo $j; // outputs '123456'


mh.


On Sun, 9 Mar 2003, Vincent M. wrote:

> Hello,
>
> Is there an easy way to change an integer to a 5 caracters string.
> For example:
> $i = 3 ;
> $j = 110 ;
> After having changed them:
> $i = "3" ;
> $j = "00110" ;
>
> Is there a php function to do so instead of doing this:
>if( ($i>0)&&($i<10)) {
>   $i = "".$i ;
>} else if( ($i>9)&&($i<100)) {
>   $i = "000".$i ;
>} else if( ($i>99)&&($i<1000)) {
>   $i = "00".$i ;
>} etc...
>
> Thanks :-)
>
> Vincent.


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



[PHP] Re: global find and replace

2003-03-08 Thread Mark Heintz PHP Mailing Lists
Actually, in this case str_replace() would be preferred over preg_replace,
as it would be faster.

foreach($_REQUEST AS $key => $val)
{
  $_REQUEST[$key] = str_replace(';', '', $val);
}


mh.

On Sat, 8 Mar 2003, James wrote:

> Add an append file to the php.ini file, this script will act the default
> loader before any other php action.
>
> parse $HTTP_POST_VARS and $HTTP_GET_VARS and $HTTP_FILES or whatever you
> want
> Parsing the POST_VARS and GET_VARS will mean you will not have to worry
> about variable names
>
> dont use eregi_* use preg.
>
> var = preg_replace("/;/i","", $var);
>
> jim.
>
>
>
>
> "Didier McGillis" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I have to remove all semi-colons from user input fields that will be sent
> > down to our backend system, semi-colons are the delimiter in the messages
> > that flow from ur website to our backend system.  How I need this to work
> is
> > not client side but server-side in our pages, I need to do this in the
> least
> > system taxing and easiest to implement.  There are many many files and
> > fields that find their way into the system.  I dont necessarly want a PHP
> > function.  I am looking for a best pratice for doing a global removal.
> >
> > Here are the three approaches that I have thought of, although there is
> > another one but that is outside my scope as it requires me touching out
> C++
> > componets.
> >
> > 1.  Down and dirty make a function that will strip each field when it is
> > going through its normal validation.  Time consuming and taxing of the
> > system.
> >
> > 2.  Strip the semi colons on their way in to the functions that interact
> > with the C++ components.
> >
> > 3.  Strip them in the JSI component, which is the layer between JS and
> C++.
> >
> > 4.  I had thought of stripping the semi-colons in the C++ components
> myself,
> > I thought that would be the best, doing a strip, but I dont know C++ very
> > well and I dont know the best way or any way to do that.
> >
> > Okay you have seen my four obviously briliant ideas, do you have one or do
> > you have a way of doing this task easly and quickly.
> >
> > Please help



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



Re: [PHP] Uploading file problem

2003-03-06 Thread Mark Heintz PHP Mailing Lists

What do you mean by "fails at the copy"?  Have you verified that the
filename and path you're copying to is valid?  Otherwise, if the filename
that is failing is consistently the same, and if it's attempting to
overwrite an existing file, it could be a permissions problem.  Just a
couple of guesses...

mh.

On Thu, 6 Mar 2003, Amanda McComb wrote:

> I'm very new to PHP, so I hope no one is offended by reading my very basic
> questions.
>
> I have created a web form that saves some data to a database and uploads
> three files, copies them to a new directory, and renames them.  From my
> work machine and home machine, it works great for me - there are never any
> errors.  When my boss tries it, two of the files work fine, but the other
> fails at the copy.  I have watched him do it, and it's not user error.
> What could the problem be?  I'm stumped!
>
> I can include code or links if needed.
>
> Thanks,
> Amanda


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



Re: [PHP] mortgage calculator

2003-03-05 Thread Mark Heintz PHP Mailing Lists

http://dave.imarc.net/ offers one.  I haven't used it yet myself, though.

mh.

On Wed, 5 Mar 2003, Karen E. Lubrecht wrote:

> I'd like to add a mortgage calculator to a client's site. I've been unable
> to find the formula. In searching php.net, I found a discussion from back in
> 2000 related to some buggy code. My web search hasn't produced anything
> other than realtor and mortgage companies and a perl script site. I'm not
> familiar with perl and would prefer avoiding it until my knowledge improves.
> There were corrections for a java script somewhere, but I'm beginning to
> think it is down. Some things seem so obvious that you just don't think you
> need to bookmark! So why can't I remember...
>
> I would just prefer not reinventing the wheel. Suggestions would be greatly
> appreciated.
>
> Karen


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



RE: [PHP] file upload question

2003-01-24 Thread Mark Heintz PHP Mailing Lists

You have to include a filename along with the path when you're using
move_uploaded_file(); if you're only specifying
'/usr/local/etc/httpd/htdocs/blast/images' as your destination string, php
is trying to create a file named 'images' in
'/usr/local/etc/httpd/htdocs/blast'.  If there's still a problem,
the user that your webserver (and therefore php, in most cases) runs as
may not have write permission to the directory you're trying to move to.
Make sure the webserver can write to the destination directory.

mh.


On Fri, 24 Jan 2003, Andrew Rench wrote:

> thanks for the advice- this makes sense as to why I'm not seeing the file. I added 
>the
> move_uploaded_file() to the script to see what happens and I end up getting the 
>following error:
> PHP Warning: Unable to move '/var/tmp/phpfcwVyC' to 
>'/usr/local/etc/httpd/htdocs/blast/images' in
> /usr/local/etc/httpd/htdocs/blast/upload_test2.php on line 10
>
> Am I setting the path wrong? Should it be relative to the 'upload_test2.php' file?
>
> thanks
>
> --- "Ford, Mike   [LSS]" <[EMAIL PROTECTED]> wrote:
> > > -Original Message-
> > > From: Andrew Rench [mailto:[EMAIL PROTECTED]]
> > > Sent: 24 January 2003 17:05
> > >
> > > the following code:
> > >
> > > 
> > > 
> > >  > > ="post">
> > > 
> > > Send this file: 
> > > 
> > > 
> > >  > > echo $_FILES['userfile']['tmp_name'];
> > > ?>
> > > 
> > > 
> > >
> > > produces the following after upload:
> > >
> > > /var/tmp/phplSTEVp (or php[something-or-other])
> > >
> > > When I view that directory, it is empty.
> >
> > When you upload a file, the file PHP puts it in is a temporary file -- hence the 
>['tmp_name']
> > key -- which is your /var/tmp/php??.  Because it's a temporary file, PHP 
>automatically
> > deletes it when the script ends.  If you haven't done something with it in the 
>script (such as
> > move_uploaded_file() it), it's gone forever.
> >
> > Cheers!
> >
> > Mike
> >
> > -
> > Mike Ford,  Electronic Information Services Adviser,
> > Learning Support Services, Learning & Information Services,
> > JG125, James Graham Building, Leeds Metropolitan University,
> > Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> > Email: [EMAIL PROTECTED]
> > Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211
>
>
> __
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> 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




Re: [PHP] Setting session variables from a MySQL field value.

2003-01-15 Thread Mark Heintz PHP Mailing Lists

The problem may be your variable variable syntax...  See if the following
works:

while ($row = mysql_fetch_array($result))
{
  session_register('config_'.$row['config_id']);
  ${'config_'.$row['config_id']} = $row['config_value'];
}

Although I personally prefer using the session superglobal over
session_register, which means you'd just need a string for the key
value and can avoid variable variables altogether...

while ($row = mysql_fetch_array($result))
{
  $_SESSION['config_'.$row['config_id']] = $row['config_value'];
}

mh.


On Wed, 15 Jan 2003, Stephen of Blank Canvas wrote:

> Hi Everyone,
>
> I'm trying to use MySQL to store some general settings for a site I am
> working on, which I was then going to access as session variables on
> pages as needed without having to call the dB each time.  However I am
> having problems setting the name of the session variable in a way that I
> can reference it later.  The code I am trying to use is:
>
> ===
>session_start();
>$connection =
> @mysql_connect("$MySQLHost","$MySQLUser","$MySQLPassword") or
> die("Unable to connect to MySQL Host. ".mysql_error() );
>$db = @mysql_select_db($MySQLdB, $connection) or die("Unable to
> connect to MySQL dB. ".mysql_error() );
>$query = "SELECT * FROM config WHERE status = 1";
>$result = @mysql_query($query,$connection) or die("Unable to execute
> select query. ".mysql_error() );
>$num_rows = mysql_numrows($result);
>
>while ($row = mysql_fetch_array($result))
>{
>$config_$row[config_id] = $row[config_value];
>session_register(config_$row[config_id]);
>}
>
>mysql_free_result($result);
>mysql_close($connection);
> ===
>
> Any pointers much appreciated.
>
> Stephen
>



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




Re: [PHP] form arrays not populating $_POST

2002-10-29 Thread Mark Heintz PHP Mailing Lists

Like I said, it works fine on any other server.  I was wondering if it
could be a configuration issue.

I believe $GLOBALS['HTTP_RAW_POST_DATA'] is not populated by default by a
setting in php.ini.  I turned it on to verify that the browser was
actually transmitting the data which was missing from the array.

Mark.


On Tue, 29 Oct 2002, Kevin Stone wrote:

> I Copy and Pasted your code directly from this email and tested it.
> $GLOBALS['HTTP_RAW_POST_DATA'] never gets set, but the rest of it worked
> fine.  Curious.
> -Kevin
>
>
> ----- Original Message -----
> From: "Mark Heintz PHP Mailing Lists" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, October 29, 2002 2:20 PM
> Subject: [PHP] form arrays not populating $_POST
>
>
> > I'm having a problem where $_POST is being populated with the values of a
> > set of checkboxes after moving the script to a new server.  The checkbox
> > values appear in the raw post data, the proper number of indexes are
> > created, but the data does't make it into the superglobal.
> >
> >
> > The form similar to the following:
> >
> > 
> > 
> >  1
> >  2
> >  3
> > 
> > 
> >
> >
> >
> > The php to check it:
> >
> >  > if(isset($_POST['some_var'])){
> >   echo "";
> >   echo $GLOBALS['HTTP_RAW_POST_DATA']."\n\n";
> >   print_r($_POST);
> >   echo "";
> > }
> > ?>
> >
> >
> > Checking checkbox 1 and 2 and submitting results in the following:
> >
> > test=Hello&some_var%5B%5D=1&some_var%5B%5D=2&submit=submit
> > Array
> > (
> > [test] => Hello
> > [some_var] => Array
> > (
> > [0] =>
> > [1] =>
> > )
> >
> > [submit] => submit
> > )
> >
> >
> > This is running under php 4.2.3 on apache 1.3.20.  The script was working
> > fine on the previous server (same php and apache version).  The only
> > oddity is that the script utilizes phplib (some_var is registered as a
> > phplib session var), but I'm performing the print_r before any phplib
> > files are included.
> >
> > Has anyone ever encountered this problem?
> >
> > Thanks,
> > mh.
> >
> >
> > --
> > 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




[PHP] form arrays not populating $_POST

2002-10-29 Thread Mark Heintz PHP Mailing Lists
I'm having a problem where $_POST is being populated with the values of a
set of checkboxes after moving the script to a new server.  The checkbox
values appear in the raw post data, the proper number of indexes are
created, but the data does't make it into the superglobal.


The form similar to the following:



 1
 2
 3





The php to check it:

";
  echo $GLOBALS['HTTP_RAW_POST_DATA']."\n\n";
  print_r($_POST);
  echo "";
}
?>


Checking checkbox 1 and 2 and submitting results in the following:

test=Hello&some_var%5B%5D=1&some_var%5B%5D=2&submit=submit
Array
(
[test] => Hello
[some_var] => Array
(
[0] =>
[1] =>
)

[submit] => submit
)


This is running under php 4.2.3 on apache 1.3.20.  The script was working
fine on the previous server (same php and apache version).  The only
oddity is that the script utilizes phplib (some_var is registered as a
phplib session var), but I'm performing the print_r before any phplib
files are included.

Has anyone ever encountered this problem?

Thanks,
mh.


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




Re: [PHP] passing variable arguments from

2002-06-27 Thread Mark Heintz PHP Mailing Lists

On Thu, 27 Jun 2002, Haddad Said wrote:

> in query.php i have this piece of code;
>
> echo "
> 
> one
> two
> 
> 
> 
> ";
>
> 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] How to put a "new line" character with fputs($birthday_file,$content);

2002-06-23 Thread Mark Heintz PHP Mailing Lists


"\n" is a newline character, "\r" is a carriage return.

$line = "This is a line with a newline character.\n";

You can find it in the manual here:
http://www.php.net/manual/en/language.types.string.php

mh.



On Fri, 21 Jun 2002, Alfredo wrote:

> Hi,
>
> I am saving the result of a query on a text file.  Then I want to open it
> with excel.
>
> At the moment, when I open it with excel, all results appear in one very
> long line.  How could I insert a "new line" character at the end of each
> record?
>
> Thanks
>
> Alfredo
>
>
>
> --
> 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




Re: [PHP] POST Arrays with register globals..

2002-06-12 Thread Mark Heintz PHP Mailing Lists

$groups = $_POST['groups'];

or

if(isset($_POST['groups']) && is_array($_POST['groups']))
  $groups = $_POST['groups'];
else
  $groups = array();

so that groups is an (empty) array even if no checkboxes were checked

mh.


On Wed, 12 Jun 2002, Adam Plocher wrote:

>   blah1
> &nbps; blah2
>   blah3
>
> I can't seem to access that data correctly when that form gets submitted.
>
> I have tried:
>
> $groups[] = $_POST['groups[]'];
> and
> $groups[] = $_POST['groups'];
>
> no luck..
>
> Can somebody please give me a hand, thanks a lot.
>
> -Adam
>


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




Re: [PHP] PHP (CLI) + CURL + SSL Problem...

2002-06-07 Thread Mark Heintz PHP Mailing Lists

Are you sure curl was included with the CLI installation?  Try running
this through the CLI to check...

if(extension_loaded('curl')){
  echo 'curl support present';
} else {
  echo 'curl not found';
}

mh.


On 7 Jun 2002, Matthew Walker wrote:

> I have PHP installed both as a module, and as a CLI. When I use CURL
> from inside the module, it works fine for all connections, including
> SSL. When I use the CLI, I can't make SSL connections with CURL. It just
> returns 'false'. Anyone know why?


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




Re: [PHP] PHP code in a database

2002-06-07 Thread Mark Heintz PHP Mailing Lists

You want the eval() function.

manual entry:
http://www.php.net/eval

mh.


On Fri, 7 Jun 2002, Jean-Rene Cormier wrote:

> I'm trying to make a script that'll take some pages from a database but
> I want it to execute the PHP that's in the pages that it'll fetch from
> the database.
>
> Say it gets the data from the page in $data I want it to put the data on
> the screen and if there's some PHP code in the $data variable I want it
> to be executed. Is there a way I can do that?
>
> Jean-Rene Cormier


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




Re: [PHP] Comparing array elements

2002-06-05 Thread Mark Heintz PHP Mailing Lists

Well, it sounds like something that could be done through the db
query, but if you want to use arrays, it'd be something like this...

$servers = arrray('s1','s2','s3','s4','s5');
$group1 = array('s1','s4','s5');

$in_group = array_intersect($servers, $group1);
$not_in_group = array_diff($servers, $group1);


mh.


On Wed, 5 Jun 2002, Chris Knipe wrote:

> hey everyone,
>
> Does anyone have and ideas of wisdom on how to compare arrays (mysql result
> sets) and group items based on if they exist in two or more arrays?
>
> For example:
>
> I have a table, with a list of servers:
> server1
> server2
> server3
> server4
> server5
> ...
> serverX
>
> I have a table that specifies which of the servers are grouped:
> group1
>   server1
>   server4
>   server5
>
> Now, I want to compare group1 against the server list, and do something like
> the following:
> In group:
>   server1
>   server4
>   server5
>
> Not in group:
>   server2
>   server3
>   serverX



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




Re: [PHP] Re: Parsing file's

2002-05-31 Thread Mark Heintz PHP Mailing Lists

You may have been heading in the right direction originally with
array_slice...  This is off the top of my head, I don't guaruntee it will
work...

$start = 34;
$interval = 15;
$max = 303;
// hop across orig. array 15 columns at a time
for($offset = $start;
$offset < $max && isset($array[$offset]);
$offset += $interval){
  // slice off $interval many columns starting at $offset
  $sub_array = array_slice($array, $i, $interval);
  // handle your $interval many key-value pairs
  foreach ($sub_array as $key => $value){
$policyWriter = "$quoteKey|$key|$value";
// ...
  }
}


mh.


On Fri, 31 May 2002, Scott wrote:

> That's what I mean by starring at this too much :)  I tried writting to a
> seperate file, but is there a way to take an array and split it every so
> many records within another loop?
>
> Let's say the first row contains the first 18 columns which I already
> parsed, I then want to grab the next 5 15 columns, but need to seperate
> them in groups of 15.  I tried this:
>
> foreach ($output as $key => $value){
>   $policyWriter = "$quoteKey|$key|$value";
>   fwrite ($policyFile,"$policyWriter\r\n");
> }
>
> Which will take and print the rest of the row, but I needo split the
> columns into groups of 15.
>
> -Scott
>
>
>
>
>
> On Fri, 31 May 2002, Michael Davey wrote:
>
> > You should normalise your data - have a field in the second csv that links
> > to the first csv and then you can have as many rows as you want associated
> > with the record in the first file.
> >
> > Mikey
> >
> > "Scott" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > I have a csv file that I am parsing, formatting and then writting to a new
> > > file.  I am currently using an array, but I have some lines that might
> > > contain more data than others.  I know for sure that columns 0-33 will
> > > always be there, but the customer has the option to add another set of
> > > columns to the row if needed.  I do know that the addition's will always
> > > be 18 columns and I do know that they can add up to 15 set's of 18.  So,
> > > the row length could be 0-33 or 0-51 if they add one additional set or 303
> > > columns if they go up to 15.
> > >
> > > The tricky part is I have to format each column for the new file that is
> > > created, I do this using sprintf.  I have so far tried to use array_slice
> > >  for the first 18 columns, then I do another array_slice starting at 18
> > > and using the column count to get the last column in the row.  Here is the
> > > code:
> > >
> > > array_slice($fields, 18,$lineCount);
> > > foreach ($fields as $key => $value){
> > > print "$key|$value\r\n";
> > > }
> > >
> > > The format of the new file will be this:
> > > 01-Customer information
> > > 02-Other information
> > > 03a Required Info (that can repeat up to 15 times per line)
> > > 03b ""
> > > 04b ""
> > > 04-Close Customer Record
> > >
> > > Repeat cycle for each row.  The inner loop happens between the 02 and 04
> > > records.  Remember, I need to format each individual column, they are
> > > different format options.
> > >
> > > If you have some thoughts, I would be all ears as I have been starring at
> > > this too long and too hard.
> > >
> > > Thanks,
> > >
> > > -Scott




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




Re: [PHP] how to send a file to the user's browser?

2002-03-18 Thread Mark Heintz PHP Mailing Lists

On Mon, 18 Mar 2002, Mark Heintz PHP Mailing Lists wrote:

>   header ( "Content-Disposition: attachment; filename="$downloadfile" );

erg... typo...

  header ( "Content-Disposition: attachment; filename=$downloadfile" );


mh.



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




Re: [PHP] how to send a file to the user's browser?

2002-03-18 Thread Mark Heintz PHP Mailing Lists


A couple more headers than absolutely necessary, but this should work:




mh.


On Mon, 18 Mar 2002, Carlos Fernando Scheidecker Antunes wrote:

> Hello all,
>
> I've got a script that generates a txt file, compresses it into a Zip file and it 
>all happens on a directory that is out of apache's web site.
>
> This script generates the file based on MySQL server information and I have it then 
>sent to the user's e-mail address. What I would like to do is to make the PHP script 
>"throw" the file to the user's browser so that it would download it automatically. 
>This file is created on a directory that is not the same as the web server where the 
>pages and php scripts are located.
>
> Anyone could help me with that?
>
> Thanks.
>
> regards,
>
> Carlos Fernando Scheidecker Antunes
> Linux User #207984
>
>


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




RE: [PHP] Creating arrays using results from MySQL query

2002-03-18 Thread Mark Heintz PHP Mailing Lists


I should have been more exact in my original reply.  The second query
isn't necessary.  Try this:

File: login.php
# if $employee_1, query db workgroups table to check if $emp_login_id
belongs to any groups
$sql_2 = "SELECT * FROM workgroups WHERE emp_id='$emp_login_id'";
$result_2 = @mysql_query($sql_2) or die (mysql_error());
# initialize empty arrays
$emp_login_wkgrp_id = array();
$emp_login_grp_id = array();
$emp_login_role_id = array();
$i=0;
# while there are matches, set workgroups login variables in array, then
# register workgroups login variables in session
while($employee_2 = mysql_fetch_array($result_2)){
  $emp_login_wkgrp_id[$i] = $employee_2["wkgrp_id"];
  $emp_login_grp_id[$i] = $employee_2["grp_id"];
  $emp_login_role_id[$i] = $employee_2["role_id"];
  $i++;
}
session_register('emp_login_wkgrp_id');
session_register('emp_login_grp_id');
session_register('emp_login_role_id');


mh


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




Re: [PHP] Creating arrays using results from MySQL query

2002-03-18 Thread Mark Heintz PHP Mailing Lists


You have to call mysql_fetch_array for each record in your result set...

$emp_login_wkgrp_id = array ();
$emp_login_grp_id = array ();
$emp_login_role_id = array ();
$i = 0;
while($employee_2 = mysql_fetch_array($result_2)){
  $emp_login_wkgrp_id[$i] = $employee_2["wkgrp_id"];
  $emp_login_grp_id[$i] = $employee_2["grp_id"];
  $emp_login_role_id[$i] = $employee_2["role_id"];
  $i++;
}

mysql_fetch_array will return false when you run out of results, breaking
the while loop.

Check the manual for more info:
http://www.php.net/manual/en/function.mysql-fetch-array.php


mh.


On Mon, 18 Mar 2002, Mullin, Reginald wrote:

> Hi Guys,
>
> I've been experiencing some problems when trying to build 3 arrays with the
> ID values of all of the groups a user belongs to.  (I then want to register
> these arrays into the current session).  The arrays only appear to be
> getting the first value (group ID) instead of all of the values the user
> belongs to.  What am I doing wrong here?
>
> My code looks like this:
>
> File: login.php
> # if $employee_1, query db workgroups table to check if $emp_login_id
> belongs to any groups
> $sql_2 = "SELECT * FROM workgroups WHERE emp_id='$emp_login_id'";
> $result_2 = @mysql_query($sql_2) or die (mysql_error());
> $rows = mysql_num_rows($result_2);
> $employee_2 = mysql_fetch_array($result_2);
> # if match, set workgroups login variables in array, then register
> workgroups login variables in session
> if ($employee_2){
>   $emp_login_wkgrp_id = array ();
>   $emp_login_grp_id = array ();
>   $emp_login_role_id = array ();
>   for ($i=0; $i<$rows; $i++){
>   $emp_login_wkgrp_id[$i] = $employee_2["wkgrp_id"];
>   $emp_login_grp_id[$i] = $employee_2["grp_id"];
>   $emp_login_role_id[$i] = $employee_2["role_id"];
>   }
>   session_register('emp_login_wkgrp_id');
>   session_register('emp_login_grp_id');
>   session_register('emp_login_role_id');
> }
>
> O  From Now 'Till Then,
> \->Reginald Alex Mullin
> /\  212-894-1690
>
>
>
> **
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the postmaster at [EMAIL PROTECTED]
>
>
> www.sothebys.com
> **


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




Re: [PHP] help with date formatting

2002-03-18 Thread Mark Heintz PHP Mailing Lists


Since you're using phpmyadmin, I'm assuming you're using mysql.  You could
use the built-in date and time functions to do the formatting when
selecting your date field.  Check here:

http://www.mysql.com/doc/D/a/Date_and_time_functions.html

mh.

On Mon, 18 Mar 2002, Ryan wrote:

> Hi, I'm trying to create an events page, where it shows the posted
> events.  I enter data using phpmyadmin.  Currently, the ouput is like
> this:
>
> 
> Conference in New York
> 2002-03-06
>
> There is going to be a conference in New York next week.
> 
>
> I'm having trouble with the formatting of the date.  I'm using the type
> date with the function now, so it shows the current date when I post an
> event.  Here is what I would like:
>
> 
> Conference in New York
> Wednesday, March 5th, 2002
>
> There is going to be a conference in New York next week.
> 
>
> Thanks for any help.
>
> --
> Ryan Spangler
> 428 N Harmony Ln, Apt. 3
> Whitewater, WI 53190
> (262) 473-8392
> [EMAIL PROTECTED]


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




Re: [PHP] Must results from MySQL fetches always be an Array??

2002-01-25 Thread Mark Heintz PHP Mailing Lists

On Fri, 25 Jan 2002, [ISO-8859-1] René Fournier wrote:

> $series = mysql_fetch_array(mysql_query("SELECT key2 FROM models WHERE
> lang='$lang' AND recordname='$model'",$db));
>
> Now I realize that with this function $series will always be an array,
> even if it contains just one element (which it does). What I'd like to
> know is, can I write that statement so that $series is created just as a
> string? (So that I don't have to write "$series = $series[0];"
> immediately afterwards in order to treat $series as a $string.)

If you're sure that mysql_fetch_array is always returning an array with
a single element, you could use implode to convert the array to a
string...

$series = implode('', mysql_fetch_array(mysql_query( ...

Check http://www.php.net/manual/en/function.implode.php for details on
the implode function.

mh


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] fread via ftp to NT fails

2001-05-21 Thread Mark Heintz PHP Mailing Lists


I'm attempting to read a file from a remote server and save it to a
variable.  The code below works fine if the remote server is unix based,
but fails with the server I actually need to retrieve data from (NT4 SP4,
beyond my control).  When trying to fread from the NT server,
$invoice_contents ends up being null ($invoice_contents === '').

if( !($fd = fopen("anonymous:[EMAIL PROTECTED]/pub/readme.txt", "rb"))){
  $error = true;
  $error_msg = "Unable to connect to server.";
}
else {
  $i = 0;
  do {
$invoice_contents = fread($fd, 10);
$i++;
  } while( $invoice_contents == "" && $i < 2 );
  fclose($fd);
}

Here's the interesting part:  If I comment out the fread and run this
code, there is no visable difference in the ftp logs on the NT server (a
USER, PASS, and sent  appear for the connection).  Am I
correct in interpreting this as the file is being sent immediately (after 
the fopen) rather than at the fread?  Has anybody else encountered this? 

Thanks,
mth


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] fread over ftp

2001-02-21 Thread Mark Heintz PHP Mailing Lists

I'm having some trouble reading a text file from a remote server into a
string.  The code is as follows:


if( !($fd = @fopen($ftp_url, "r")) ){
  $error = true;
  $error_msg = "Unable to connect to server.";
}
else {
  $file_contents = fread($fd, 10);
  fclose($fd);
}

if( empty($file_contents) ){
  $error = true;
  $error_msg = "Did not read file.";
}


The problem is that the fread doesn't always succeed; about about half
the time the $file_contents string tests as empty.  There is never a
problem with the fopen, and there doesn't seem to be any consistancy in
the failure...  The same file may be loaded into the string on run one,
and missing the next.  The remote server is NT-based.

Does anybody know what is going wrong here?  I don't have to add any logic
to "wait" for the fread to complete, do I?

Thanks,
mth.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]