[PHP] newbie question about code

2010-09-10 Thread Adam Williams
I'm looking at someone's code to learn and I'm relatively new to 
programming.  In the code I see commands like:


$code-do_command();

I'm not really sure what that means.  How would that look in procedural 
style programming?  do_command($code); or something else?



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



[PHP] stripping first comma off and everything after

2010-06-18 Thread Adam Williams
I'm querying data and have results such as a variable named 
$entries[$i][dn]:


CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx 



Basically I need to strip off the first command everything after, so 
that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92.


I tried echo rtrim($entries[$i][dn],,); but that doesn't do 
anything.  Any ideas?



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



[PHP] html email showing br instead of line breaks

2009-09-24 Thread Adam Williams
I have users enter support tickets into a a textarea form and then it 
emails it to me, I'm trying to get the emails to display when they hit 
enter correctly, so i'm changing the \r\n to br, but in the email i'm 
getting, its displaying the br instead of a line break:  here is the code:


$message = htmlheadtitlenew support request 
#.mysqli_insert_id($mysqli)./title/headbodyp
Hello, .$_SESSION[full_name]. has created a  new support request.  
Please log in at a href=\http://intra/helpdesk\;MDAH Helpdesk/a. 
The problem request is \;
$message .= htmlspecialchars(str_replace('\r\n', 'br', 
$_POST[problem]));
$message .= \ and the best time to contact is 
\.htmlspecialchars($_POST[contact_time]).\ /p/body/html;

   $headers  = 'MIME-Version: 1.0' . \r\n;
   $headers .= 'Content-type: text/html; 
charset=iso-8859-1' . \r\n;
   $headers .= From: 
.$_SESSION[full_name]..$_SESSION[username].@mdah.state.ms.us 
.\r\n .

   X-Mailer: PHP/ . phpversion();
  mail('isst...@mdah.state.ms.us', $subject, $message, 
$headers);


but the email I get is:

Hello, Karen Redhead has created a new support request. Please log in at 
MDAH Helpdesk http://intra/helpdesk. The problem request is Elaine is 
out today but her computer no longer has Past Perfect from what I can 
tell. Also how does she access her email. The Sea Monkey email icon does 
not take you anywhere.brThanks so much,brKaren and the best time to 
contact is 1:30 -5:00



How come the email is being displayed with br instead of line breaks?



Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Adam Williams
Thanks, i'll try that.  what is the difference in using '' and ?  I 
thought they were interchangeable.


Jonathan Tapicer wrote:

\r\n should be between double quotes: \r\n

  



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



Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Adam Williams
oh nevermind, i see double quotes translate the \r\n to its appropriate 
EOL character.


Adam Williams wrote:
Thanks, i'll try that.  what is the difference in using '' and ?  I 
thought they were interchangeable.


Jonathan Tapicer wrote:

\r\n should be between double quotes: \r\n

  






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



[PHP] running php script as a user?

2009-07-15 Thread Adam Williams
I have a page where a user authenticates, fills in some information in 
an HTML form, and then when clicking on the submit button, will need to 
execute a php schell script as that user to write some data to their 
/home/username directory.  Since apache web server runs as the user 
nobody, how will I have that script execute as that user so that it can 
write data to their home directory?



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



[PHP] fixing new lines from textarea in an email?

2009-06-26 Thread Adam Williams
I have staff fill out a form that contains a textarea with their 
problem description and emailed to me when they click submit.  Staff 
will press enter in the text area, but I'm having problems converting 
the \r\n into a new line in the email that is sent to me, here is the code:


$subject = new support request #.mysqli_insert_id($mysqli);
$message = Hello, .$_SESSION[full_name]. has created a new support 
request.  Please log in at a href=\http://intra/helpdesk\;MDAH 
Helpdesk/a.  The problem request is 
\.htmlspecialchars(nl2br(str_replace('\r','',$_POST[problem]))).\. 
and the best time to contact is 
\.htmlspecialchars($_POST[contact_time]).\.;

$headers  = 'MIME-Version: 1.0' . \r\n;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n;
$headers .= From: 
.$_SESSION[full_name]..$_SESSION[username].@mdah.state.ms.us 
.\r\n .X-Mailer: PHP/ . phpversion();

mail('awill...@mdah.state.ms.us', $subject, $message, $headers);

and here is an example email, notice the \n is still in the body of the 
email, and it needs to be converted to a new line in the email:


Hello, Gwendolyn Jones has created a new support request. Please log in 
at MDAH Helpdesk http://intra/helpdesk. The problem request is 1 of 2 
questions: I'm having trouble opening files from Jennifer, Susie, and 
Bill because they are working with a higher version of microsoft office. 
My version is 2003. Is there any way I could get an update on this?\n2 
of 2 questions: I need permission to download a plug-in for the NPS site 
where I research NR properties.\nNeither of these questions/issues are 
urgent. Thanks. -Gwen. and the best time to contact is Any time, phone 
# is cell.


why isn't nl2br converting the \n to br in the email?



Re: [PHP] fixing new lines from textarea in an email?

2009-06-26 Thread Adam Williams



Daniel Brown wrote:

In a cursory glance, I've noticed the following code:

htmlspecialchars(nl2br(str_replace('\r','',$_POST[problem])))

You are using a literal '\r' in your str_replace() function.  This
should instead be replaced with double quotes to translate the \r to
its appropriate EOL character:

htmlspecialchars(nl2br(str_replace(\r,'',$_POST[problem])))

  


Thanks, I didn't know that single vs double quotes in that instance made 
a difference.  I've made the change to my code.



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



[PHP] graphical integrated development environment recommendations?

2009-05-01 Thread Adam Williams
With the wide range of users on the list, I'm sure there are plenty of 
opinions on what are good graphical IDE's and which ones to avoid.  I'd 
like to get away from using notepad.exe to code with due to its 
limitations.  Something that supports syntax/code highlighting and has 
browser previews would be nice features.  I'm looking at Aptana 
(www.aptana.com) but it seems like it is more complicated to use then it 
should be.  Either Linux or Windows IDE (i run both OSes) 
recommendations would be fine.



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



[PHP] help with explode()

2009-04-24 Thread Adam Williams
I have a form where users submit search terms and it explodes the terms 
into an array based upon spaces.  But, how can I have explode() keep 
words in quotation marks together?  For example, if someone enters on 
the form:


John Jill Judy Smith

and I run $termsarray = explode( , $_POST[terms]);

it explodes into:

Array ( [0] = John [1] = Jill [2] = Judy [3] = Smith )

but I'd like it to explode into:

Array ( [0] = John [1] = Jill [2] = Judy Smith )


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



Re: [PHP] help with explode()

2009-04-24 Thread Adam Williams



Jan G.B. wrote:

You could try it with regular expression matching..
for example:
?php
preg_match_all('/([a-z]+|[a-z ]+)/i', $searchstring, $resultarray);
?


Regards
  


Thanks.  That seems to create 2 duplicate arrays, though.  Can it be 
narrowed down to just array [0]?


preg_match_all('/([a-z]+|[a-z ]+)/i', $_POST[terms], $termsarray);
echo $_POST[terms].br;
print_r($termsarray);

displays:

John Jill Judy Smith
Array ( [0] = Array ( [0] = John [1] = Jill [2] = Judy Smith ) [1] 
= Array ( [0] = John [1] = Jill [2] = Judy Smith ) )



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



Re: [PHP] help with explode()

2009-04-24 Thread Adam Williams



Jan G.B. wrote:

Yes, preg_match_all returns all matches and the subpattern matches
(the stuff inside the brakes)
You can ommit stop it by using (?:) instead of ()..
So: preg_match_all('/(?:[a-z]+|[a-z ]+)/i', $_POST[terms], $termsarray)

You might want to check out the regular expression manuals on
http://www.php.net/manual/en/book.pcre.php

regards
  


Thanks, you've been a big help, that works great!


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



Re: [PHP] I need ideas for things to code

2009-04-24 Thread Adam Williams

Andrew Hucks wrote:

I've been coding PHP for about a year, and I'm running out of things to code
that force me to learn new things. If you have any suggestions, I'd greatly
appreciate it.

  


I'm currently writing an in-house PHP helpdesk ticket system.  I looked 
at all the open source ones i could find in a google search and they 
didn't do what I need (some had few features, others didn't support 
authentication against external sources (ldap, imap, etc)).  the 
commercial ones seemed like they'd do what I want, but the budget is 
tight with my employer currently.



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



Re: [PHP] SMTP mail server

2009-04-24 Thread Adam Williams



Ron Piggott wrote:

How do I specify an actual SMTP server?  (Like mail.host.com)

This is what I have so far:

mail($email, $subject, $message, $headers);

I was to http://ca2.php.net/manual/en/function.mail.php and saw this
syntax:

mail ( string $to , string $subject , string $message [, string
$additional_headers [, string $additional_parameters ]] )

Ronhttp://

  

http://www.php.net/manual/en/mail.configuration.php

looks like you can edit php.ini and change SMTP=localhost to something 
else and restart apache (if needed)



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



[PHP] how to determine if a mysql query returns an empty set?

2009-04-23 Thread Adam Williams
Is there a way to determine if a mysql query returns an empty set?  I am 
selecting 10 results at a time with a limit statement and need to know 
when i've ran out of rows.  I've only got 2 rows in the database, so 
when I start with row 10, it returns an empty set.  I have the following 
code:


//running this query gives Empty set (0.00 sec) in mysql console.

$get_requests = select form_id, full_name, email, phone, division, 
location, date_format(time_of_request, '%m-%d-%Y %r') as 
time_of_request, contact_time, problem, accepted_by, 
date_format(accepted_time, '%m-%d-%Y %r') as accepted_time, resolution, 
date_format(resolution_time, '%m-%d-%Y %r') as resolution_time from form 
where ((stage = 'Closed')  (email = 'awilliam' )) order by 
resolution_time limit 10 , 10


