[PHP] php .htaccess autologin

2003-12-11 Thread ROBERT MCPEAK
I've dug around quite a bit and can't figure out how I might use PHP to handle an 
.htaccess login.  For example, if I wanted a script to log in the user, rather than 
the user logging in with the standard .htaccess dialog.

Any ideas?

Since the .htaccess vars are stored in the browser, should I be looking at a 
PHP/JavaScritpt 1-2 punch?

Thanks,

Bob

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



[PHP] $_POST var name char conversion . to _

2003-12-10 Thread ROBERT MCPEAK
Has anybody seen the seemingly automatic and unexplained conversion of the character 
. to _ in $_POST var names?  I've tested several ways, with and without PHP, and 
I've dug around in the HTML specs and can't find a good explanation.  Can anybody shed 
some light on this?  Can this be overridden?

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



RE: [PHP] $_POST var name char conversion . to _

2003-12-10 Thread ROBERT MCPEAK
Thanks all.  I guessed that it was something built in to PHP, although I was surprised 
when I couldn't find a good explanation in the usually excellent docs.  -Bob Mc

 Ford, Mike   [LSS] [EMAIL PROTECTED] 12/10/03 11:29AM 
On 10 December 2003 16:19, ROBERT MCPEAK contributed these pearls of wisdom:

 Has anybody seen the seemingly automatic and unexplained
 conversion of the character . to _ in $_POST var names?

Yes.  It's PHP automagic by PHP.

 I've tested several ways, with and without PHP, and I've dug
 around in the HTML specs and can't find a good explanation.
 Can anybody shed some light on this?  Can this be overridden?

It's explained at
http://uk2.php.net/manual/en/language.variables.external.php#language.variab 
les.external.dot-in-names, and no, it can't be overridden.

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

-- 
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] ARRAY

2003-12-10 Thread ROBERT MCPEAK
Because it's and array!  print and echo take strings, not arrays, I believe.  Anyway, 
print_r() or a foreach loop will do it for you.

?php 
print_r($table);
//or
foreach ($table as $atable){
echo $tableBr;
}
?

Something like that.

 Brian Sutton [EMAIL PROTECTED] 12/10/03 01:26PM 
I am trying to read in a text file to an array using the following code, 
however everytime I try and print the contents of the $table array, it 
always says ARRAY.  Why won't it show me the actual contents of the file?

$row = 1;
$handle = fopen (seclog.txt,r);
while ($data = fgetcsv ($handle, 1000, ,)) {
$num = count ($data);
print p $num fields in line $row: br\n;
$row++;
for ($c=0; $c  $num; $c++) {
print $data[$c] . br\n;
$table[] = $data;
}
}
fclose ($handle);
print $table;

-- 
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] preg_replace: literal / in pattern string

2003-06-03 Thread ROBERT MCPEAK
Search through the docs/archive and can't figure this one out.  Surely I'm overlooking 
something obvious.

I can't figure out how to escape a literal / in $q.  Adding the line: 
$q=str_replace(/, \/, $q); yields a literal \/ in $content.


$q_upper=strtoupper($q);
$q_lower=strtolower($q);
$q_ucfirst=ucfirst($q);

$patterns[0] = /$q/;
$patterns[1] = /$q_upper/;
$patterns[2] = /$q_lower/;
$patterns[3] = /$q_ucfirst/;

$content = preg_replace($patterns, $replacements, $content);

Thanks in advance, sincerely!


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



Re: [PHP] Dynamic value lookups

2003-06-03 Thread ROBERT MCPEAK
I agree that you will probably have to build all possible select value arrays on 
pageload if you want the select list to switch without a page reload.  PHP is parsed 
by the webserver and then sent to the page.  Javascript is parsed by the browser.  You 
can use PHP to dynamically generate Javascript, which can be pretty cool.

A great example of what you're trying to do can be seen on many car dealership 
websites, where you first select a car make and then all possible models for that 
make appear with a page refresh in the model select list.  Snoop around for that 
javascript source and you'll be on your way.

I agree with prior respondant that this is a PHP list, so that's it about JS from me.  
Just know that you can do anything with PHP as long as you can get a page load in 
there to parse the script.  Keep in mind ways you can use PHP to build JS on the fly 
at on pageload.

Good luck!

 Vijay Avarachen [EMAIL PROTECTED] 06/02/03 03:44PM 
Ok I am attempting to do something very simple and I know it can be 
done, but I have been told otherwise.  I have two select menu's, 
Products and Components.  There is a one to many relationship between 
them (one product can have many components).  I just want it so that 
when the user selects an entry in Products, Components get dynamically 
loaded (I know I gotta do somethign with onchange= but not sure what).
Value of Products and Components are being pulled form a database.

Someone told me the only way to do this is to load all the values of 
components into an array and pass it around.  Thats just dont' sound 
right to me.

I was thinking perhaps I can just do somthing like 
onchange=PHP_SELF?product=value.  No I know thats not the syntax but 
you get the idea =)

Any help would be appreciated.  Please keep in mind i have very very 
little knowledge of javascript.

Sincerely,
Vijay Avarachen


-- 
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] timing out a for loop, fopen

2003-01-15 Thread ROBERT MCPEAK
Dear PHP Gurus:

I'm looking for a way to timeout an fopen function.  I'm doing some link checking 
inside of a for loop and some links hang rather than return a definitive can't 
connect or can connect.  (Pardon the highly technical jargon there...)

In cases where my link hangs, I'd like to simply display a message (i.e., hanging) 
and advance to the next loop.  

I have search the docs/forumns far and wide and can't find anything definitive.  As 
far as I can tell socket_set_timeout won't quite do what I want it to.

Any ideas?  Here's the important part of my code:

for ()
{
echo Checking: $link : \n; flush();

$fp = @fopen($link, r);
if (!$fp) { echo font class=linksredThe link is 
dead!/font; }
else { fclose($fp); echo font class=linksgreenThe link is 
working!/font; }
echo brbR;

echo /font;
}

Thanks in advance!


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




[PHP] spawing new PHP process

2002-11-26 Thread ROBERT MCPEAK
I'm interested in spawing a new PHP process -- if that's the correct terminology.

The situation is that I've got a very slow loading page, where, for example, I'm using 
PHP to send, say, 1000 emails.  The user clicks submit, and, although PHP is firing 
out the emails, it appears to the user that page is hanging.  I'd like to somehow send 
that process to the background and let the page load straight-away.

In another scripting language I've used, this function was called spawn.

Do we have something like this in PHP (I know we do!! Just can't find it.) I've looked 
through the docs but don't see what I'm looking for.

Thanks in advance.

-Bob


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




Re: [PHP] spawing new PHP process

2002-11-26 Thread ROBERT MCPEAK
Rasmus,

Thanks for you reply.  I agree that what you suggest is the correct solution for the 
mail delivery scenario I used as an example.

My example was poor in that in limited the scope of what I was asking.

I have other situations where I would like to somehow spawn a new php process so 
that the page loads quickly and my user doesn't get frustrated or confused.

Another such situation would be when I do time consuming operations on a MySql table, 
such as building an index or loading data.  These operations may take several minutes 
and I'd like to avoid having to make my user wait for the page to load.

What is the correct solution for this problem?

I'm a newcomer to PHP, am quite excited by it, and really appreciate your insight.

Thanks,

Bob

 Rasmus Lerdorf [EMAIL PROTECTED] 11/26/02 11:46AM 
The correct solution for this particular problem is to just queue the
outbound mail and have your MTA deliver them out of band.  man sendmail

-Rasmus

On Tue, 26 Nov 2002, ROBERT MCPEAK wrote:

 I'm interested in spawing a new PHP process -- if that's the correct terminology.

 The situation is that I've got a very slow loading page, where, for example, I'm 
using PHP to send, say, 1000 emails.  The user clicks submit, and, although PHP is 
firing out the emails, it appears to the user that page is hanging.  I'd like to 
somehow send that process to the background and let the page load straight-away.

 In another scripting language I've used, this function was called spawn.

 Do we have something like this in PHP (I know we do!! Just can't find it.) I've 
looked through the docs but don't see what I'm looking for.

 Thanks in advance.

 -Bob


 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] interpreting variables containing in another variable

2002-11-20 Thread ROBERT MCPEAK
I've got a variable - $email_body, that contain's other variables.  For example, echo 
$email_body, might look like this:

$name, $address, $phone, $blah


I want those variables to interpreted with corresponding values set earlier in the 
script.  So, in effect, where name=bob, address=101 east main, phone=555-, and 
blah=foo, echo $email_body would look like this:

bob, 101 east main, 555-, foo


Any suggestions?

Thanks in advance.

-Bob


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




Re: [PHP] interpreting variables containing in anothervariable

2002-11-20 Thread ROBERT MCPEAK
Duh!!! Thanks!  Being a newbie hurts sometimes.

 Chris Shiflett [EMAIL PROTECTED] 11/20/02 01:50PM 
--- ROBERT MCPEAK [EMAIL PROTECTED] wrote:
 I've got a variable - $email_body, that contain's other variables. 
 For example, echo $email_body, might look like this:
 
 $name, $address, $phone, $blah
 
 I want those variables to interpreted with corresponding values set
 earlier in the script.  So, in effect, where name=bob, address=101
 east main, phone=555-, and blah=foo, echo $email_body would
 look like this:
 
 bob, 101 east main, 555-, foo

Check out the eval() function:

http://www.php.net/manual/en/function.eval.php 

Also, you might want to consider altering your approach slightly. For
example, maybe something like this would be more appropriate:

$email_body = $name, $address, $phone, $blah;

If you echo $email_body in this case, it will output:

bob, 101 east main, 555-, foo

Good luck.

Chris

-- 
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] newbie: help with date arithmetic

2002-11-12 Thread ROBERT MCPEAK
I'm trying to add/subract two dates.  I think I need to use mktime() but I can't quite 
figure out how.

I'd like to do something like this:

(2002-11-15)-(2002-11-10)=5

or

(2002-12-10)-(2002-11-10)=20

Obviously taking into account number of days in a given month.


Does somebody have some code handy that does this?  Any help would be greatly 
appreciated!

Thanks.


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




RE: [PHP] newbie: help with date arithmetic[Scanned]

2002-11-12 Thread ROBERT MCPEAK

This is a great help.  Thanks ya'll.  And I will continue to, and do regulary RTFM 
8-)  I find that it generally sucks for a newbie.


 Michael Egan [EMAIL PROTECTED] 11/12/02 10:42AM 
Robert,

I've been looking at this myself over the past couple of days.

I gather the best approach is to convert your dates into UNIX timestamps. 

For example:

$first_unix_time = mktime($hour1, $minutes1, $seconds1, $month1, $day1, $year1);

$second_unix_time = mktime($hour2, $minutes2, $seconds2, $month2, $day2, $year2);

Subtract the one from the other to give the difference:

$difference = $first_unix_time - $second_unix_time;

The result will be in seconds so you'll need to convert this depending on the format 
you require. 

For example, to convert the difference to years you might do:

$years = floor($difference / (365 * 24 * 60 * 60));

Hope this helps,

Michael Egan

-Original Message-
From: ROBERT MCPEAK [mailto:RMCPEAK;jhuccp.org] 
Sent: 12 November 2002 15:31
To: [EMAIL PROTECTED] 
Subject: [PHP] newbie: help with date arithmetic[Scanned]


I'm trying to add/subract two dates.  I think I need to use mktime() but I can't quite 
figure out how.

I'd like to do something like this:

(2002-11-15)-(2002-11-10)=5

or

(2002-12-10)-(2002-11-10)=20

Obviously taking into account number of days in a given month.


Does somebody have some code handy that does this?  Any help would be greatly 
appreciated!

Thanks.


-- 
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] dynamic variable headache

2002-11-08 Thread ROBERT MCPEAK
My newbie brain is maxed out on this, and I'm sure one of you more experience guys can 
quickly straighten me out.

I've got a variable:

$_mmdd =  a_date_value;

Later, I've got four variables;

$foo= _;
$bar=;
$bleh=mm;
$doh=dd;

I want to stick these variables together on the fly to get _mmdd  and use that 
value as a variable name to return a_date_value.

It would be the equivalent of,

echo $foo$bar$bleh$doh;

That would give me a_date_value

I've read the docs on dynamic variables but still can't seem to break through mentally 
on this one.  Can you clear this up for me?

Thanks in advance.



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




[PHP] publishing php mysql website on cd-rom

2002-11-06 Thread ROBERT MCPEAK
My organization has a need to publish some of our web content on a CD-ROM.  I'm in 
search of suggestions on how to publish our dynamic content (php/mysql templates) in 
some sort of runtime configuration that would let users browse the site from cd.

What's involved with this?  Is there such a thing as runtime mySQL?  What would it 
take to serve PHP from a CD?

Help!  I don't know where to begin and am looking for advice.