//checks to see if it returns nothing, then print that you are at the 
end of the results


   if (!$mysqli_get_requests = 
mysqli_query($mysqli,$get_requests))

   {
   echo You have reached the end of the results.
   Please press the back button.
   form action=/helpdesk/login.php method=postinput
   type=submit value=Back
   name=submit/form/body/html;
   exit;
   }

but that doesn't work, because I guess an empty set is not false, 0, or 
NULL?





Re: [PHP] how to determine if a mysql query returns an empty set?

2009-04-23 Thread Adam Williams



Nitsan Bin-Nun wrote:

mysql_num_rows() maybe? if not I probably haven't understood your question.


  

Thanks, I never thought of trying that.  This code works!

   $mysqli_get_requests = mysqli_query($mysqli,$get_requests);
   if (!mysqli_num_rows($mysqli_get_requests))
   {
   echo You have reached the end of the results.
   Please press the back button.
   form action=/helpdesk/login.php method=postinput
   type=submit value=Back
   name=submit/form/body/html;
   exit;
   }



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



Re: [PHP] how to determine if a mysql query returns an empty set?

2009-04-23 Thread Adam Williams



Andrew Ballard wrote:

It won't be any of those because the query is successful even if it
returns no records. You could use
http://us2.php.net/manual/en/mysqli-stmt.num-rows.php to determine how
many rows were returned.

Andrew
  

Oh ok, thanks that makes sense.  Thanks for the link also


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



[PHP] php isn't displaying mysql query correctly

2009-04-17 Thread Adam Williams

I have the code:

$mysqli_get_support_types = Select types from support_types order by 
types;
$mysqli_get_support_types_result = 
mysqli_query($mysqli,$mysqli_get_support_types) or 
die(mysqli_error($mysqli));


while (mysqli_fetch_array($mysqli_get_support_types_result))
   {
   echo option.$mysqli_get_support_types[types];
   }
echo /select

but when I go to the web page source it displays:

selectoptionSoptionSoptionSoptionSoptionSoptionSoptionSoptionSoptionSoptionS/select

but the query runs correctly in MySQL.  So why is php just printing S's?

mysql Select types from support_types order by types;
+-+
| types   |
+-+
| Change User |
| Computer Hardware   |
| Computer Peripheral |
| Computer Software   |
| Delete User |
| Networking  |
| New Project |
| New User|
| Server  |
| Telephone   |
+-+
10 rows in set (0.00 sec)



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



Re: [PHP] php isn't displaying mysql query correctly

2009-04-17 Thread Adam Williams

Shawn McKenzie wrote:


No.  How about:

while ($row = mysqli_fetch_array($mysqli_get_support_types_result))
   {
   echo option.$row['types'];
   }

  


thanks, now that you provided that, I see that I left out the $row variable!


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



[PHP] header() and passing sessions

2009-04-15 Thread Adam Williams
I need some help passing a session variable with a header() function.  
According to www.php.net/header, the documentation states:


*Note*: Session ID is not passed with Location header even if 
session.use_trans_sid 
session.configuration.php#ini.session.use-trans-sid is enabled. It 
must by passed manually using *SID* constant.


so, I'm trying to manually pass the SID, but not having any luck.  Here 
is a snippet of my code:


There is a file login.php which has session_start(); and sets 
$_SESSION[username] with the username you logged in with from 
index.php and has a form to click View Pending Requests which has the 
action of option.php.