Thanks,

Bob 


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




Re: [PHP] publishing php mysql website on cd-rom

2002-11-06 Thread ROBERT MCPEAK
It's a database site, containing thousands of records, similar to a products catalog 
like Amazon, for example.  Publishing as static pages is not a viable option, and 
would greatly limit the search functionality.  

There must be a way to do this!  Thanks for all the feedback.

 Maxim Maletsky [EMAIL PROTECTED] 11/06/02 12:10PM 
Theoretically it is possible, but fact stays - you won't ever make it
work well.

So, try to find an alternative for this. Usually, this choice is made by
the managers that know nothing about how webcontent works.


--
Maxim Maletsky
[EMAIL PROTECTED] 



ROBERT MCPEAK [EMAIL PROTECTED] wrote... :

 My organization has a need to publish some of our web content on a CD-ROM.  I'm in 
search of suggestions on how to publish our dynamic content (php/mysql templates) in 
some sort of runtime configuration that would let users browse the site from cd.
 
 What's involved with this?  Is there such a thing as runtime mySQL?  What would it 
take to serve PHP from a CD?
 
 Help!  I don't know where to begin and am looking for advice.
 
 Thanks,
 
 Bob 
 
 
 -- 
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] randomly select file

2002-11-05 Thread ROBERT MCPEAK
Thanks guys  gals, for clueing me in.

 rija [EMAIL PROTECTED] 11/04/02 05:31PM 
Why don't you cope with opendir / readdir () and array_rand ()
I tried it and I look ok-

But, I wonder if there are noble another way to do it?


- Original Message -
From: ROBERT MCPEAK [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, November 05, 2002 8:40 AM
Subject: [PHP] randomly select file


Could someone suggest some php for randomly selecting a file from a
directory and then displaying the contents of the file?

Thanks in advance!


--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] session cache limiter

2002-11-05 Thread ROBERT MCPEAK
Could somebody shed some light on this error message I'm getting.  Could you point me 
at the appropriate docs or clue me in somehow.

PHP Warning:  Cannot send session cache limiter - headers already sent (output started 
at /usr/local/httpd/htdocs/mmc/results.php:79) in 
/usr/local/httpd/htdocs/mmc/includes/display_options.php on line 115

Thanks!


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




[PHP] randomly select file

2002-11-04 Thread ROBERT MCPEAK
Could someone suggest some php for randomly selecting a file from a directory and then 
displaying the contents of the file?

Thanks in advance!


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




[PHP] php mysql fulltext search min word length = 3

2002-09-27 Thread ROBERT MCPEAK

Much to my dismay, I've learned that the mySQL minimum
indexable/searchable word length is 3 characters.  This is a real
problem for me.  Anybody know a workaround, or how to tweak mySQL to
allow for matches of words 3 chars or less.

From the online mysql docs
(http://www.mysql.com/doc/en/Fulltext_Search.html) 

MySQL uses a very simple parser to split text into words. A ``word''
is any sequence of characters consisting of letters, numbers, `'', and
`_'. Any ``word'' that is present in the stopword list or is just too
short (3 characters or less) is ignored. 

Any thoughts, help would be terrific!  Thanks!

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




[PHP] replacing literal in string

2002-09-25 Thread ROBERT MCPEAK

Could somebody help me with the correct syntax for an ereg_replace to
replace literal occurences of the quote character in a string.  I can't
seem to get it right.

In other words, I have a form input variable -- that literally may look
like this:  some_value, and I want it to literally look like this:
some_value.

I tried:
$key=str_replace (\, , $key);
and other variations but can't get it to work.

What am I missing?

Thanks!

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




[PHP] replacing literal in string

2002-09-25 Thread ROBERT MCPEAK

Could somebody help me with the correct syntax for an ereg_replace to
replace literal occurences of the quote character in a string.  I can't
seem to get it right.

In other words, I have a form input variable -- that literally may look
like this:  some_value, and I want it to literally look like this:
some_value.

I tried:
$key=str_replace (\, , $key);
and other variations but can't get it to work.

What am I missing?

Thanks!

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




[PHP] random array sort

2002-09-10 Thread ROBERT MCPEAK

Could someone show me a quick and simple way to randomly sort array
elements?  I can't seem to pinpoint the correct parameters in the docs.

Thanks!

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




Re: [PHP] random array sort -- array() selection quant??

2002-09-10 Thread ROBERT MCPEAK

Thanks all for you submissions.  This is what I came up with, where
$this_key is a random selection from the array $the_exploded_ids.  I
don't know why, but,  array_rand() won't work with selection quanity
parameter of less than 2.  Anybody know why?

srand ((float) microtime() * 1000);
$input = $the_exploded_ids;
$rand_keys = array_rand ($the_exploded_ids, 2);
$this_key=$input[$rand_keys[0]];



$this_key=trim($this_key);

 ROBERT MCPEAK [EMAIL PROTECTED] 09/10/02 10:22AM 
Could someone show me a quick and simple way to randomly sort array
elements?  I can't seem to pinpoint the correct parameters in the
docs.

Thanks!

-- 
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] php mysql error

2002-09-04 Thread ROBERT MCPEAK

Our box recently went down and after reconfiguring it we're left with a
semi-operation mySQL.  One error I'm getting is this:

mysql select region from clip_art where region is not null and
released = 'yes' group by region;
ERROR 1: Can't create/write to file '/tmp/#sqld0e_76_1.MYI' (Errcode:
13)

Removing the group by clause prevents the error.

Can anybody tell me how to fix this?

Thank you.



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




[PHP] resizing an image

2002-08-29 Thread ROBERT MCPEAK

Could someone show me some php that proportionally resizes an image? 
I'm collecting user sumbitted images and need them all to be within
certain size constraints.  What's the simplest, best way to do this?

Sample code would be a huge help, as I'm a newbie and have not done
anything with PHP image processing functions.

Thanks!!

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




Re: [PHP] resizing an image

2002-08-29 Thread ROBERT MCPEAK

Sheesh, I will.  Thanks.

 Robert Cummings [EMAIL PROTECTED] 08/29/02 09:47AM

ROBERT MCPEAK wrote:
 
 Could someone show me some php that proportionally resizes an image?
 I'm collecting user sumbitted images and need them all to be within
 certain size constraints.  What's the simplest, best way to do this?
 
 Sample code would be a huge help, as I'm a newbie and have not done
 anything with PHP image processing functions.

*sheesh* read the first comment at:

http://www.php.net/manual/en/function.imagecopyresized.php 

-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
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] flaking out on foreach

2002-08-27 Thread ROBERT MCPEAK

Why is this code:

?php

$bob=array(1,2,3,5,6);

foreach($bob as $foo);
{
echo $fooBR;
}
?

Rendering only 6.  That's it.  Just 6.  What am I missing here?

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




[PHP] variables not behaving as expected

2002-08-19 Thread ROBERT MCPEAK

We've recently upgraded to PHP version 4.2.2 running on SuSE 7.2 with
the 2.4.4 kernel and I'm seeing variables behave in a way I didn't
expect.  With the prior configuration http post variables were freely
available on the receiving page, but now, for some reason, they aren't.
 
This code:

foreach ($_POST as $key = $post)
{
echo $key = $postBr;
$key = $post;   
}
echo hr;
echo do = $do;

renders this result:

do = addart
display_date = date
art_time = time
art_url = url
art_link = link
src_link = link
src_url = url

do = 


Why is the $do variable null outside of the for loop?  Shouldn't it
equal addart? Shouldn't it be available anywhere on the page?  With
the previous configuration the http post variables were available
anywhere on the page.  Is this a php configuration issue?

Thanks!





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




[PHP] php/mysql join query help

2002-05-23 Thread ROBERT MCPEAK

I have a table with a field key containing a unique value.  I have a
second table containing a field called keys containg a pipe-delimited
list of values from the key table.

I'd like to do a query that took each value from key, and matched it
agains the field keys in the second table, and returned a third table
of unique key values from the first table, and number of matches from
the second table.

I've already set up a full text index for the values in the second
table and have done successful matches in simpler queries.

Make sense?

The table I'd like to generate might look like this:

key matches
blue 50
yellow 6
green 29

This would indicate that there were 3 key values in the first table
(blue, yellow, green), and, respectively, there were 50, 6, and 20
matches for each term in the second table.

Can somebody help me do this?

Thanks!

-Bob

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




RE: [PHP] Leading zeroes

2002-05-23 Thread ROBERT MCPEAK

I'm a newbie, but maybe this'll do it:

if ($str!='0')
{
$str = ltrim($str, '0')
}

 Liam Gibbs [EMAIL PROTECTED] 05/23/02 01:49PM 
 From version 4.1.0, $str = ltrim($str, '0')

This works excellently. Thanks. One problem that I
didn't think of, though: If the number is 0 (only 0),
then the string ends up being empty. Is there a way
around that? I put an if statement in saying if the
string is empty, then the string is 0. Any better way?

__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.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] php/mysql join query help

2002-05-23 Thread ROBERT MCPEAK

I appreciate you help.  I inherited the pipe-delimited data.  I would
have done it as you suggested.

Thanks.

-Bob

 1LT John W. Holmes [EMAIL PROTECTED] 05/23/02 01:57PM

It's generally a bad idea to store delimited data in a single column in
a
database. It kind of goes against what a database is there for. A
better
layout would be to have your second table contain a row for each of
the
delimited values.

So if you have '1,2,3,4' in your database now, the better way would be
to
have four rows, 1 through 4 in the table instead, with whatever other
info
you keep for each row. Then a simple SELECT var, COUNT(var) FROM table
will
give you the answers you're looking for.

but...if you want to leave it the way it is, then you can use some kind
of
matching to find the rows using LIKE. I couldn't get a query to work,
though. If your data can be seperated by commas, an easy way to do it
is
with something like this

SELECT table1.key, COUNT(*) FROM table1, table2 WHERE
FIND_IN_SET(table1.key,table2.keys) GROUP BY table1.key

But, the flaw of that is that it'll only count one occurance of
table1.key
per row in table2. If a row has 'blue' twice, only one will be
counted.

---John Holmes...

- Original Message -
From: ROBERT MCPEAK [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, May 23, 2002 1:22 PM
Subject: [PHP] php/mysql join query help


 I have a table with a field key containing a unique value.  I have
a
 second table containing a field called keys containg a
pipe-delimited
 list of values from the key table.

 I'd like to do a query that took each value from key, and matched it
 agains the field keys in the second table, and returned a third
table
 of unique key values from the first table, and number of matches
from
 the second table.

 I've already set up a full text index for the values in the second
 table and have done successful matches in simpler queries.

 Make sense?

 The table I'd like to generate might look like this:

 key matches
 blue 50
 yellow 6
 green 29

 This would indicate that there were 3 key values in the first table
 (blue, yellow, green), and, respectively, there were 50, 6, and 20
 matches for each term in the second table.

 Can somebody help me do this?

 Thanks!

 -Bob

 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] newbie: dynamically building associative arrays

2002-05-15 Thread ROBERT MCPEAK

I'm trying to build what I think is an associative array from a set of
mySQL results.

It looks like this:

//First, a mySQL results loop for a select statement return unique
occurrences of data in the field term:

for ($i=0; $i $num_results; $i++)
 {
 $row = mysql_fetch_array($result);

echo $row[term];

//Then, within the loop, another search to find the number of
occurrences //of that result

$this_term[$i]=$row[term];
$this_query = select term from photoqueries where term = '$this_term'
order by term;
$this_result = mysql_query($this_query);
$this_num_results[$i] = mysql_num_rows($this_result);

}

//so, now I have 2 vars corresponding to each term value from the
table:  $this_term[i], and $this_num_results[i].  

That's where I get stuck!  How do I stick all of my $this_term and
$this_num_results values together in an array.  Once that is
accomplished, how do I then sort the array (descending) by the
$this_num_results values?

In short, what I'm trying to do is display a list of all term values
and the number of times that data appears in the table.  If I had a
table names containg these values:

bob
bob
joe
sue
fred
bob
sue
jane

The display I'm trying to build would look like this:

bob 3
sue 2
jane 1
joe 1

Any help is greatly appreciated, sincerely!

Thanks!



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




[PHP] date(), strtotime(), Wed, Dec 31, 1969 ??

2002-05-03 Thread ROBERT MCPEAK

Running PHP3 on a Linux box and I've got trouble with date().

Here's the code:

$blah=2002-05-02;
$thedate = date(D, M d, Y, strtotime($blah)); 
$echo $thedate;


Why is $thedate resolving to Wed, Dec 31, 1969.

Thanks!

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




[PHP] date wierdness

2002-05-03 Thread ROBERT MCPEAK

On PHP3 where $row[art_date] == 2002-05-03, 
$thedate resolves to Thurs, May 2, 2002  

YESTERDAYS DATE!

See for yourself, if you wish, here:
http://www.endvaw.org/current.php3