-- option.php --
?php
session_start();
if ($_POST[option] == View Pending Requests)
   {
   header('Location: 
http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID='.session_id());

   }
?

--viewpending.php --
?php
session_start();
if (!$_SESSION[username])
   {
   echo You have not logged in;
   exit;
   }
?

so you click on View Pending Requests, and the URL in your browser is:

http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID=du75p41hel9k1vpuah799l2ce7

but viewpending.php says You have not logged in.  Why is that?



Re: [PHP] header() and passing sessions

2009-04-15 Thread Adam Williams

abdulazeez alugo wrote:


Hi,
Well I'ld say the reason is quite obvious. You have simply not set 
$_session[username] . I'ld have done something like:
 
-- option.php --

?php
 session_start();
 if ($_POST[option] == View Pending Requests)
{
$_session[username]= true;  //sets the session
 header('Location: 
http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID='.SID);
// 
http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID=%27.SID%29;%A0%A0%A0+// 
I'ld use SID

 }
 ?

 
--viewpending.php -

 ?php
 session_start();
 if ($_SESSION[username] !=true)
 {
 echo You have not logged in;
 exit;
 }
 ?
 
I hope this helps. try it.

Cheers
Alugo Abdulazeez




Well the thing is, $_SESSION[username] is set.  If I change option.php to:

?php
session_start();
echo session username is .$_SESSION[username];
/*if ($_POST[option] == View Pending Requests)
   {
   header('Location: 
http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID='.session_id());

   }
*/
?

and click on View Pending Requests, it prints:

session username is awilliam




Re: [PHP] GIS with PHP tutorial

2009-04-15 Thread Adam Williams

have you looked into this? http://postgis.refractions.net/


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



[PHP] help with end of line charater

2009-01-30 Thread Adam Williams
I have staff inputting email addresses into a textarea named $list on 
a form and when they click submit, my php script sorts the email 
addresses and writes to disk.  The problem is, lets say they enter the 
email addresses


b...@mdah.state.ms.usstaff hits enter
ama...@mdah.state.ms.usstaff hits enter
sa...@mdah.state.ms.usstaff hits enter
j...@mdah.state.ms.usstaff hits enter
ci...@mdah.state.ms.usstaff does not hit enter and clicks on submit button

then views the sortes email addresses, it displays as:

ama...@mdah.state.ms.us
b...@mdah.state.ms.us
ci...@mdah.state.ms.usjoe@mdah.state.ms.us
sa...@mdah.state.ms.us

because the staff didn't hit enter on the last line.  Is there a way to 
read each line of input and add a carriage return if needed?  I tried 
the code below but it did not work, nothing happened, and i don't know 
to examine each line to see if it ends in \r\n either.


$list2 = explode(\r\n, $list);

foreach ($list2 as $key = $var)
   {

   $var = $var.\r\n;

   }

$list = implode(\r\n, $list2);







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



Re: [PHP] Re: help with end of line charater

2009-01-30 Thread Adam Williams

Shawn McKenzie wrote:

This may be best handled in your sorting code.  What does it look like?
  


yeah just a second ago a big lightbulb went off in my head and i fixed 
my code to add a \r\n on saving, and strip it on viewing.  I sort on 
viewing, not sort on saving.  The viewing code looks like:


$biglist = ;

$filename = /usr/local/majordomo/lists/.$edit;

$fp = fopen($filename, r) or die (Couldn't open $filename);
if ($fp)
   {
   while (!feof($fp))
   {
   $thedata = fgets($fp);
   $buildingvar[] = $thedata;
   }
   sort($buildingvar);
   foreach ($buildingvar as $key = $val)
   {
if ($val != \r\n)  //gets rid of 
empty whitespace lines

   {
   $biglist .= $val;
   }

   }

   }

//$biglist gets echo'd into a textarea box below.

but now right before it is saved, i'll add a new line

$list .=\r\n;

$fp = fopen($filename, w) or die (Couldn't open $filename);
if ($fp)
   {
   fwrite($fp, $list);
   echo 
   headtitleSaving Page/title
   link rel=stylesheet href=/maillist.css type=\text/css\
   /head
   Your mailing list has been updated.;
   }

fclose($fp);

so that upon viewing, if they didn't press enter, a \r\n will be added, 
and even if they did add press enter on the last line, it'll be stripped 
out upon viewing the list of email addresses.




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



[PHP] removing text from a string

2008-11-04 Thread Adam Williams

I have a file that looks like:

1. Some Text here
2. Another Line of Text
3. Yet another line of text
340. All the way to number 340

And I want to remove the Number, period, and blank space at the begining 
of each line.  How can I accomplish this?


Opening the file to modify it is easy, I'm just lost at how to remove 
the text.:


?php
$filename = results.txt;

$fp = fopen($filename, r) or die (Couldn't open $filename);
if ($fp)
{
while (!feof($fp))
   {
   $thedata = fgets($fp);
   //Do something to remove the 1. 
   //print the modified line and \n 
   }

fclose($fp);
}
?

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



Re: [PHP] removing text from a string

2008-11-04 Thread Adam Williams

Thanks Boyd, your code did exactly what I wanted!

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



[PHP] going from procedural style to object orientated style coding

2008-05-30 Thread Adam Williams
I was wondering if anyone knew of some books/tutorials/howto's, etc on 
going from procedural style coding to object orientated coding with 
PHP?  I've been using PHP since version 3 and am used to the procedural 
style, but I'm noticing that PHP's trend is going to the object 
orientated style, but I'm not familiar with that style.  Any suggestions 
on how to make the switch to coding in object orientated style?



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



Re: [PHP] New search related question

2008-02-05 Thread Adam Williams

http://search.mnogo.ru

Jason Pruim wrote:

Hi Everyone! :)

Just a quick question, I've done some googling but haven't been able 
to find what I need... I am looking at doing a search function for 
someone's website, the website is just static HTML files, and she 
doesn't want to redo the entire website to make it dynamic.


What I am thinking (And please correct me when I'm wrong!) is that if 
I maintain a database with keywords in it, and links to the pages it 
exists on, I can implement the search easily enough without redoing 
the entire website. IE: Someone searches the database for Flowers 
and flowers are the main product on: Flowers.html and 
fakeFlowers.html so on the page, I would display:


Search Term: Flowers

Search Results:
link.to.site/Flowers.html
link.to.other.site/fakeFlowers.html

Is there anything wrong with the way I'm thinking? Or is it that there 
is a better way to search through a static HTML site?



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]



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



[PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Adam Williams
I'm having users enter dates in MM-DD- format.  is there a way to 
check if what they have entered is invalid (like if they enter 1-15-2008 
instead of 01-15-2008) ?


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



Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Adam Williams

Thanks, I think I have it:

$dateexplode = explode(-, $_POST[date_entered]);
if (!preg_match(/^(\d{2})$/, $dateexplode[0],$data1) ||
!preg_match(/^(\d{2})$/, $dateexplode[1],$data2) ||
!preg_match(/^(\d{4})$/, $dateexplode[2],$data3))
   {
   die (you have entered an invalid date);
   }

so if the person enters 01-15-2008 its fine, but 1-15-2008 dies.

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



Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Adam Williams



Andrew Ballard wrote:

Just curious why you won't take 1-15-2008. Once you validate it, you
can always assign it to a variable as either a timestamp or a DateTime
object and then format it however you want when you display it, send
it to a database, or whatever you are doing with the date.

FWIW, what you have above will also accept 42-75-2008.

Andrew

  
Because I'm inserting it into MySQL as a date conversion from American 
date to a MySQL date field. %m must be ##, %d must be ##, and %Y must be 
. so if %m or %d is set to 1 - 9 and not 01 - 09 it will error.



$mysqli_insert_sql = INSERT INTO contract (user_id, cwcv,
amount, responsibility, length_start, length_end, stage, title, lastmod, 
divdirdate)

VALUES ( '$user_id', '. $_POST[cwcv].', '.$_POST[amount].',
'.$_POST[responsibility].',
STR_TO_DATE('.$_POST[length_start].', '%m-%d-%Y'),
STR_TO_DATE('.$_POST[length_end].', '%m-%d-%Y'), '1',
'.$_POST[title].', now(), now());

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



Re: [PHP] checking user input of MM-DD-YYYY

2008-01-15 Thread Adam Williams

Andrew Ballard wrote:

All the more reason I would turn it into a timestamp or DateTime
object in PHP first. That will prevent trying to insert something like
what I used above. Then I would get rid of the MySQL STR_TO_DATE
function in the $mysqli_insert_sql value just replace it with
something like this:

date('Y-m-d', $length_start)

If you enter it in that format MySQL will get it right without regard
to locale settings.

I hope that you are sanitizing the rest of the input as well, and not
just shoving unchecked POST data into a database. Your example is a
SQL injection attack waiting to be exploited.

Andrew

  


I'm running mysql_real_escape_string(); on all of the variables prior to 
inserting/updating them.


I don't see the point in needing to convert it to a timestamp.  The 
length_start and length_end fields in MySQL are defined as date fields.  
All I care about is the date, not the hours/minutes/seconds.  If I 
insert it as date('Y-m-d', $length_start) then when I SELECT it back 
out, I will still have to do a date conversion back to MM-DD- when I 
display it to the user.


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



[PHP] mysql date question

2008-01-03 Thread Adam Williams

I have a field in mysql as shown by describe contract;

| length_start | date| YES  | | NULL
||


Which stores it in the mysql format of -MM-DD.  However, I need the 
output of my select statement to show it in MM-DD- format.  I can 
select it to see the date in the field:


select length_start from contract where user_id = 1;
+--+
| length_start |
+--+
| 2006-01-12   |
+--+
1 row in set (0.00 sec)

so then I do my date_format() select statement, but it returns a NULL 
value.  Why?


select date_format('contract.length_start', '%m-%d-%Y') as length_start 
from contract where user_id = 1;

+--+
| length_start |
+--+
| NULL |
+--+
1 row in set, 1 warning (0.00 sec)

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



[PHP] Re: mysql date question

2008-01-03 Thread Adam Williams
nevermind, figure it out, had to take the ' ' away from 
contract.length_start :)


Adam Williams wrote:

I have a field in mysql as shown by describe contract;

| length_start | date| YES  | | NULL
||


Which stores it in the mysql format of -MM-DD.  However, I need 
the output of my select statement to show it in MM-DD- format.  I 
can select it to see the date in the field:


select length_start from contract where user_id = 1;
+--+
| length_start |
+--+
| 2006-01-12   |
+--+
1 row in set (0.00 sec)

so then I do my date_format() select statement, but it returns a NULL 
value.  Why?


select date_format('contract.length_start', '%m-%d-%Y') as 
length_start from contract where user_id = 1;

+--+
| length_start |
+--+
| NULL |
+--+
1 row in set, 1 warning (0.00 sec)




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



[PHP] handling ' with mysql/php insert and select

2008-01-03 Thread Adam Williams
In my form, I am parsing all the text inputs through 
mysql_real_escape_string() before inserting the data.  however, when I 
look at the SQL query in PHP, when I type the word blah's to my text box 
variable, and then insert it into mysql after being ran through 
mysql_real_escape_string(), it does:


insert into contract (contract_id, responsibility) VALUES (15, 'blah\\\'s')

and when I query the in mysql/PHP it shows:

select responsibility from contract where contract_id = 15;
++
| responsibility |
++
| blah\'s|
++
1 row in set (0.00 sec)

and when I run that select statement in PHP it prints blah\'s on the 
screen.  I want it to print back blah's without the \.  So what are my 
options?  run every variable through stripslashes(); before printing 
them to the screen?


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



[PHP] Wrong parameter count for imap_open()

2008-01-02 Thread Adam Williams

I'm running PHP 5.2.4 and getting the error:

*Warning*: Wrong parameter count for imap_open() in 
*/var/www/sites/intra-test/contract/login.php* on line *9


*My code is:

$mbox =
imap_open(\{mail.mdah.state.ms.us/imap/novalidate-cert:143}INBOX\,
\.$_POST[username].\, \.$_POST[password].\);   // line 9

but when I echo it out, it looks fine:

echo \{mail.mdah.state.ms.us/imap/novalidate-cert:143}INBOX\,
\.$_POST[username].\, \.$_POST[password].\;

prints:

{mail.mdah.state.ms.us/imap/novalidate-cert:143}INBOX, awilliam, 
xxx



any ideas?
*
*


[PHP] Fatal error: Function name must be a string

2008-01-02 Thread Adam Williams
I'm getting the following error and I don't see whats wrong with my 
line.  Any ideas?


*Fatal error*: Function name must be a string in 
*/var/www/sites/intra-test/contract/perform.php* on line *57*


and my snippet of code is:

if ( $_POST[perform] == View Contracts )
   {

   $mysqli_get_userid = SELECT user_id from user where email =
'.$_SESSION[username].';

   $mysqli_get_userid_result = $mysqli_query($mysqli,  // line 57
$mysqli_get_userid) or die(mysqli_error($mysqli));

   while ($userid_result = 
mysqli_fetch_array($mysqli_get_userid_result))

   {
   $user_id = $userid_result[user_id];
   }
   }


[PHP] how to handle inserting special characters into a mysql field

2007-12-14 Thread Adam Williams
I'm going to be inserting data from a PHP form into a mysql field.  The 
data could contain special characters like   '  \ /, etc.  How do I 
handle that?  just $data = addslashes(htmlspecialchars($data)); before 
the insert query?  because later on the data will be read back from the 
mysql db and I don't want it to contain a special character that would 
break the PHP script.


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



Re: [PHP] how to handle inserting special characters into a mysql field

2007-12-14 Thread Adam Williams
Thanks for all the replies everyone.  I have a question on 
mysql_real_escape_string().  The PHP example page shows:


$query = sprintf(SELECT * FROM users WHERE user='%s' AND password='%s',
   mysql_real_escape_string($user),
   mysql_real_escape_string($password));

and I understand it uses the %s because of sprintf(), to indicate the 
data is a string.  However, thats not syntax I'm used to seeing.  If I 
rewrite the code to the following below, will it return the same results 
or error when queried?


$user = mysql_real_escape_string($user);
$password = mysql_real_escape_string($password)
$query = SELECT * FROM users WHERE user='$user' AND password='$password';

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



Re: [PHP] mysql DATE_FORMAT() question

2007-12-12 Thread Adam Williams

nevermind, I see I had a mistake in my mysql statement,  I should of been:

select DATE_FORMAT(testdate, '%m\-%d\-%Y') as date_column from testtable;

please disregard.

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



[PHP] mysql DATE_FORMAT() question

2007-12-12 Thread Adam Williams

I ran the commands:

CREATE TABLE testtable ( testdate DATETIME);

INSERT INTO testtable (testdate) VALUES (now());

and then I want to select it but format it to show the date only (not 
the time, and yes I know I could use DATE instead of DATETIME, but there 
may be cases where I need to show the time also).  So I run:


select DATE_FORMAT(testdate, '%m\-%d\-%Y') from testtable AS date_column;
+-+
| DATE_FORMAT(testdate, '%m\-%d\-%Y') |
+-+
| 12-12-2007  |
+-+


now my question is, why is the column heading DATE_FORMAT(testdate, 
'%m\-%d\-%Y') even though I told it to be called date_column?


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



[PHP] parsing text for special characters

2007-11-29 Thread Adam Williams
I've got an html form, and I have PHP parse the message variables for 
special characters so when I concatenate all off the message variables 
together, if a person has put in a '  or other special character, it 
won't break it when it used in mail($to, MMH Suggestion, $message, 
$headers);  below is my snippet of code, but is there a better way to 
parse the text for special characters.  what about if I were to have the 
$message inserted into a mysql field?  how would I need to handle 
special characters that way?


$need_message = $_POST['need_message'];

  function flash_encode($need_message)
  {
 $string = rawurlencode(utf8_encode($need_message));

 $string = str_replace(%C2%96, -, $need_message);
 $string = str_replace(%C2%91, %27, $need_message);
 $string = str_replace(%C2%92, %27, $need_message);
 $string = str_replace(%C2%82, %27, $need_message);
 $string = str_replace(%C2%93, %22, $need_message);
 $string = str_replace(%C2%94, %22, $need_message);
 $string = str_replace(%C2%84, %22, $need_message);
 $string = str_replace(%C2%8B, %C2%AB, $need_message);
 $string = str_replace(%C2%9B, %C2%BB, $need_message);

 return $need_message;
  }

//and then there are $topic_message, $fee_message, etc and they all get 
concatenated with

$message .= needs_message;
$message .= $topics_message;
$message .= $fee message;

//emails the $message
mail($to, MMH Suggestion, $message, $headers);

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



[PHP] problem with foreach

2007-10-22 Thread Adam Williams

I have an html page with checkboxes:

form action=mailform2.php method=POST
input type=checkbox name=option[] value=Modern MississippiModern 
Mississippibr

input type=checkbox name=option[] value=Civil RightsCivil Rightsbr
input type=checkbox name=option[] value=Military 
HistoryMilitaryHistorybr

input type=submit name=submit value=Submit

and mailform2.php containing:

echo you selected: br;
/* line 81 */ foreach ($_POST[option] as $a)
   {
   echo $a;
   }

but I'm getting the error:

you selected:

*Warning*: Invalid argument supplied for foreach() in 
*/var/www/sites/mdah-test/museum/mmhsurvey/mailform2.php* on line *81*


I googled some checkbox/foreach pages on google, but I don't see where 
I'm going wrong.  I'm running php 5.2.5 on Apache 2.2.4 on Fedora 
Linux.  Any help?


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



Re: [PHP] problem with foreach

2007-10-22 Thread Adam Williams



Robert Cummings wrote:

On Mon, 2007-10-22 at 18:07 +0100, Stut wrote:
  

Adam Williams wrote:


I have an html page with checkboxes:

form action=mailform2.php method=POST
input type=checkbox name=option[] value=Modern MississippiModern 
Mississippibr

input type=checkbox name=option[] value=Civil RightsCivil Rightsbr
input type=checkbox name=option[] value=Military 
HistoryMilitaryHistorybr

input type=submit name=submit value=Submit

and mailform2.php containing:

echo you selected: br;
/* line 81 */ foreach ($_POST[option] as $a)
   {
   echo $a;
   }

but I'm getting the error:

you selected:

*Warning*: Invalid argument supplied for foreach() in 
*/var/www/sites/mdah-test/museum/mmhsurvey/mailform2.php* on line *81*


I googled some checkbox/foreach pages on google, but I don't see where 
I'm going wrong.  I'm running php 5.2.5 on Apache 2.2.4 on Fedora 
Linux.  Any help?
  
Turn notices on. You will then get lots of notices about the use of an 
undefined constant option.


You should be using $_POST['option'] instead - notice the quotes.

Your HTML should really have double quotes around the attributes but 
that's beyond the scope of this list.



He's still going to get an invalid argument warning though since PHP
will automatically convert the unquoted key to a string and then look up
the value. The problem is that the value doesn't exist or is not an
array as expected.

Cheers,
Rob.
  


Yeah, thats the problem I'm having for some reason.  When I do:

print_r($_POST['option']);

it prints nothing.

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



[PHP] echo'ing a variable and cat'ing text

2006-03-02 Thread Adam Williams
I have a file called userlist.  I'm trying to read the file, and then 
echo their name and add @mdah.state.ms.us with it.  In the file 
userlist, it looks like:


userabc
userdef
userxyz

and I have the following code:

?php
$filename = userlist;
$fp = fopen($filename, r) or die (Couldn't open $filename);
if ($fp)
{
while (!feof($fp))
   {
   $thedata = fgets($fp);
   if ($thedata != )
   {
   echo $thedata.@mdah.state.ms.us;
   }
   }
fclose($fp);
}
?


But when I run it, I get:

@mdah.state.ms.ususerabc
@mdah.state.ms.ususerdef
@mdah.state.ms.ususerxyz

and I am expecting to get:

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

So can someone look at my code and let me know why I'm not getting my 
expected output?


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



Re: [PHP] echo'ing a variable and cat'ing text

2006-03-02 Thread Adam Williams
Hi, I just tried that, didn't make a difference, still not getting my 
expected output.


[EMAIL PROTECTED] wrote:

[snip]
echo $thedata.@mdah.state.ms.us;
[/snip]

Try echo $thedata.'@mdah.state.ms.us';

  


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



Re: [PHP] echo'ing a variable and cat'ing text

2006-03-02 Thread Adam Williams

John Nichel wrote:
Well, you're not telling fgets how much to read for one, and I'd do 
this a different way to begin with...


if ( $file = file ( $filename ) ) {
foreach ( $file as $line ) {
if ( $file !=  ) {
echo ( $line . @mdah.state.ms.us );
}
}
} else {
echo ( Couldn't open $filename );
}


When I do that, I get:

userabc
@mdah.state.ms.ususerdef
@mdah.state.ms.ususerxyz
@mdah.state.ms.us


so looks like I need to strip out the end-of-line (EOL) character somehow.

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



Re: [PHP] echo'ing a variable and cat'ing text

2006-03-02 Thread Adam Williams

got it!  i had to have my block of code look like this:

if ( $file = file ( $filename ) ) {
   foreach ( $file as $line ) {
   if ( $line !=  ) {
   $line = trim($line);
   echo ( $line . @mdah.state.ms.us );
   echo \n;
   }
   }
} else {
   echo ( Couldn't open $filename );
}

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



[PHP] grabbing source of a URL

2004-12-10 Thread Adam Williams
Hi, I don't know what functions to use so maybe someone can help me out.  
I want to grab a URL's source (all the code from a link) and then cut out 
a block of text from it, throw it away, and then show the page.

For example, if I have page.html with 3 lines:

htmlheadtitlehi/title/head
body
!-- line a --
this is line a
!-- end line a --
!-- line b --
this is line b
!-- end line b --
!-- line c --
this is line c
!-- end line c --
/body/html

i want my php script to grab the source of page.html, strip out:

!-- line a --
this is line a
!-- end line a --

and then display what is left, how would I go about doing this?  I don't 
know what function to use to grab the page.  for the string to remove, I 
know I can probably do a str_replace and replace the known code with 
nothing.

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



[PHP] stripping text from a string

2004-10-29 Thread Adam Williams
Hi, I use a piece of proprietary software at work that uses weird session 
ID strings in the URL.  A sample URL looks like:

http://zed2.mdah.state.ms.us/F/CC8V7H1JF4LNBVP5KARL4KGE8AHIKP1I72JSBG6AYQSMK8YF4Y-01471?func=find-b-0

The weird session ID string changes each time you login.  Anyway, how can 
I strip out all of the text between the last / and the ? and insert it 
into another variable?  So in this case, the end result would be a 
variable containing:

CC8V7H1JF4LNBVP5KARL4KGE8AHIKP1I72JSBG6AYQSMK8YF4Y-01471

thanks!

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



[PHP] fopen and http://

2004-10-08 Thread Adam Williams
Hi, I'm having a problem with fopen and http files.  I keep getting the 
error:

Warning: fopen(http://zed/htdocs/rgfindingaids/series594.html ) 
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 
Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
http://zed/htdocs/rgfindingaids/series594.html does not exist

Warning: fopen(http://zed/htdocs/rgfindingaids/ser391.html ) 
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 
Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
http://zed/htdocs/rgfindingaids/ser391.html does not exist

Warning: fopen(http://zed/htdocs/rgfindingaids/ser392.html ) 
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 
Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
http://zed/htdocs/rgfindingaids/ser392.html does not exist



I have a text file /home/awilliam/public_html/rgfaids containing URLs such 
as:

http://zed/htdocs/rgfindingaids/series594.html
http://zed/htdocs/rgfindingaids/ser391.html
http://zed/htdocs/rgfindingaids/ser392.html

and I can bring up these URLs fine in a browser on the PC i'm running the 
script on.

The following is my code:

?

$filelist = fopen(/home/awilliam/public_html/rgfaids, r);

if (!$filelist)
{
echo error opening rgfaids;
exit;
}

while ( !feof($filelist))
{
$line = fgets($filelist, 9);

$filetotest = fopen($line, r);

if (!$filetotest)
{
echo $line does not existbr;
}
elseif ($filetotest)
{
echo $line does exist;
}
}

?



But I don't understand why I am getting that error about failed to open 
strem: HTTP request failed, when I can bring up the links fine in a 
browser on the server running the php script.  So can anyone help me out?  
Thanks

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



Re: [PHP] fopen and http://

2004-10-08 Thread Adam Williams
On Fri, 8 Oct 2004, Matt M. wrote:

  But I don't understand why I am getting that error about failed to open
  strem: HTTP request failed, when I can bring up the links fine in a
  browser on the server running the php script.  So can anyone help me out?
  Thanks
 
 do you have allow_url_fopen enabled? 
 
 http://us4.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen
 
 

Yes I do, in my php.ini I have:

;;
; Fopen wrappers ;
;;

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On

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



Re: [PHP] fopen and http://

2004-10-08 Thread Adam Williams
On Fri, 8 Oct 2004, Hendrik Schmieder wrote:

 What say phpinfo about Registered PHP Streams ?
 
Hendrik
 
 

Hi, I think I just figured out my problem...I had to use rtrim($line) 
because I think there was a \n or an invisible character at the end of the 
line that was being passed to the http:// server from looking at the 
server's access_log and error_log files.  So now it works except on the 
very last line it processes, it prints does not exist, so there is still 
some sort of a hidden character but its not affecting fetching the URLs 
from the web server.  so i'm still trying to figure that last line out, 
but everything else works.

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



[PHP] single dimensional array questions

2004-08-04 Thread Adam Williams
Here is my snippet of code.  It takes cardnum from the database, removes 
the duplicates for each individual date, and then counts how many discrete 
numbers there was.

!-- snippet of code starts here --

//database connect and selection here, now my sql statement:

$sql = select convert( varchar,eventime, 110) as date, cardnum from events, 
badge where eventtype=0 and devid=1 and events.cardnum=badge.id and badge.type
= 1 and convert(varchar,eventime,110) between '$startdate' and '$enddate' 
group by events.eventime, events.cardnum order by 
convert(varchar,eventime,110), cardnum;

$query = mssql_query($sql);

while ($row = mssql_fetch_assoc($query))
{

$array[$row['date']][] = $row['cardnum'];
}

$i = 0;
$j = 0;

foreach ( $array as $key = $value)
{
echo 'date: '. $key . ', count: ' . count(array_unique($value));
echo br;
$i += count(array_unique($value));
$j++;
}
$query = mssql_query($sql);

while ($row = mssql_fetch_assoc($query))
{

$array[$row['date']][] = $row['cardnum'];
}

$i = 0;
$j = 0;

foreach ( $array as $key = $value)
{
echo 'date: '. $key . ', count: ' . count(array_unique($value));
echo br;
$i += count(array_unique($value));
$j++;
}
echo total = $ibr;
echo average = .round(($i/$j),1);

!-- end of code --

And now my question.  What I need to do is create a single 
dimensional array that contains each number that 
count(array_unique($value)) is counting.  how would I do this?  I can't 
use the SQL query because I have to remove duplicate cardnums for each 
date.

I was thinking of doing:

$patrons = array();

//inside of the foreach have this:
$patrons[] = array_unique($value);

but that doesn't seem to work.  because when I print_r($patrons) its 
creating an array of arrays of an array.  here is from july 1 to july 7th.

date: 07-01-2004, count: 50
date: 07-02-2004, count: 43
date: 07-03-2004, count: 33
date: 07-06-2004, count: 35
date: 07-07-2004, count: 51
Array ( [0] = Array ( [0] = 123 [1] = 204 [2] = 277 [4] = 343 [6] = 
450 [7] = 552 [8] = 637 [9] = 828 [11] = 829 [12] = 1007 [13] = 1075 
[14] = 1363 [15] = 1455 [17] = 1539 [18] = 1736 [19] = 1928 [23] = 
1929 [25] = 2044 [26] = 2221 [29] =  [34] = 2961 [36] = 2969 [37] 
= 3122 [39] = 3273 [42] = 3274 [46] = 3286 [47] = 3288 [51] = 3294 
[52] = 3322 [53] = 3325 [54] = 3326 [56] = 3327 [57] = 3328 [59] = 
3329 [60] = 3330 [61] = 3332 [62] =  [63] = 3334 [64] = 3335 [65] 
= 3336 [66] = 3337 [68] = 3338 [69] = 3339 [70] = 3340 [71] = 3341 
[72] = 3342 [73] = 3343 [74] = 3344 [76] = 3345 [77] = 3346 ) [1] = 
Array ( [0] = 114 [1] = 123 [2] = 277 [3] = 369 [5] = 637 [6] = 744 
[7] = 829 [8] = 1264 [10] = 1702 [11] = 1738 [13] = 1911 [15] = 1928 
[20] = 2221 [24] =  [29] = 2593 [30] = 2961 [31] = 2969 [34] = 
3037 [35] = 3273 [38] = 3274 [43] = 3322 [45] = 3336 [46] = 3338 [48] 
= 3347 [50] = 3348 [53] = 3349 [55] = 3350 [56] = 3351 [57] = 3352 
[59] = 3353 [61] = 3354 [62] = 3355 [63] = 3356 [66] = 3357 [68] = 
3358 [69] = 3359 [70] = 3360 [71] = 3361 [72] = 3362 [73] = 3363 [75] 
= 3364 [76] = 3365 [77] = 3366 ) [2] = Array ( [0] = 87 [2] = 344 
[3] = 355 [4] = 362 [5] = 637 [7] = 744 [8] = 825 [9] = 826 [11] = 
895 [13] = 1478 [15] = 1654 [17] = 2429 [18] = 2654 [20] = 2756 [21] 
= 2969 [22] = 3124 [23] = 3166 [24] = 3273 [27] = 3274 [29] = 3294 
[31] = 3351 [32] = 3352 [34] = 3361 [36] = 3367 [37] = 3368 [39] = 
3369 [40] = 3370 [42] = 3372 [43] = 3373 [44] = 3374 [45] = 3375 [46] 
= 3376 [47] = 3378 ) [3] = Array ( [0] = 314 [4] = 343 [7] = 637 [8] 
= 825 [9] = 826 [10] = 829 [11] = 1736 [13] = 1844 [15] = 2084 [17] 
= 2967 [18] = 2990 [19] = 2991 [21] = 3037 [23] = 3078 [24] = 3106 
[25] = 3107 [28] = 3179 [31] = 3379 [34] = 3380 [36] = 3381 [38] = 
3382 [40] = 3383 [41] = 3384 [42] = 3385 [44] = 3386 [45] = 3387 [46] 
= 3388 [47] = 3389 [48] = 3390 [49] = 3391 [51] = 3392 [53] = 3393 
[54] = 3394 [55] = 3395 [56] = 3396 ) [4] = Array ( [0] = 63 [3] = 
203 [4] = 286 [5] = 637 [7] = 828 [9] = 829 [10] = 1066 [12] = 1262 
[13] = 1702 [14] = 1736 [16] = 1738 [17] = 1844 [19] = 1926 [20] = 
2654 [23] = 2946 [24] = 2990 [26] = 2991 [29] = 3179 [31] = 3220 [33] 
= 3286 [35] = 3316 [38] = 3334 [39] = 3361 [41] = 3383 [43] = 3384 
[44] = 3385 [45] = 3390 [46] = 3391 [48] = 3398 [49] = 3399 [50] = 
3400 [53] = 3401 [55] = 3402 [59] = 3403 [63] = 3404 [65] = 3405 [71] 
= 3406 [72] = 3407 [73] = 3408 [74] = 3409 [75] = 3410 [76] = 3411 
[77] = 3412 [79] = 3413 [81] = 3414 [82] = 3415 [83] = 3416 [84] = 
3418 [85] = 3419 [86] = 3420 [87] = 3421 ) ) total = 212
average = 42.4 

note that there is no july 4th and 5th because we were closed those days.

what I want to do is is say after I add the first array of dates into 
$patrons[], say if its 10 cardnums, i'll have $patrons[0] through $patrons[9], 
and when I add the next day and it was 8 cardnums, it would be 
$patrons[10] through $patrons[17].  but instead its creating 
$patrons[0][0] through patrons[0][9] and next day is $patrons[1][0] 
through $patrons[1][7].  atleast thats 

[PHP] opposite of array_unique()?

2004-08-04 Thread Adam Williams
array_unique() removes duplicate values from an array.

Is there an opposite function or way of keeping all values in a single 
dimentional array that are duplicates and removing all that are 
duplicates?

for example if I have an array:

array( [0] = 'dog', [1] = 'cat', [2] = 'rabbit', [3] = 'cat')

how do I make it just have array ( [0] = 'cat' )?  i want to drop the 
non-duplicates and trim the array to only have one of the duplicates?



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



[PHP] converting a char variable to an int?

2004-06-14 Thread Adam Williams
Hi, I have a variable that is created using the date command:

$date = date(Ymd);

but its not working in my database this way (when I explicity enter 
20040614 in my database, it works though).  so I think PHP is making $date 
a character variable, so how can I force or change the caste of $date to 
force it to be an integer variable?  thanks

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



Re: [PHP] converting a char variable to an int?

2004-06-14 Thread Adam Williams
eh nevermind, I found settype();

:) thanks

On Mon, 14 Jun 2004, Adam Williams wrote:

 Hi, I have a variable that is created using the date command:
 
 $date = date(Ymd);
 
 but its not working in my database this way (when I explicity enter 
 20040614 in my database, it works though).  so I think PHP is making $date 
 a character variable, so how can I force or change the caste of $date to 
 force it to be an integer variable?  thanks
 
 

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



[PHP] rounding average to one decimal point

2004-05-10 Thread Adam Williams
Hi, I have a randon group of numbers I need the average of.  When I add 
them up and divide by how many there are and print the result, I get a 
lot of decimal places.  The number comes out to look like 29.3529411765, 
but I don't need that many decimal places.  rounding to one decimal place 
will be fine.  anyway to trim off the excess decimal values? 

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



Re: [PHP] rounding average to one decimal point

2004-05-10 Thread Adam Williams
On Mon, 10 May 2004, Richard Davey wrote:

 Hello Adam,
 
 Monday, May 10, 2004, 7:03:36 PM, you wrote:
 
 AW Hi, I have a randon group of numbers I need the average of.  When I add
 AW them up and divide by how many there are and print the result, I get a
 AW lot of decimal places.  The number comes out to look like 29.3529411765,
 AW but I don't need that many decimal places.  rounding to one decimal place
 AW will be fine.  anyway to trim off the excess decimal values? 
 
 Try the round() function? :)
 
 ceil() and floor() might help if you decide you don't want the extra
 decimal places too.
 
 


i didn't know about round(), guess i should check php.net/round next time 
;) thanks!

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



[PHP] adding -'s to a numeric string

2004-04-21 Thread Adam Williams
Hi, I have a form where I have a user entering in the date in a numeric 
string.  For today they would enter 04212004 and so on...I'm working on 
this date within mysql server, and mssql server handles dates as 
04-21-2004 when you use convert(varchar,field,110).  So how in PHP can I 
change a variable's value which is 04122004 into 04-21-2204 

thanks!

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



[PHP] ocilogon

2004-03-30 Thread Adam Williams
Hi, what is the syntax for using ocilogon() to connect to a remote server?  
The remote server's name is zed.mdah.state.ms.us (ip is 10.8.5.4) and the 
database is zed.aleph0.  Locally on zed I can do 
ociogon(user,pw,zed.alpeh0) and connect fine, but on a remote server 
I try ociogon(user,pw,[EMAIL PROTECTED]) but it errors out with an 
oci_open_server error.  I tried going to www.php.net/ocilogon but the page 
doesn't exist, so does anyone know how the proper connect line to 
connect to a remote server that runs oracle?  Thanks!

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



Re: [PHP] ocilogon

2004-03-30 Thread Adam Williams
Hi, I have the client libraries on the computer I have PHP on.  My connect 
line is $conn = ocilogon(user,pw,zed.aleph0); and I can connect 
usning sqlplus.  When I look at the listener log, it doesn't show my 
computer with PHP on it trying to connect using PHP, but when I tnsping 
zed.aleph0, the listener log shows that.

On 30 Mar 2004, William Lovaton wrote:

 You need the Oracle cliente libraries installed where you have PHP for
 this to work.
 
 the third parameter in OCILogon() is the connection string configured in
 tnsnames.ora ($ORACLE_HOME/network/admin)
 
 Let's say that you make connection to Oracle using sqlplus:
 User: scott
 pass: tiger
 dbstring: test
 
 this in PHP would be: $conn = OCILogon(scott, tiger, test);
 
 
 -William
 
 
 El mar, 30-03-2004 a las 15:52, Adam Williams escribió:
  Hi, what is the syntax for using ocilogon() to connect to a remote server?  
  The remote server's name is zed.mdah.state.ms.us (ip is 10.8.5.4) and the 
  database is zed.aleph0.  Locally on zed I can do 
  ociogon(user,pw,zed.alpeh0) and connect fine, but on a remote server 
  I try ociogon(user,pw,[EMAIL PROTECTED]) but it errors out with an 
  oci_open_server error.  I tried going to www.php.net/ocilogon but the page 
  doesn't exist, so does anyone know how the proper connect line to 
  connect to a remote server that runs oracle?  Thanks!
 
 

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



Re: [PHP] ocilogon

2004-03-30 Thread Adam Williams
Hi, I figured out what was wrong, I had php_oci8.dll uncommented in 
php.ini but not php_oracle.dll.  Fixed that and now I get an ORA-12705 
error, which looking on google has something to do with NLS.  Going to do 
more reading, thanks :)

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



[PHP] str_replace or regex

2004-03-18 Thread Adam Williams
Hi, I was wondering if I can get some help with either a str_replace or a 
regex.  I have some data and it always begins with $$ but it can end with 
any letter of the alphabet.  so sometimes its $$a and sometimes its $$b 
and sometimes $$c all the way to $$z. $$a all the way to $$z needs to 
be changed to a /  So is there a way to do this?  I was thinking of a 
str_replace but since the letter always changes I'm not so sure.  Any help?

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



[PHP] regex to change ' to ?

2004-03-04 Thread Adam Williams
What would be the PHP expression to change any and all ' to ? in a 
variable?

I want to change any and all ' in $_POST[data] to ?

what would be the statement?  Thanks!

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



Re: [PHP] regex to change ' to ?

2004-03-04 Thread Adam Williams
Thank you, that works great!

On Thu, 4 Mar 2004, Richard Davey wrote:

 Hello Adam,
 
 Thursday, March 4, 2004, 3:36:06 PM, you wrote:
 
 AW What would be the PHP expression to change any and all ' to ? in a
 AW variable?
 
 AW I want to change any and all ' in $_POST[data] to ?
 
 $output_array = str_replace(', ?, $_POST);
 
 Use this instead of a reg exp for such a simple task, it's quicker and
 will cope with the whole array in one command.
 
 

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



[PHP] authentication using /etc/passwd

2004-02-05 Thread Adam Williams
Hi, is there a way to authenticate a username/password someone enters in a 
form with what is in /etc/passwd?

Thanks!

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



[PHP] authentication comparing to /etc/passwd

2004-02-03 Thread Adam Williams
Hi, is there a PHP function or some sort of way to have a user enter their 
username and password in a form, and compare the username and password and 
see if the username exists and the password is correct?

basically I want to have a page where a person enters their username and 
password and if correct to use the header function to send them to the a 
page.

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



[PHP] date conversion

2003-12-10 Thread Adam Williams
Hi, is there a PHP function that will convert MM/DD/ to MMDD?  
Also I will need to take into affect some people may put in M/D/ (some 
people may put in 1 instead of 01, 2 instead of 02, etc).  Is there a way 
to do this?

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



[PHP] date convertion

2003-12-09 Thread Adam Williams
I have a script where a user inputs a date in MMDD format, and I need 
to convert it to month day, year.  For example they will enter 20031209 
and I need the script to return the date as December 09, 2003.  They won't 
be entering today's date, so I can't use the timestamp with the date 
function.  So any ideas?

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



[PHP] explode()

2003-11-17 Thread Adam Williams
I am having a user enter a phrase into a textbox, and then I need to 
seperate the words he has typed into variables so I can use each one 
in an sql statement.  I know I will use the explode() function to do this, 
but how will I know how many variables I've created.  For instance, if a 
user types in 3 words seperated by spaces, how will I know i'll have 
var[0] through var[2]?  how about when they type in 2 words or 4 words?  
How will I know how many words they have typed in?  The only way I can 
think of to do this is:

// $var is the input after being ran through explode()

$i = 0;
while ($var[$i])
{
$i++;
}

I will then take the data they enter and create the sql statement:

$j = 0;

$sql = select subject from subfile where;

while ($j = $i)
{
$j++;
$sql .= suject matches '*$var[$j]*';

if ( $j != $i)
{
$sql .=  and ;
}
}




but I think there has to be a better way to do this.  any ideas?

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



[PHP] escaping ' when inside a

2003-11-17 Thread Adam Williams
If I have the SQL statement:

$sql = select subject from subwhile where subject = '*$var[0]*';

do I need to put a \ before each '?

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



Re: [PHP] escaping ' when inside a

2003-11-17 Thread Adam Williams
Yeah thats what I meant to do, my PHP is very rusty if you can't tell 
(and so is my SQL) :)

Jay Blanchard wrote:

[snip]

If I have the SQL statement:

$sql = select subject from subwhile where subject = '*$var[0]*';


Don't you want to do:
$sql = select subject from subwhile where subject LIKE '%$var[0]%';
[/snip]
Not if the variable is exactly what he is looking for.

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


[PHP] ignoring case

2003-11-12 Thread Adam Williams
Hi,

does anyone happen to know off hand the function that will ignore case for 
data inputted via text from a form/form?  I don't remember it off hand 
and can't find it in the function list on php.net.  Basically it changes 
the text in the string from a character to [a-Z] for each character.  I 
know it exists because i've used it before.  Any help?  Thanks

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



Re: [PHP] ignoring case

2003-11-12 Thread Adam Williams
Hi,

I finally found it in my notes, it was sql_regcase()

Rolf Brusletto wrote:

Adam Williams wrote:

Hi,

does anyone happen to know off hand the function that will ignore case 
for data inputted via text from a form/form?  I don't remember it 
off hand and can't find it in the function list on php.net.  Basically 
it changes the text in the string from a character to [a-Z] for each 
character.  I know it exists because i've used it before.  Any help?  
Thanks

 

Adam -

here ya go..

http://www.php.net/strtolower

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


[PHP] testing a variable

2003-11-12 Thread Adam Williams
Hello,

I need to test a variable to see if it contains a value or not, and if 
not, do something.  My php is a little rusty, so which would be better?

if ( !$var )
{ echo do something;}

or

if ( !isset($var )
{ echo do something;}

or are both of those wrong, and if so, how hsoudl I check if a variable is 
false, null, doesn't contain a value, etc...

What I am doing is checking a field in an sql table, and if the field is 
null, empty, etc... then do something.  so what is the best way to check 
the field if its null, empty, etc...?

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



[PHP] keyword searching

2003-11-12 Thread Adam Williams
Hello,

I am selecting a field in a database called description for keyword 
searching.  The field contains names of people, states, years, etc.  When 
someone searches for say holmes north carolina the query searches for 
exactly that, fields which have holmes north carolina, and not fields 
that contaim holmes, north, and carolina.  So I run a str_replace to 
replace all spaces with *, which turns it into holmes*north*carolina, 
but say that north carolina is before holmes in the field, it won't return 
those fields (it only returns fields in which holmes is infront of north 
carolina).  So how can I have it return all fields which contain all 
the words holmes, north, and carolina in any order, in that field?

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



Re: [PHP] keyword searching

2003-11-12 Thread Adam Williams
I'm using Informix SQL.  Do you know how to do full text searching on 
Informix?  If so, please share the details :)

Jay Blanchard wrote:

[snip]
I am selecting a field in a database called description for keyword 
searching.  The field contains names of people, states, years, etc.
When 
someone searches for say holmes north carolina the query searches for 
exactly that, fields which have holmes north carolina, and not fields 
that contaim holmes, north, and carolina.  So I run a str_replace to 
replace all spaces with *, which turns it into holmes*north*carolina, 
but say that north carolina is before holmes in the field, it won't
return 
those fields (it only returns fields in which holmes is infront of north

carolina).  So how can I have it return all fields which contain all 
the words holmes, north, and carolina in any order, in that field?
[/snip]

You don't say which database you are using, but several allow for full
text searching of fields where the order is inconsequential. The
behaviour you describe is preceisely how most (if not all) databases
will return a search on a standard column type.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] sql query/displaying results question

2003-10-23 Thread Adam Williams
I have a php page I am writing with an SQL query.  I am going to query the 
database for a couple of fields.  One of the fields I am querying is the 
title oh the document someone is searching for.  The title will be used at 
the top of the html page and will say:

you are searching for document number ###: document $title 

but then later on down on the page when it starts returning your results:

document $title: document $location

So I will have 1 query that needs to print the document $title at the top 
of the page and then when it starts showing results.  I won't know what 
the document title is until the database is queried (because they are 
doing a query for keywords in the documents stored in that table in the 
database).  So at the top of the page can I use my $title from the 
database and then when I start showing the results, can I show the same 
document $title from the 1st row returned if I am using a while loop, or 
because I already used $title at the top from the 1st row returned, will 
it want to start at the 2nd row returned when I start my while loop to 
return all of the data?

Adam

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



[PHP] displaying time on the server

2003-10-15 Thread Adam Williams
Hello,

I was wondering if someone knew how to display the time on the server to a 
web page that resides on that server, and have it update the time each 
second?  I was looking at javascript for this, but they all use the client 
PC viewing the page to get the time, but I want it to display the server's 
time.  any suggestions on how to do this?  Thanks!

Adam

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



[PHP] allowing access to php page by IP

2003-10-07 Thread Adam Williams
Hello,

I want to allow access to a php page but am not sure how I should verify 
the IP once I get it.  I want to allow 10.8.4.* and 10.8.5.* to access a 
certain webpage and keep everyone else out.  I have written code to figure 
out what someone's IP is, but am not sure about how I should verify 
whether the IP is in the range of 10.8.4.* or 10.8.5.*.  Any suggestions?  
I was thinking of either using a regex (but I dunno regex so I'd have to 
learn it) to stip off the .* octect and then compare the rest of the IP 
and see if its either 10.8.4 or 10.8.5, or create a for loop and loop 
through 1-254 and cat it to the end of 10.8.4. and 10.8.5. and compare it 
to the IP they are coming from.  Any suggestions on how I should do it?

Here is the code I have to get the IP:

if (getenv(HTTP_CLIENT_IP))
{
$ip = getenv(HTTP_CLIENT_IP);
}
elseif (getenv(HTTP_X_FORWARDED_FOR))
{
$ip = getenv(HTTP_X_FORWARDED_FOR);
}
elseif (getenv(REMOTE_ADDR))
{
$ip = getenv(REMOTE_ADDR);
}
else $ip = UNKNOWN;

Thanks,
Adam

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



[PHP] PHP 4.3.3 compile error

2003-09-05 Thread Adam Williams
Hello,

I'm trying to compile PHP 4.3.3.  My configure is:

./configure --enable-track-vars --without-mysql --with-mail 
--with-apxs2=/usr/local/apache2/bin/apxs --with-informix

and when doing make I get:

[EMAIL PROTECTED] php-4.3.3]# make
/bin/sh /root/php-4.3.3/libtool --silent --preserve-dup-deps 
--mode=compile gcc -I/usr/informix/incl/esql -Iext/informix/ 
-I/root/php-4.3.3/ext/informix/ -DPHP_ATOM_INC -I/root/php-4.3.3/include 
-I/root/php-4.3.3/main -I/root/php-4.3.3 -I/root/php-4.3.3/Zend 
-I/root/php-4.3.3/ext/xml/expat  -I/root/php-4.3.3/TSRM  -g -O2  
-prefer-pic -c /root/php-4.3.3/ext/informix/ifx.c -o ext/informix/ifx.lo
/root/php-4.3.3/ext/informix/ifx.ec: In function `zm_info_ifx':
/root/php-4.3.3/ext/informix/ifx.ec:402: parse error before '/' token
/root/php-4.3.3/ext/informix/ifx.ec:3127:17: operator '' has no left 
operand
make: *** [ext/informix/ifx.lo] Error 1



I'm not a programmer, so any advice on why its breaking on making the 
informix code and how to fix it would be appreciated.  Thanks!

Adam

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



[PHP] fwrite() question

2003-07-01 Thread Adam Williams
Hello,

I have a block of code:

?php
if ($_POST['news'])
{
$fp = fopen( news.txt, w);
$success = fwrite( $fp, $POST_['news'] );
fclose($fp);

if (!success)
{
echo punable to write to news.txt/p;
exit;
}

Header(Location: http://archives1.mdah.state.ms.us/news.php; );
}
?

and when I access it, I get the error:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or 
`T_NUM_STRING' in /usr/local/apache2/htdocs/updatenews.php on line 5

and line 5 is:

$success = fwrite( $fp, $POST_['news'] );

which looks ok to me.  When I take out the   around $POST_['news'] it 
doesn't generate an error, but then it doesn't write anything to news.txt.  
news.txt is owned by nobody with 755 and apache runs as nobody.

I'd appreciate any help.  Thanks!

Adam


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



Re: [PHP] fwrite() question

2003-07-01 Thread Adam Williams
Hi,

when I do that, nothing is written to news.txt, and I'm not sure why.  
This is the entire script:

?php
if ($_POST['news'])
{
$fp = fopen( news.txt, w);
$success = fwrite( $fp, $POST_['news'] );
fclose($fp);

if (!success)
{
echo punable to write to news.txt/p;
exit;
}

Header(Location: http://archives1.mdah.state.ms.us/news.php; );
}
?

html
headtitleNews update/title/head
body bgcolor=white
pPlease make your changes below and then click submit:/p
?php
if ( $_GET['action'] = update)
{

echo form action=$PHP_SELF METHOD=POST;
echo textarea name=news rows=10 cols=50 wrap=virtual;
$fp = fopen( news.txt, 'r' );
while ( ! feof ($fp) )
{
$line = fgets( $fp,  );
$line = htmlspecialchars(nl2br($line));
echo $line;
}
echo /textarea
br
input type=submit value=submit name=submit
/form;
fclose($fp);
}
?
a href=http://archives1.mdah.state.ms.us/news.php;home/a
/body/html


Adam


On Tue, 1 Jul 2003, Adrian wrote:

 you should use $_POST['news'] instead of $POST_['news'].
 ans you also should'nt put  around variables ;)
 
 
  Hello,
 
  I have a block of code:
 
  ?php
  if ($_POST['news'])
  {
  $fp = fopen( news.txt, w);
  $success = fwrite( $fp, $POST_['news'] );
  fclose($fp);
 
  if (!success)
  {
  echo punable to write to news.txt/p;
  exit;
  }
 
  Header(Location: http://archives1.mdah.state.ms.us/news.php; );
  }
 ?
 
  and when I access it, I get the error:
 
  Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or 
  `T_NUM_STRING' in /usr/local/apache2/htdocs/updatenews.php on line 5
 
  and line 5 is:
 
  $success = fwrite( $fp, $POST_['news'] );
 
  which looks ok to me.  When I take out the   around $POST_['news'] it 
  doesn't generate an error, but then it doesn't write anything to news.txt.  
  news.txt is owned by nobody with 755 and apache runs as nobody.
 
  I'd appreciate any help.  Thanks!
 
  Adam
 
 
 
 
 


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



[PHP] reading CD information

2003-02-05 Thread Adam Williams
Is it possible to have PHP read cd label information?  You know in windows
like after you put in a CD and use Windows Explorer and go to your CD rom
drive's letter it will say like D: (MSOffice2K) or D: (date of burned cd)
or D: (XPProCD), etc...If you know what I am talking about, is there a way
to have PHP read that cd label?

Adam


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




RE: [PHP] reading CD information

2003-02-05 Thread Adam Williams
It would be in the cd-rom drive of the webserver.  The CD's would be
rotated periodically and the only way I have to identify what is on each
cd and which .exe to run on it is by identifying it by its cd label.  I've
searched google and php.net but haven't found a function that can read cd
labels.  Any help is appreciated.

Adam

On Wed, 5 Feb 2003, Jon Haworth wrote:

 Hi Adam,

  Is it possible to have PHP read cd label information?

 Where is the CD?

 If it's in the CD-ROM drive of the webserver: probably.
 If it's in the CD-ROM drive of a visitor to your website: no.

 Cheers
 Jon




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




Re[2]: [PHP] reading CD information

2003-02-05 Thread Adam Williams
Thanks Tom, that works perfect!

Adam

On Thu, 6 Feb 2003, Tom Rogers wrote:

 Hi,   Adam


 TR You could try the vol command using exec{} and parse out the volume name

 TR --
 TR regards,
 TR Tom

 This should do it:
 ?
 exec(vol g:,$result);
 $label = trim(strrchr($result[0],' '));
 echo 'Label is '.$label.'br';
 ?




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




Re: [PHP] reading CD information

2003-02-05 Thread Adam Williams
Unfortunately not.  I'm putting PHP on a windows 95 computer and the
person will put a cdrom into the cd drive.  Then they will double click on
a shortcut that will run the php executable with script, and the script
will read the cd label.  depending on what the cd label is, it will call
the correct .exe file on it to load the application.

Its for a library and will be used by the general public, so I am making
it as simple as possible :)

Adam

On Wed, 5 Feb 2003, John Nichel wrote:

 Guess it's not on Linux, eh?  :)

 Adam Williams wrote:


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




Re: [PHP] Pls Help: Moving script from Win to Linux

2002-12-10 Thread Adam Williams
is register globals enabled?

On Tue, 10 Dec 2002, Shane wrote:

 Greetings gang.

 You know me, I never ask for help if I haven't checked all my other options, but 
this is day two, and I'm getting spanked on this one.

 Some recently moved scripts from a WIN2K server running PHP 4.2.1 to an Apache PHP 
4.2.3 setup have stop accepting HTML Form Variables.

 I can pass variables till I am blue in the face, even see them in the URL but they 
are still showing up as (!isset)

 My ISP (Whom is using Virtual Directories) has no solution, and I have tried every 
code variation I could think of to troubleshoot it. This code has been working fine 
for Months on the WIN2K box, but just doesn't pass a var on the Linux solution.

 Can any Server pros out there possibly throw me a bone? My deadline is looming. :^)

 As always, a million thanks in advance.
 Yours truly.
 -NorthBayShane

 --
 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 2.4.3 and Apache 2.0.x

2002-12-04 Thread Adam Williams
If you mean PHP 4.2.3, it'll work with apache 2.0, but not that great.
I'm also using PHP 4.3.0-rc2 with Apache 2.0 and its not any better.

Adam

On Wed, 4 Dec 2002, Vicente Valero wrote:

 Hello,

 PHP 2.4.3 can work with Apache 2.0.x or I need Apache 1.3.x?


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




Re: [PHP] PHP and Apache

2002-12-04 Thread Adam Williams
Yes

On Wed, 4 Dec 2002, Vicente Valero wrote:

 Excuseme my confussion, I meant PHP 4.2.3. So you suggest me PHP 4.2.3 and Apache 
1.3.x??


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




Re: [PHP] Changeing user

2002-12-04 Thread Adam Williams
change the directory ownership to the user apache runs as, or make the dir
777.

Adam

On Wed, 4 Dec 2002, [iso-8859-1] Davíð Örn Jóhannsson wrote:

 I need to be able to create dirs, chmod and other stuff on the server,
 but I get : Warning: MkDir failed (Permission denied), so
 Is there any way for me to do something so I can change the user I
 attept to execute those functions.

 Something like exec(change user, pass).

 Thanks David



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




Re: [PHP] x as a multiplier

2002-12-03 Thread Adam Williams
I don't think he's trying to multiply, I think he wants to print #x#, like
800x600 or 1024x768, etc...

Adam

On Tue, 3 Dec 2002, Kevin Stone wrote:

 Is it possible you're mistaken somehow?  x isn't an operator in PHP.
 Executing $a x $b will give you a parse error.  Anything in quotes is
 automatically casted as a string.
 -Kevin

 - Original Message -
 From: John Meyer [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, December 03, 2002 3:20 PM
 Subject: [PHP] x as a multiplier


  Code:
 
  $newwidth . x  . $newheight
 
 
  What I want to get out is a string, like 89x115.  All I am getting though,
  is one number, even though  if I do this
 
  $newwidth .  x   . $newheight
 
  It prints out just fine.  What is going on here?
 
 
  --
  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] phpUpLoad

2002-11-22 Thread Adam Williams
You either need to make the directory 777 or change the ownership of the
dir to apache or nobody (depending on which user httpd runs as)

Adam

On Fri, 22 Nov 2002, Vicky wrote:

 Yup, both directorys are chmoded to 755. Lots of users are going to use this
 script so...

 I'm still not sure what's wrong or what to do hehe.





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




Re: [PHP] how can php get the values of a group of checkbox

2002-11-21 Thread Adam Williams
user name=cb[] and PHP will automatically make the array.  then call it
with $_GET[cb][#]

Adam

On Thu, 21 Nov 2002, Xin Qi wrote:

 hi there,

 if i have a group of checkboxes, and they have the SAME name, when they are
 submited into a php script, how can this php file get the value of each
 checkbox?

 since they have the same name, $_GET[checkbox_name] only returns the last
 one.

 thanks






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




Re: [PHP] How I Got PHP4.2.2, Apache 2.0, mySQL and RedHat 8.0 towork

2002-11-19 Thread Adam Williams
Not to burst your bubble, but I'have had all of this working since the day
RedHat 8.0 was released.  Though I compiled everything by hand instead of
using RedHat's RPMs.  Just read the comments on php.net under the
apache/unix install and did what they said to add to httpd.conf for PHP.

Adam

On Mon, 18 Nov 2002, Daevid Vincent wrote:

 Well, it seems there are some glitches with and snags and other fun
 stuff to deal with when doing a straight RedHat 8.0 install. It turns
 out you have to edit your /etc/php.ini and uncomment out the
 extension=mysql.so line for starters. It also helps to set
 short_open_tag = On.

 Another fun thing to contend with is the fact that register_globals is
 now off by default, s, read this page:
 http://www.zend.com/zend/art/art-sweat4.php to see how to get around
 this (without turning RG on of course).

 I have some sites that use .php and some that use .phtml and you'd think
 it would be as simple as modifying /etc/httpd/conf.d/php.conf, dupe the
 entry and change the extension. Wrong. What I did was change it to:

 FilesMatch \.(php|phtml|phps|php4|php3)$
 SetOutputFilter PHP
 SetInputFilter PHP
 LimitRequestBody 524288
 /FilesMatch
 DirectoryIndex index.php index.phtml

 I use virtual hosts but none use SSL currently, and haven't figured that
 part out with the SSL.conf so I just renamed it to ssl.conf.disabled and
 created a virtual-hosts.conf that looks like this:

 VirtualHost *
 DocumentRoot /home/foo/public_html
 ServerName foo.com
 ServerAlias ww.foo.com *.foo.*
 ErrorLog logs/foo-error_log
 CustomLog logs/foo-access_log common
 /VirtualHost

 And at the end of the httpd.conf file you have to turn VH on by
 uncommenting NameVirtualHost *
 And I also added this at the bottom to catch all that don't match with
 an entry in my virtual-hosts.conf file above:

 VirtualHost *
 ServerAdmin webmaster@localhost
 DocumentRoot /var/www/html
 ServerName localhost
 ErrorLog /etc/httpd/logs/error_log
 CustomLog /etc/httpd/logs/access_log common
 /VirtualHost

 I also went ahead and installed mySQL-MAX, so you need to create a
 /etc/my.cnf file and put something like:

 [mysqld]

 # You can write your other MySQL server options here
 # ...

 innodb_data_home_dir=

 #  Data file(s) must be able to
 #  hold your data and indexes.
 #  Make sure you have enough
 #  free disk space.
 innodb_data_file_path = ibdata1:10M:autoextend

 #  Set buffer pool size to
 #  50 - 80 % of your computer's
 #  memory
 set-variable = innodb_buffer_pool_size=70M
 set-variable = innodb_additional_mem_pool_size=10M

 #  Set the log file size to about
 #  25 % of the buffer pool size
 set-variable = innodb_log_file_size=20M
 set-variable = innodb_log_buffer_size=8M

 #  Set ..flush_log_at_trx_commit
 #  to 0 if you can afford losing
 #  some last transactions
 innodb_flush_log_at_trx_commit=1

 set-variable = innodb_lock_wait_timeout=50
 #innodb_flush_method=fdatasync
 #set-variable = innodb_thread_concurrency=5

 skip-locking
 set-variable = max_connections=200
 #set-variable = read_buffer_size=1M
 set-variable = sort_buffer=1M
 #  Set key_buffer to 5 - 50%
 #  of your RAM depending on how
 #  much you use MyISAM tables, but
 #  keep key_buffer + InnoDB
 #  buffer pool size  80% of
 #  your RAM
 set-variable = key_buffer=10M

 Somehow the pretty /etc/rc.d/init.d/mysql script has changed (probably
 due to mysqlMax) I like the old one with the green [ OK ] messages like
 everything else there and I'm not sure how to get it back :( but it
 works for now and I have innoDB tables, so I can't complain too much.

 Hope this helps someone and saves them the nearly 7 hours I've spent
 today getting it all working. Most of that is sifting through a million
 web pages and trying to find the magic incantation on Google to get the
 solutions.

 DÆVID.
 http://daevid.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] passing multiple variables in a url

2002-11-14 Thread Adam Williams
Change the space in job enquiry to a +

Adam

On 14 Nov 2002, BigDog wrote:

 Does this not work...

 a href=contactus.php?email=directorsubject=job enquiry



 On Thu, 2002-11-14 at 14:11, CJ wrote:
  I have a contact us php script on my site that allows users to email
  direct from the webiste.  I want to be able to pass the to address and
  subject line to the script so I can call teh web page from elsewhere on the
  site and have it automatically choose the correct email address and subject
  line.
 
  EG instad of using a href=mailto:joe;bloggs.mail.com which requires them
  to have an email client set up on the machine I want to link to
  a href=contactus.php?email=director subject=job enquiry
  The script already handles the email=director by setting a default entry in
  a drop down form but I can't get it to separate the first and second
  variables in the URL.
 
  Also is this a big security risk as I will be echoing the 2nd variable as
  the contents of a form field.  Would it be possible for someone to type in
  the URL with HTML/php in it that would make a mess of everything?  How can I
  protect against this?  Would it be sufficient to just pase the 2nd variable
  for non alphabetic characters and remove them?



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




Re: [PHP] Run webscript from command line

2002-11-14 Thread Adam Williams
0 0 * * * lynx http://whatever/blah.php ; sleep 5; killall -9 lynx

Adam

On Thu, 14 Nov 2002, Aate Drageset wrote:

 Not specifically php-problem, but..
 How could i run a php-script from command line (cron.daily) using no GUI or X ??
 There should be some way of using a browser or comparable.
 my PHP is not enabled for command line script.
 Regards Aate Drageset






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




Re: [PHP] get the output from a program

2002-11-12 Thread Adam Williams
look up exec()

Adam

On Tue, 12 Nov 2002, Greg wrote:

 Hi-
 Is there a way in PHP to execute a program and then have it pass its output
 back to PHP?  Say I wanted to return the value that running df produced
 and put it in a web page?  Thanks!!
 -Greg






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




Re: [PHP] get the output from a program

2002-11-12 Thread Adam Williams
actually, look up system() I think it would be better in your case.

Adam

On Tue, 12 Nov 2002, Greg wrote:

 Hi-
 Is there a way in PHP to execute a program and then have it pass its output
 back to PHP?  Say I wanted to return the value that running df produced
 and put it in a web page?  Thanks!!
 -Greg






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




  1   2   >