What gives.

$row = mysql_fetch_array($result);
$blah = eregi_replace(-, /, $row[art_date]); 
$thedate = date(D, M d, Y, strtotime($blah)); 

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




[PHP] basename unix/windows

2002-04-25 Thread ROBERT MCPEAK

I'm running php on linux and wish to use basename() to get the file name
from a windows path.

basename() on our linux/php box can't seem to cope with the use of
backslash (\) in the Windows paths I'm feeding it. 

In other words:

basename(/usr/blah/doh/yuck/wow/abigfile.html)

resolves to : abigfile.html

but 

basename(adirectory\onawindowsbox\abigfile.html)

does not resovle to abigfile.html.

Does anybody have a workaround for this?

Thanks!

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




[PHP] newbie: string manipulation

2002-04-24 Thread ROBERT MCPEAK

I need code that grabs the file at the end of a file path.
I have this:

/usr/blah/doh/yuck/wow/abigfile.html

And would like to return this:

abigfile.html

Could somebody show me how to do this?

Thank you!

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




[PHP] php permissions

2002-04-19 Thread ROBERT MCPEAK

php is running on our box  as nobody:nogroup.  I'm trying to write php
code that will edit/delete files uploaded to the server by other users,
and, obviously, I get a permissions error.

My sysadmin is hesitant to give php more access until I do some
research about the security issues involved, and I am a relative newbie
and I'm not sure what the issues are or how to find out more about
them.

How do I give php permissions to delete files etc., without opening up
an security hole?  Is this an issue at all?

Help!

Thanks!

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




Re: [PHP] php permissions

2002-04-19 Thread ROBERT MCPEAK

How?  Manually each time a file is uploaded?  Or with PHP somehow?

I appreciate your response, but perhaps I'm not clear enough.

Isn't it quite common to have php creating/editing/deleting files on
the server?  How is this done in a secure manner?

Could you explain further?

Thanks.

 Dave Raven [EMAIL PROTECTED] 04/19/02 01:55PM 
chown them to nobody.


- Original Message - 
From: ROBERT MCPEAK [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 19, 2002 7:53 PM
Subject: [PHP] php permissions


 php is running on our box  as nobody:nogroup.  I'm trying to write
php
 code that will edit/delete files uploaded to the server by other
users,
 and, obviously, I get a permissions error.
 
 My sysadmin is hesitant to give php more access until I do some
 research about the security issues involved, and I am a relative
newbie
 and I'm not sure what the issues are or how to find out more about
 them.
 
 How do I give php permissions to delete files etc., without opening
up
 an security hole?  Is this an issue at all?
 
 Help!
 
 Thanks!
 
 -- 
 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] php permissions

2002-04-19 Thread ROBERT MCPEAK

Craig, you seem very knowledgable and I appreciate your help.  I
confused matters by mentioning the word upload.  I'm actually not
using php to upload the files.  The user ftps the files to the server,
and the ownership permissions prevent php from manipulating the files.

I'm looking for a clear answer on whether giving php permission, or
setting the directory to nobody:nogroup, or whatever, poses a security
threat.

How can php be used to edit/delete files without opening a security
hole?

Bear with me, I think Im getting clearer.

 Craig Vincent [EMAIL PROTECTED] 04/19/02 03:07PM 
 How?  Manually each time a file is uploaded?  Or with PHP somehow?

 I appreciate your response, but perhaps I'm not clear enough.

 Isn't it quite common to have php creating/editing/deleting files on
 the server?  How is this done in a secure manner?

 Could you explain further?

Well technically unless your admin is using the latest PHP updates,
the
server is already open to known exploits (albeit most are pretty
difficult
to recreate).  Your admin is probably panicing as many others did when
the
exploits were announced they were mentioned as problems in the file
upload
routineshowever most people don't realize that these exploits were
usable whether file uploading was used or not.

In answer to your question the file upload system is fairly secure but
you
should never rely on it alone.  When it initially uploads the file, the
file
is stored as a temporary name (so there's no way to execute code with
a
screwy filename).  And although it shouldn't be an issue regardless, as
long
as you remove any fancy characters from the true filename before you
store
it in another area (anything not alphanumeric or a .) you should have
no
problems whatsoever.

However as was mentioned before, assuming someone did manage to use the
file
upload system ...the worst damage one could do to a system would be to
erase/modify files associated with the webserver username (or files
with
open permissions)...so really worse case scenario if your admin has
done his
job properly is one could manage to erase all the other php uploaded
files
if they found an exploit.

Sincerely,

Craig Vincent



-- 
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] email attachments

2002-04-16 Thread ROBERT MCPEAK

This nifty code (taken from PHP Cookbook) sends an email with a file
attached in-line.  The text from the attached file appears within the
body of the email.  I need to send attached files that are not in-line,
but, rather, come as attached files that the user views outside of their
email browser.  Can somebody help me with this.  Maybe tweak the code
I've got?

Thanks!

//attachment
$to = $the_email;
$subject = 'dump';
$message = 'this is the dump';
$email = '[EMAIL PROTECTED]';

$boundary =b . md5(uniqid(time()));
$mime = Content-type: multipart/mixed; ;
$mime .= boundary = $boundary\r\n\r\n;
$mime .= This is a MIME encoded
message.\r\n\r\n;
//first reg message
$mime_message .=--$boundary\r\n;
$mime .=Content-type: text/plain\r\n;
$mime .=Content-Transfer-Encoding: base64;
$mime .=\r\n\r\n .
chunk_split(base64_encode($message)) . \r\n;
//now attach
$filename = mysqldump/surveydump.txt;
$attach = chunk_split(base64_encode(implode(,
file($filename;
$mime .=--$boundary\r\n;
$mime .=Content-type: text/plain\r\n;
$mime .=Content-Transfer-Encoding: base64;
$mime .=\r\n\r\n$attach\r\n;






mail($to,
$subject,
,
$mime);



//attachment



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




RE: [PHP] email attachments

2002-04-16 Thread ROBERT MCPEAK

I wish that made sense to me.  Can you expound?

 James E. Hicks III [EMAIL PROTECTED] 04/16/02 09:41AM 
You need a Content-Disposition in yer $mime variable. I'll leave it up
to you to
figure out where, because I've forgotten where it goes exactly.

James


-Original Message-
From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, April 16, 2002 8:46 AM
To: [EMAIL PROTECTED] 
Subject: [PHP] email attachments


This nifty code (taken from PHP Cookbook) sends an email with a file
attached in-line.  The text from the attached file appears within
the
body of the email.  I need to send attached files that are not
in-line,
but, rather, come as attached files that the user views outside of
their
email browser.  Can somebody help me with this.  Maybe tweak the code
I've got?

Thanks!

//attachment
$to = $the_email;
$subject = 'dump';
$message = 'this is the dump';
$email = '[EMAIL PROTECTED]';

$boundary =b . md5(uniqid(time()));
$mime = Content-type: multipart/mixed; ;
$mime .= boundary = $boundary\r\n\r\n;
$mime .= This is a MIME encoded
message.\r\n\r\n;
//first reg message
$mime_message .=--$boundary\r\n;
$mime .=Content-type: text/plain\r\n;
$mime .=Content-Transfer-Encoding: base64;
$mime .=\r\n\r\n .
chunk_split(base64_encode($message)) . \r\n;
//now attach
$filename = mysqldump/surveydump.txt;
$attach = chunk_split(base64_encode(implode(,
file($filename;
$mime .=--$boundary\r\n;
$mime .=Content-type: text/plain\r\n;
$mime .=Content-Transfer-Encoding: base64;
$mime .=\r\n\r\n$attach\r\n;






mail($to,
$subject,
,
$mime);



//attachment



--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] formatting form input/sql insert

2002-04-16 Thread ROBERT MCPEAK

I'm collecting data with from textarea inputs.  The user may enter a
linebreak with the return key, or a tab, etc.  I then write this data to
a mySQL table, formatting the data with addslashes().

I then output the data to a text file using a select into file
statement.  When I import the file into excel, or view it with an
editor, the user entered tabs  linebreaks are being interpreted as
field separators and record separators.

How do I format the input to solve this problem?

Thanks!

-Bob

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




[PHP] formatting form input

2002-04-16 Thread ROBERT MCPEAK

How do I use PHP to remove certain characters from form input? 
Specifically, how to I ensure that form data does not contain any
newline/linebreak or tab characters?

Thanks!



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




[PHP] attachment filename

2002-04-16 Thread ROBERT MCPEAK

The code below very nicely sends an email attachment, but, the name of
the attachment appears as Part.000, not the original filename of the
attached file.

How do I set the filename of the attachment?  I'd like it to be
something nice, like yourfileattachment.txt or something, not
Part.000.  What is Part.000 anyway?

Stumped!

Help!

Thanks!

Code:

//attachment
$to = $the_email;
$subject = 'dump';
$message = 'this is the dump';
$email = '[EMAIL PROTECTED]';

$boundary =b . md5(uniqid(time()));
$mime = Content-type: multipart/mixed; ;
$mime .= boundary = $boundary\r\n\r\n;
$mime .= This is a MIME encoded
message.\r\n\r\n;
//first reg message
$mime_message .=--$boundary\r\n;
$mime .=Content-type: text/plain\r\n;
$mime .=Content-Transfer-Encoding: base64;
$mime .=\r\n\r\n .
chunk_split(base64_encode($message)) . \r\n;



//now attach
$filename = mysqldump/surveydump.dmp;
$attach = chunk_split(base64_encode(implode(,
file($filename;
$mime .=--$boundary\r\n;
$mime .=Content-type:
application/octet-stream;\r\n;
$mime .=Content-Disposition: attachment\r\n;
$mime .=Content-Transfer-Encoding: base64;
$mime .=\r\n\r\n$attach\r\n;






mail($to,
$subject,
,
$mime);



//attachment




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




[PHP] newbie: unix/php/mySQL permissions

2002-04-15 Thread ROBERT MCPEAK

I'm very new to php  mySQL and need some help understanding how I
should set up my Unix permissions.  

I would like to run php code that could delete/create/edit existing
files.  I've tried to issue the load data infile statement from the
command line but mySQL gives me a permissions error.

How can I setup unix/apache/php/mySQL to allow for creation/deletion of
files, but still be relatively secure against malicious code?

Is there a permissions primer out there that could help this Newbie get
familiar with how this all works?

Thanks!

-Bob

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




[PHP] newbie: unix/php/mySQL permissions

2002-04-15 Thread ROBERT MCPEAK

I'm very new to php  mySQL and need some help understanding how I
should set up my Unix permissions.  

I would like to run php code that could delete/create/edit existing
files.  I've tried to issue the load data infile statement from the
command line but mySQL gives me a permissions error.

How can I setup unix/apache/php/mySQL to allow for creation/deletion of
files, but still be relatively secure against malicious code?

Is there a permissions primer out there that could help this Newbie get
familiar with how this all works?

Thanks!

-Bob

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




[PHP] newbie: unix/php/mySQL permissions

2002-04-15 Thread ROBERT MCPEAK

I'm very new to php  mySQL and need some help understanding how I
should set up my Unix permissions.  

I would like to run php code that could delete/create/edit existing
files.  I've tried to issue the load data infile statement from the
command line but mySQL gives me a permissions error.

How can I setup unix/apache/php/mySQL to allow for creation/deletion of
files, but still be relatively secure against malicious code?

Is there a permissions primer out there that could help this Newbie get
familiar with how this all works?

Thanks!

-Bob


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




Re: [PHP] PHP Training is New York

2002-04-12 Thread ROBERT MCPEAK


Can't make it to this one but would like to know of any other training
opps in the Balt-Wash-Phil-NY areas.  Anybody know of a good source for
this info?


 Daniel Kushner [EMAIL PROTECTED] 04/12/02 10:48AM 
LAST DAY TO REGISTER

http://websapp.com/training.php 

--Daniel


-- 
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] newbie html forms primer help

2002-04-10 Thread ROBERT MCPEAK

I need some help with html forms.  I primer on html forms and variables
is much needed.  Anybody have some code snipets to share?  

I'm getting acquainted with $HTTP_POST_VARS but need some help in
accomplishing a couple of things.

I'd like to collect all checkbox input variables and stick them
together in a comma delimited string.

I'd also like to display the names and values of the all posted
variables.

In another language I'm familiar with, this looks like:

[formvariables name=thevarname][name]=[value]BR[/formvariables]

For passed checkbox input var doh, where values were blah and bleck,
the above code would display:

doh=blah
doh=bleck

How do I do this with php?

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




[PHP] mySQL join query error

2002-04-04 Thread ROBERT MCPEAK

I get an error with the follow query. There is a field user in both
tables, tifrequest  tifexpire.  Can anybody see what's wrong with it? 
Thanks.

SELECT * FROM tifrequest LEFT JOIN USING(user) WHERE tifexpire.exp_date
=2002-04-04



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




[PHP] syntax for date math expressions

2002-04-03 Thread ROBERT MCPEAK

What is the php syntax for adding or subtracting dates?

For example, I'd like to do something like this:

2002-04-03 - 2002-04-02 = 1

or 

2002-04-03 - 2002-04-02 = -00-01

or 

2002-04-03 + -00-01 = 2002-04-03

etc.

Can anybody help this newbie?

Thanks!



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




[PHP] Re: syntax for date math expressions

2002-04-03 Thread ROBERT MCPEAK

Okay, I've got 2 tables.  One has fields user, exp_date, the other has a
bunch of fields including user.  If the exp_date from the first table is
greater than $somedate (probably today's date), then I don't want to
show the records from the 2nd table.  Get it?

So how do I do this?

It doesn't seem apparently obvious to me how to do it in a single, or
multiple sql queries.

Thanks.

 Maxim Maletsky [EMAIL PROTECTED] 04/03/02 12:51PM


first of all your data seems to come from a DB to me. If it's so then
read 
your DB manual for date functions. It would be way better and faster. 

Otherwise, if you're so keen to let this duty job up to PHP then
convert 
both dates into UNIX time format 'maketime()' deduct the values and put
them 
through the 'date()' function. 

 


Maxim Maletsky 

Founder, Chief Developer
PHPBeginner.com (Where PHP Begins) 

www.PHPBeginner.com 
[EMAIL PROTECTED] 

 


ROBERT MCPEAK writes: 

 What is the php syntax for adding or subtracting dates? 
 
 For example, I'd like to do something like this: 
 
 2002-04-03 - 2002-04-02 = 1 
 
 or  
 
 2002-04-03 - 2002-04-02 = -00-01 
 
 or  
 
 2002-04-03 + -00-01 = 2002-04-03 
 
 etc. 
 
 Can anybody help this newbie? 
 
 Thanks! 
 
  
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php 
 
 


Maxim Maletsky 

Founder, Chief Developer
PHPBeginner.com (Where PHP Begins) 

www.PHPBeginner.com 
[EMAIL PROTECTED] 

-- 
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] date expressions

2002-04-02 Thread ROBERT MCPEAK

How do I compare a date (2002-05-01) against a date plus 5 days?  I need
help figuring out how to do math operations on dates, etc.  Could
somebody fill this newbie in?

Thanks!



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




[PHP] parse error, mysql select

2002-04-01 Thread ROBERT MCPEAK

When I execute from browser I get a parse error, but when I enter the
query directly into a MySQL command prompt I get a successful return. 
Can anybody see the problem with this code:

$query = SELECT DATE_FORMAT( exp_date, %W, %M
%d, %Y) AS thedate from tifrequest where user='$user' limit 1,1;


Thanks!  My eyes are shot!


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




RE: [PHP] parse error, mysql select

2002-04-01 Thread ROBERT MCPEAK

Ack!  Thanks.

 Rick Emery [EMAIL PROTECTED] 04/01/02 02:59PM 
$query = SELECT DATE_FORMAT( exp_date, \%W, %M %d, %Y\) AS thedate
from
tifrequest where user='$user' limit 1,1;

Missing escape \ in front of quotes

-Original Message-
From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] 
Sent: Monday, April 01, 2002 1:55 PM
To: [EMAIL PROTECTED] 
Subject: [PHP] parse error, mysql select


When I execute from browser I get a parse error, but when I enter the
query directly into a MySQL command prompt I get a successful return. 
Can anybody see the problem with this code:

$query = SELECT DATE_FORMAT( exp_date, %W, %M
%d, %Y) AS thedate from tifrequest where user='$user' limit 1,1;


Thanks!  My eyes are shot!


-- 
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] date comparison expressions

2002-04-01 Thread ROBERT MCPEAK

I'd like to compare today's date against a stored date, and then fire
some code based on the result.

Like.

if ($today's_date  stored_date+5 days)

then {blah}

Can somebody clue this newbie in on how to do this?

-Bob

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




[PHP] newbyie - date conversion to human readable form

2002-03-25 Thread ROBERT MCPEAK

I've dug around for a while but I can't find a direct answer on how to
convert a date in this format: 2002-03-25 to a human readable format
such as  March 25, 2002, or even better, Monday, March 25, 2002.

Can anybody help me with this, or point me to some clear directions on
how to do this?

Thanks!

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




RE: [PHP] newbyie - date conversion to human readableform-CORRECTION

2002-03-25 Thread ROBERT MCPEAK



 Rick Emery [EMAIL PROTECTED] 03/25/02 11:04AM 
CORRECTION:
SELECT DATE_FORMAT( mydate, %W, %M %d, %Y) AS thedate FROM mytable;

-Original Message-
From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] 
Sent: Monday, March 25, 2002 9:58 AM
To: [EMAIL PROTECTED] 
Subject: RE: [PHP] newbyie - date conversion to human readable form


This mysql syntax generates an error message.  Can you see what's
wrong
with it?

 Rick Emery [EMAIL PROTECTED] 03/25/02 10:00AM 
In PHP, you look at the date() function.

If retrieving this from a mysql database, mysql will do it for you:
SELECT DATE( mydate, %W, %M %d, %Y) AS thedate FROM mytable;


-Original Message-
From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] 
Sent: Monday, March 25, 2002 8:55 AM
To: [EMAIL PROTECTED] 
Subject: [PHP] newbyie - date conversion to human readable form


I've dug around for a while but I can't find a direct answer on how to
convert a date in this format: 2002-03-25 to a human readable format
such as  March 25, 2002, or even better, Monday, March 25, 2002.

Can anybody help me with this, or point me to some clear directions on
how to do this?

Thanks!

-- 
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] testing for blank var

2002-03-21 Thread ROBERT MCPEAK

if $img_url has a value, then I'd like to show the image, if it doesn't,
then I'd like to show a message.  What's wrong with my code?  Am I
incorrectly testing for the value?  The else works fine, but not the if.
 Thanks!

if (!$img_url)
{
echo bNo Image URL Entered/bbr;
}
else
{
echo img src=\$img_url\;
}


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




RE: [PHP] testing for blank var

2002-03-21 Thread ROBERT MCPEAK

Beautiful!

 Rick Emery [EMAIL PROTECTED] 03/21/02 09:19AM 
if ( ! ISSET($img_url) )


-Original Message-
From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, March 21, 2002 8:18 AM
To: [EMAIL PROTECTED] 
Subject: [PHP] testing for blank var


if $img_url has a value, then I'd like to show the image, if it
doesn't,
then I'd like to show a message.  What's wrong with my code?  Am I
incorrectly testing for the value?  The else works fine, but not the
if.
 Thanks!

if (!$img_url)
{
echo bNo Image URL Entered/bbr;
}
else
{
echo img src=\$img_url\;
}


-- 
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] new to php/mysql - insert not working

2002-03-20 Thread ROBERT MCPEAK

Can somebody help me with this?

The following code gets me document contains no data.  I have done a
successfull select from mysql db, but not an insertion.

I don't know how to troubleshoot this.  Any help is much appreciated. 
Thanks!

?php


$id = addslashes($id);
$visitdate = addslashes($visitdate);
$img_group = addslashes($img_group);
$img_url = addslashes($img_url);
$display = addslashes($display);



 $db = mysql_connect(www, mmc, mmc-WWW);

  if (!$db)
  {
 echo Error: Could not connect to database.  Please try again
later.;
 exit;
  }

  mysql_select_db(mmc);
  $query = insert into visitorgallery values
('.$id.', '.$img_url.', '.$visitdate.',
'.$img_group.', '.$display.', );


 
  $result = mysql_query($query);
  if ($result)
echo mysql_affected_rows(). Image inserted! ;



?

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




[PHP] mysql update help needed

2002-03-20 Thread ROBERT MCPEAK

Can somebody straighten this out for me?

I can't get the update to work.  I'm sure the variables are being
passed to the code.  Thanks!

if ($postaction==edit)

{
echo it firedBr;
// process form

$db = mysql_connect(myhost, myuname,
mypword);

 mysql_select_db(mydb);

$sql = UPDATE mytable SET
img_url=$img_url,visitdate=$visitdate,img_group=$img_group,display=$display,
caption=$caption where id = $id;

$result = mysql_query($sql);

echo center;
echo Thank you! Information entered.\n;
echo /center;

}

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




[PHP] html form select list selected

2002-03-20 Thread ROBERT MCPEAK

I'd like to determine the selected option in a select list based on a
passed variable.  The code below won't work, but I can't figure out why.
 Any guesses?


echo form;
echo select name=\display\;
echo option value=\true\;
if ($display==false){echo selected;}
echo Display;
echo option value=\false\;
if ($display==false){echo selected;}
echo selectedDon't Display;
echo /select;
echo /form;


Thanks!

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




[PHP] Fwd: html form select list selected

2002-03-20 Thread ROBERT MCPEAK

Whoops!  Still won't work but that code should read:

echo form;
echo select name=\display\;
echo option value=\true\;
if ($display==true){echo selected;}
echo Display;
echo option value=\false\;
if ($display==false){echo selected;}
echo selectedDon't Display;
echo /select;
echo /form;

 ROBERT MCPEAK 03/20/02 04:20PM 
I'd like to determine the selected option in a select list based on a
passed variable.  The code below won't work, but I can't figure out why.
 Any guesses?


echo form;
echo select name=\display\;
echo option value=\true\;
if ($display==false){echo selected;}
echo Display;
echo option value=\false\;
if ($display==false){echo selected;}
echo selectedDon't Display;
echo /select;
echo /form;


Thanks!

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




RE: [PHP] Fwd: html form select list selected

2002-03-20 Thread ROBERT MCPEAK


Still doesn't work.  What gives?

 Kevin Stone [EMAIL PROTECTED] 03/20/02 04:31PM 
The contents of $display are a string so you must have quotes
aroud it in the comparison statement.

if ($display == 'false') // should work.

Alternatively you could do.

select name=display
option value=0True
option value=1False
/select

Now the contents of $display is an integer which will can be
interpreted
as a boolean value (true or false).  Then you can compare it like you
had.

if ($display == false)

-Kevin


-Original Message-
From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, March 20, 2002 2:24 PM
To: [EMAIL PROTECTED] 
Subject: [PHP] Fwd: html form select list selected

Whoops!  Still won't work but that code should read:

echo form;
echo select name=\display\;
echo option value=\true\;
if ($display==true){echo selected;}
echo Display;
echo option value=\false\;
if ($display==false){echo selected;}
echo selectedDon't Display;
echo /select;
echo /form;

 ROBERT MCPEAK 03/20/02 04:20PM 
I'd like to determine the selected option in a select list based on a
passed variable.  The code below won't work, but I can't figure out
why.
 Any guesses?


echo form;
echo select name=\display\;
echo option value=\true\;
if ($display==false){echo selected;}
echo Display;
echo option value=\false\;
if ($display==false){echo selected;}
echo selectedDon't Display;
echo /select;
echo /form;


Thanks!

-- 
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] broken select solution

2002-03-20 Thread ROBERT MCPEAK

got it:

?php   
echo $displayBr;
echo form;

echo select
name=\display\;
echo option
value=\true\;
if ($display ==
'true'){echo  selected;}
echo Display;
echo option
value=\false\;
if ($display ==
'false'){echo  selected;}
echo Don't Display;


echo /select;

echo /form;

?

 ROBERT MCPEAK [EMAIL PROTECTED] 03/20/02 04:39PM 

Still doesn't work.  What gives?

 Kevin Stone [EMAIL PROTECTED] 03/20/02 04:31PM 
The contents of $display are a string so you must have quotes
aroud it in the comparison statement.

if ($display == 'false') // should work.

Alternatively you could do.

select name=display
option value=0True
option value=1False
/select

Now the contents of $display is an integer which will can be
interpreted
as a boolean value (true or false).  Then you can compare it like you
had.

if ($display == false)

-Kevin


-Original Message-
From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, March 20, 2002 2:24 PM
To: [EMAIL PROTECTED] 
Subject: [PHP] Fwd: html form select list selected

Whoops!  Still won't work but that code should read:

echo form;
echo select name=\display\;
echo option value=\true\;
if ($display==true){echo selected;}
echo Display;
echo option value=\false\;
if ($display==false){echo selected;}
echo selectedDon't Display;
echo /select;
echo /form;

 ROBERT MCPEAK 03/20/02 04:20PM 
I'd like to determine the selected option in a select list based on a
passed variable.  The code below won't work, but I can't figure out
why.
 Any guesses?


echo form;
echo select name=\display\;
echo option value=\true\;
if ($display==false){echo selected;}
echo Display;
echo option value=\false\;
if ($display==false){echo selected;}
echo selectedDon't Display;
echo /select;
echo /form;


Thanks!

-- 
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 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