[PHP] How to change the first line of a text file

2010-06-12 Thread Richard Kurth


I have around 6000 text files and I need to change the first line on every 
one of them.


The first line is the title of the article and I need it look like this 
titlethe name of the article/title


every file has the first line and the it starts the article on the second 
line


The files are in many directory under one main directory
like this

top directory
   fashion-school
   Dogs
   DentalAssistant
   etc..

I need a script that will loop through each directory look at each file 
extract the first line and replace it with the example above.
I have figured out how to pull the first line into an array but I don't no 
where to go from there to look in each directory and the write the data back 
at the top.


$f = file('GENERAL HISTORY OF DOGS.txt');
$a = 'title' . $f[0] . '/title';
echo $a;



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



[PHP] Forcing a Post of data

2009-05-05 Thread Richard Kurth

How can I force this to be a POST and not a GET
a href=customer.php?cid=1location=customeradd.php Add Customer /a
or is the only way you can pass data with a POST is from a Form submission.

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



Re: [PHP] Forcing a Post of data

2009-05-05 Thread Richard Kurth

Ashley Sheridan wrote:

On Tue, 2009-05-05 at 00:22 -0700, Richard Kurth wrote:
  

Ashley Sheridan wrote:


On Tue, 2009-05-05 at 00:09 -0700, Richard Kurth wrote:
  
  

How can I force this to be a POST and not a GET
a href=customer.php?cid=1location=customeradd.php Add Customer /a
or is the only way you can pass data with a POST is from a Form submission.




The only way you can send post data is either through the form or using
an AJAX call. In theory, you could have an onclick handler for this link
which calls the AJAX, which then alters the page when it gets the return
value. I wouldn't recommend it though, as the link would stop
functioning as a link. Why do you want to send the data through POST
anyway?


Ash
www.ashleysheridan.co.uk


  
  
Because some of the links get a lot of data in them and I would like to 
pass the info so it can't be seen. The example was small so no big deal.

It was Just a thought.



If some of the links have a lot of data in, have you thought about
trimming that down to what is necessary, and leaving the data that won't
change in a session?

  



Yes I could just pass a session number and the gather all the data out of the 
session. I might just look at that
  


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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Richard Kurth

tedd wrote:

At 6:31 PM -0700 3/14/09, Richard Kurth wrote:

I have a script that is passing a area in a $_POST and it does not pass
the data. When I try to look at the data with $_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the data is
there. This seams very strange to me. It has been working for about 6
months with no problem and then all of a sudden it does not pass the
data anymore. The real funny thing is the rest of the data that is sent
that is not an area gets past in a $_POST works just fine.Would there be
something in the php.ini file that I have changed that would case this.


What method is your form using?

Cheers,

tedd

It  is using POST as it always has but it just stopped working for the 
one post the one with an array in it.


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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Richard Kurth

Shawn McKenzie wrote:

tedd wrote:
  

At 6:31 PM -0700 3/14/09, Richard Kurth wrote:


I have a script that is passing a area in a $_POST and it does not pass
the data. When I try to look at the data with $_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the data is
there. This seams very strange to me. It has been working for about 6
months with no problem and then all of a sudden it does not pass the
data anymore. The real funny thing is the rest of the data that is sent
that is not an area gets past in a $_POST works just fine.Would there be
something in the php.ini file that I have changed that would case this.
  

What method is your form using?

Cheers,

tedd




And what is an area?  A textarea?

  
This is the form that is being sent as a post and the fieldorder[] is 
the part that is not sending properly. But it has worked for about  a 
year in the script. It just stopped working. and I did not change 
anything in this script



form action=import.php method=post
!-- form action=testimport.php method=post --
   INPUT TYPE=HIDDEN NAME=members_id VALUE=?php echo 
$_SESSION[members_id];?

   INPUT TYPE=HIDDEN NAME=copy VALUE='?php echo $_POST['copy'];?'
   INPUT TYPE=HIDDEN NAME=format VALUE=?php echo $_POST['format'];?
input type=hidden name=doit value=no

   TABLE
   /TD/TR
   TRTHfont class=fieldlabelOur Fields/font/THTHfont 
class=fieldlabelYour Data/font/TH/TR

   ?php
   /*echo $_POST['format'];
   echobr;
   echo $copy;
   echobr;*/
  
   $fieldnumber = 0;

 while (list(,$field) = each($fields)){
 echo TR\n;
 echo TDSELECT NAME=fieldorder[]\n;
 reset($possiblefields);
 reset($descriptionfields);
 $anyselected = '';

 while (list(,$description) = each($descriptionfields)){
  list(,$possible) = each($possiblefields);

 $selected = @(($fieldorder[$fieldnumber] == $possible) 
? 'SELECTED' : '');

 if ($fieldnumber = count($fieldorder)  !$anyselected){
 $selected = 'SELECTED';
 }
 echo OPTION value=\$possible\ 
$selected$description/OPTION\n;

 }
 echo /SELECT/TD\n;
 echo TD$field/TD\n;
 echo /TR\n;
 $fieldnumber++;
 }
   
  
   ?

   /TABLE
  TABLE 
   TR ALIGN=CENTER

   TDinput type=submit name='recorddelta' value='|'/TD
   TDinput type=submit name='recorddelta' value='10'/TD
   TDinput type=submit name='recorddelta' value=''/TD
   TDinput type=submit name='recorddelta' value=''/TD
   TDinput type=submit name='recorddelta' value='10'/TD
   TDinput type=submit name='recorddelta' value='|'/TD
   /TR
   TR
   TD COLSPAN=6
   Jump To: INPUT NAME=recordnumber SIZE=5 VALUE=?php 
echo $recordnumber;?

   INPUT TYPE=SUBMIT NAME=recorddelta VALUE=Jump
   /TD
   /TR
   /TABLE
   font class=fieldlabelIf the first Row is the Header Row You must 
check this box/FONT input type=checkbox name=firstheader value=

br
font class=fieldlabelPick a Category to import these contacts to/FONT
br
?php
$sqlu=SELECT value,discription FROM category WHERE members_id = 
'$_SESSION[members_id]';

radio($sqlu,'catagory','value','discription',$row[catagory]);
?   
   HR

   font class=instructions
   POnce you're happy with the fields lining up click Import/P
  
   PIDouble-check everything before you IMPORT/I/P/FONT

   INPUT TYPE=SUBMIT NAME=import VALUE=IMPORT
/FORM


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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Richard Kurth

Phpster wrote:
I don't think that fieldorder needs to be an array. I don't see you 
using it as a multiselect. Does this field occur multiple times on the 
form?


Bastien

Sent from my iPod

On Mar 15, 2009, at 11:56, Richard Kurth richardku...@centurytel.net 
wrote:



Shawn McKenzie wrote:

tedd wrote:


At 6:31 PM -0700 3/14/09, Richard Kurth wrote:

I have a script that is passing a area in a $_POST and it does not 
pass

the data. When I try to look at the data with $_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the 
data is

there. This seams very strange to me. It has been working for about 6
months with no problem and then all of a sudden it does not pass the
data anymore. The real funny thing is the rest of the data that is 
sent
that is not an area gets past in a $_POST works just fine.Would 
there be
something in the php.ini file that I have changed that would case 
this.



What method is your form using?

Cheers,

tedd




And what is an area?  A textarea?


This is the form that is being sent as a post and the fieldorder[] is 
the part that is not sending properly. But it has worked for about  a 
year in the script. It just stopped working. and I did not change 
anything in this script



form action=import.php method=post
!-- form action=testimport.php method=post --
  INPUT TYPE=HIDDEN NAME=members_id VALUE=?php echo 
$_SESSION[members_id];?

  INPUT TYPE=HIDDEN NAME=copy VALUE='?php echo $_POST['copy'];?'
  INPUT TYPE=HIDDEN NAME=format VALUE=?php echo $_POST['format'];?
   input type=hidden name=doit value=no

  TABLE
  /TD/TR
  TRTHfont class=fieldlabelOur Fields/font/THTHfont 
class=fieldlabelYour Data/font/TH/TR

  ?php
  /*echo $_POST['format'];
  echobr;
  echo $copy;
  echobr;*/
$fieldnumber = 0;
while (list(,$field) = each($fields)){
echo TR\n;
echo TDSELECT NAME=fieldorder[]\n;
reset($possiblefields);
reset($descriptionfields);
$anyselected = '';

while (list(,$description) = each($descriptionfields)){
 list(,$possible) = each($possiblefields);

$selected = @(($fieldorder[$fieldnumber] == 
$possible) ? 'SELECTED' : '');
if ($fieldnumber = count($fieldorder)  
!$anyselected){

$selected = 'SELECTED';
}
echo OPTION value=\$possible\ 
$selected$description/OPTION\n;

}
echo /SELECT/TD\n;
echo TD$field/TD\n;
echo /TR\n;
$fieldnumber++;
}
   ?
  /TABLE
 TABLETR ALIGN=CENTER
  TDinput type=submit name='recorddelta' value='|'/TD
  TDinput type=submit name='recorddelta' value='10'/TD
  TDinput type=submit name='recorddelta' value=''/TD
  TDinput type=submit name='recorddelta' value=''/TD
  TDinput type=submit name='recorddelta' value='10'/TD
  TDinput type=submit name='recorddelta' value='|'/TD
  /TR
  TR
  TD COLSPAN=6
  Jump To: INPUT NAME=recordnumber SIZE=5 VALUE=?php 
echo $recordnumber;?

  INPUT TYPE=SUBMIT NAME=recorddelta VALUE=Jump
  /TD
  /TR
  /TABLE
  font class=fieldlabelIf the first Row is the Header Row You must 
check this box/FONT input type=checkbox name=firstheader 
value=

br
font class=fieldlabelPick a Category to import these contacts 
to/FONT

br
?php
$sqlu=SELECT value,discription FROM category WHERE members_id = 
'$_SESSION[members_id]';

radio($sqlu,'catagory','value','discription',$row[catagory]);
?  HR
  font class=instructions
  POnce you're happy with the fields lining up click Import/P
PIDouble-check everything before you IMPORT/I/P/FONT
  INPUT TYPE=SUBMIT NAME=import VALUE=IMPORT
/FORM



Yes the field order does have a multiselect it selects the order that 
you what to import a list from a CVS file like first name last name 
address ets. it can have 2 up to 25 diferent selections in it. The 
question was not about that it is way can I not receive the data in that 
field as a $_POST but I can with a $_REQUEST all the other $_POSTs go 
thrue without any problem






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



Re: [PHP] Problem with passing and Area in a $_POST

2009-03-15 Thread Richard Kurth

tedd wrote:

At 8:56 AM -0700 3/15/09, Richard Kurth wrote:
This is the form that is being sent as a post and the fieldorder[] is 
the part that is not sending properly. But it has worked for about  a 
year in the script. It just stopped working. and I did not change 
anything in this script



-snip- code

If it was my problem, I see the script is riddled with 
inconsistencies. As such, I would pass it through validation to 
discover all the errors. Then I would fix those errors and then see if 
the problem continues.


Granted, some people don't think validation is important, but I'm 
positive that I could get your script to work by simply cleaning up 
the code.


Cheers,

tedd
You are probly right. But I got this script from Rasmus Lerdor about a 
year ago and I changed very little. It has worked just fine sence I 
started using it. Who am I to question Rasmus's coding.  I am now using 
$_Request to capture the array for fieldorder[] and $_POST to get the 
rest of the data.


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



[PHP] Problem with passing and Area in a $_POST

2009-03-14 Thread Richard Kurth

I have a script that is passing a area in a $_POST and it does not pass
the data. When I try to look at the data with $_POST['fieldorder'] it
its empty but when I look at it with $_REQUEST['fieldorder'] the data is
there. This seams very strange to me. It has been working for about 6
months with no problem and then all of a sudden it does not pass the
data anymore. The real funny thing is the rest of the data that is sent
that is not an area gets past in a $_POST works just fine.Would there be
something in the php.ini file that I have changed that would case this.


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



[PHP] Using a class inside of a class

2008-12-12 Thread Richard Kurth

Can I use another class inside of a function in a class


this function process_queue below is inside of a class called class mailer
I want to use the phpMailer class inside of this function so I can send 
email using smtp.

Can this be done and is there any information out there on how to do this


function process_queue($num=10){

   if (isset($this-db_settings['demo']) and 
($this-db_settings['demo'])){

   return;
   }

   $q = $this-ams-db-query(SELECT * FROM 
{$this-ams-pre}email_queue
   WHERE queue_state = 0 ORDER BY 
queue_time_added ASC LIMIT $num);


   while ($row = $this-ams-db-nqfetch($q)){

   $this-to = $row['queue_to'];
   $this-headers = $row['queue_headers'];
   $this-subject = $row['queue_subject'];
   $this-message = $row['queue_text'];

   $updateq = $this-ams-db-query(UPDATE 
{$this-ams-pre}email_queue SET

   queue_time_added = queue_time_added,
   queue_time_sent = NOW(),
   queue_state = -2 WHERE queue_id = 
{$row['queue_id']});


   if (@mail($this-to, $this-subject, $this-message, 
$this-headers)){

   $result = 1;
   }
   else{
   $result = -1;
   }

   if ($this-ams-settings['email_debug']){
   @mail ($this-ams-settings['site_email'], 
$this-subject, $this-message, $this-headers);

   }

   $updateq = $this-ams-db-query(UPDATE 
{$this-ams-pre}email_queue SET

   queue_time_added = queue_time_added,
   queue_time_sent = NOW(),
   queue_state = $result WHERE queue_id = 
{$row['queue_id']});

   }
   }

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



[PHP] how can I make an email bounce

2008-11-23 Thread Richard Kurth
I need to make a bunch of emails bounce in different ways so I can check 
to see if my script to read a mail box full of bounced emails will work 
properly.

Does any body know how I can do this.

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



[PHP] find a word in a string

2008-11-05 Thread Richard Kurth
is the a php function to find a word in a string and report back that it 
was found


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



[PHP] Catchable fatal error

2008-10-20 Thread Richard Kurth
I am getting *Catchable fatal error*: Object of class stdClass could not 
be converted to string in *C:\web\easycontactpro\openchecker.php* on 
line *49
line 49 is * $mail_head = imap_headerinfo($conn, $i); what could be 
casing this. The next line works fine if I delete line 49




   $conn = @imap_open({ . $open['host'] . : . $open['port'] . / . 
$open['mailtype'] . /notls} . $open['mbeailbox'], $open['username'], 
$open['password']);

print_r(imap_errors());

$headers = @imap_headers($conn);
if ($headers) {
 $email_count = sizeof($headers);
 for($i = 1; $i = $email_count; $i++) {
  # Check the body against all saved patterns
  $mail_head = imap_headerinfo($conn, $i);  --- Line 49
  $mail_body = imap_fetchbody($conn, $i, 1);
   echo mail head: $mail_headbr\n;
   echo mail body: $mail_bodybr\n;



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



Re: [PHP] Catchable fatal error

2008-10-20 Thread Richard Kurth

I figured it out
I am getting *Catchable fatal error*: Object of class stdClass could 
not be converted to string in *C:\web\easycontactpro\openchecker.php* 
on line *49
line 49 is * $mail_head = imap_headerinfo($conn, $i); what could be 
casing this. The next line works fine if I delete line 49




   $conn = @imap_open({ . $open['host'] . : . $open['port'] . / 
. $open['mailtype'] . /notls} . $open['mbeailbox'], 
$open['username'], $open['password']);

print_r(imap_errors());

$headers = @imap_headers($conn);
if ($headers) {
 $email_count = sizeof($headers);
 for($i = 1; $i = $email_count; $i++) {
  # Check the body against all saved patterns
  $mail_head = imap_headerinfo($conn, $i);  --- Line 49
  $mail_body = imap_fetchbody($conn, $i, 1);
   echo mail head: $mail_headbr\n;
   echo mail body: $mail_bodybr\n;
   



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



[PHP] pulling data from array

2008-09-08 Thread Richard Kurth
I am trying to pass the data from a table to a 
google.visualization.OrgChart javascript

I have converted the data to an array called $customf_array.
Look down in the script to where I need to pull the data out of the 
array to see the reset of my question



$query = SELECT * FROM member WHERE members_id = '$_SESSION[members_id]';
$result=mysql_query($query);
$row = mysql_fetch_array($result);
$memberrep=$row['repnumber'];


$query1 = SELECT sponserrep,rep,firstname,lastname,phonenumber FROM 
contacts WHERE members_id = '8' AND sponserrep != '';

$result1=mysql_query($query1);
$num_rows = mysql_num_rows($result1);
while($row1=mysql_fetch_array($result1)){
$customf_array[]=$row1[0] . , . $row1[1] . , . $row1[2] . , . 
$row1[3];

}



foreach ($customf_array as $value) {
   echo Value: $valuebr /\n;
}

this is the data that is put out by the foreach
Value: ,1234,top,manager
Value: 1342,4523,Leeann,Rodriguez
Value: 4325,,Carolyn,Sanderssandifer
Value: 1342,4567,Annie B,Scott
Value: 1234,4325,Jessica,Hobirk
Value: 1234,12356,Kaye,Meadows
Value: 1234,1342,Misty,Coe
Value: 1234,3462,Donald,Skinner



?
html
head
script type=text/javascript src=http://www.google.com/jsapi;/script
script type=text/javascript
google.load(visualization, 1, {packages:[orgchart]});
google.setOnLoadCallback(drawChart);
function drawChart() {
   var data = new google.visualization.DataTable();
   data.addColumn('string', 'Name');
   data.addColumn('string', 'Manager');
   
   
   data.addRows(? echo $num_rows?);
   data.setCell(0, 0, '? echo$row[firstname]? ? 
echo$row[lastname]?','font size=+1 color=#FF? 
echo$row[firstname]? ? echo$row[lastname]?   
/fontbr? echo$row[phonemember]?');






*look at this section***
This is what I do not understand  how to do if you can give me some 
examples on how to sort and pull this data out of the array or if there 
is a better way to do this

I have been working with this for a few days and do not no where to go

This is the section I need to loop through the array and add the data
it needs to number each recored and the add the members name according 
to the rep# and the managers name according to the  sponserrep#

$number //the recored number
$addname // the members name
$addmanager// the managers name
   
   data.setCell($number, 0, '$addname','h1$addname/h1');
   data.setCell($number, 1, '$addmanager');



*l*** 


   var table = new
google.visualization.OrgChart(document.getElementById('chart_div'));
   table.draw(data, {allowHtml:true});
}

/script/head
bodydiv id=chart_div/div/body
/html

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



[PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Richard Kurth
I am trying to read a bunch of files that are in many directors into one 
string

But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file into 
a string that is one line after another.

There is only one line per file they are email address

$file=/remote/0/13*;
$data =;
$fp = fopen($file, r);
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data

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



Re: [PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Richard Kurth

Version 5

First, which version of PHP?  PHP 5 added a lot of features for reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

I am trying to read a bunch of files that are in many directors into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file=/remote/0/13*;
$data =;
$fp = fopen($file, r);
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data




  



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



Re: [PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Richard Kurth

*I get this when I run it
Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on line *4
it does not like the *foreach (0..22 as $dirNum)

Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = $rootPath/$dirNum;
chdir($dir);
$files = glob(13*);
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
   


Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

Version 5


First, which version of PHP?  PHP 5 added a lot of features for reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  

I am trying to read a bunch of files that are in many directors into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file=/remote/0/13*;
$data =;
$fp = fopen($file, r);
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data



  
  



  



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



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Richard Kurth

*Now I get  this error
Warning*: chdir() [function.chdir]: No error (errno 0) in
*C:\web\easycontactpro\removeemail.php* on line *7*
Where can I find what errno 0 means
it loops through all the directors but does not process any of the files

foreach (range(0,22) as $dirNum)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

*I get this when I run it
Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
line *4
it does not like the *foreach (0..22 as $dirNum)


Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = $rootPath/$dirNum;
chdir($dir);
$files = glob(13*);
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
  
Thank you,

Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  

Version 5
   


First, which version of PHP?  PHP 5 added a lot of features for
reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
 
  

I am trying to read a bunch of files that are in many directors into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file=/remote/0/13*;
$data =;
$fp = fopen($file, r);
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data




  


  
  


  




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



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Richard Kurth

I had to add the full path and it works just fine.
Thanks

Well, make sure $rootPath is correct for your environment.  Also, add a
slash after the directory name.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

*Now I get  this error
Warning*: chdir() [function.chdir]: No error (errno 0) in
*C:\web\easycontactpro\removeemail.php* on line *7*
Where can I find what errno 0 means
it loops through all the directors but does not process any of the files


foreach (range(0,22) as $dirNum)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  

*I get this when I run it
Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
line *4
it does not like the *foreach (0..22 as $dirNum)
   


Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = $rootPath/$dirNum;
chdir($dir);
$files = glob(13*);
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
  Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
 
  

Version 5
  


First, which version of PHP?  PHP 5 added a lot of features for
reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  
  

I am trying to read a bunch of files that are in many directors
into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file=/remote/0/13*;
$data =;
$fp = fopen($file, r);
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data



  
  



  
  
  





  



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



[PHP] mail script not working

2008-08-04 Thread Richard Kurth

I have been trying to get this mail script to send an html message and
it just sends the html in plain text with all the html code showing.
Could somebody tell my way this will not work. When it does send it
takes a long time to go through but when I send a plan text message it
goes through right away


$plain_text =
$firstname $lastname has just accesed your web site.
They went there at $today.
It would be a good time to contact them.
$firstname $lastname Phone number is $phonenumber.
Log in at http://domain.com/login.php;;

$hmessage = html
head
   title/title
/head

body
table
tr
   tdh2$firstname $lastname has just accesed your web site.brThey
went there at font color='#FF'$today/font./h2/td
/tr
tr
   tdh3It would be a good time to contact them.br$firstname
$lastname Phone number is $phonenumber./h3
brh3Log in at a
href='http://domain.com/login.php'http://easycontactpro.com/login.php/a/h3/td
/tr
/table
/body
/html;


$from=[EMAIL PROTECTED];
$to=[EMAIL PROTECTED];
$subject=test;

# Setup mime boundary
   $mime_boundary = 'Multipart_Boundary_x'.md5(time()).'x';

   $headers  = MIME-Version: 1.0\r\n;
   $headers .= Content-Type: multipart/alternative;
boundary=\$mime_boundary\\r\n;
   $headers .= Content-Transfer-Encoding: 7bit\r\n;

   $body = This is a multi-part message in mime format.\n\n;

   # Add in plain text version
   $body.= --$mime_boundary\n;
   $body.= Content-Type: text/plain; charset=\charset=us-ascii\\n;
   $body.= Content-Transfer-Encoding: 7bit\n\n;
   $body.= $plain_text;
   $body.= \n\n;

   # Add in HTML version
   $body.= --$mime_boundary\n;
   $body.= Content-Type: text/html; charset=\UTF-8\\n;
   $body.= Content-Transfer-Encoding: 7bit\n\n;
   $body.= $hmessage;
   $body.= \n\n;


   # End email
   $body.= --$mime_boundary--\n; # -- Notice trailing --,
required to close email body for mime's

   # Finish off headers
   $headers .= From: $from\r\n;
   $headers .= X-Sender-IP: $_SERVER[SERVER_ADDR]\r\n;
   $headers .= 'Date: '.date('n/d/Y g:i A').\r\n;

   # Mail it out
   mail($to, $subject, $body, $headers);



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



Re: [PHP] limiting the amount of emails sent at a time in a batch send

2008-07-31 Thread Richard Kurth

Andrew Ballard wrote:

On Thu, Jul 31, 2008 at 4:24 PM, brian [EMAIL PROTECTED] wrote:
  

Andrew Ballard wrote:


On Thu, Jul 31, 2008 at 1:27 PM, brian [EMAIL PROTECTED] wrote:
  

Richard Kurth wrote:


I want to limit these script two send 100 email and then pause for a few
seconds and then send another 100 emails and repeat this tell it has
sent
all the emails that are dated for today. This script is runs by cron so
it
is running in the background.

How would I do this and is it the best way to do it. I am using swift
mailer to send the mail.

I think I would use limit 100 in the query but how would I tell it to
get
the next 100.
  

There's no need to limit the DB query, nor to track what's been sent by
updating the DB. Grab all of the addresses at once and let SwiftMailer
deal
with the throttling:

require('Swift/lib/Swift.php');
require('Swift/lib/Swift/Connection/SMTP.php');

/* this handles the throttling
 */
require('Swift/lib/Swift/Plugin/AntiFlood.php');


/* this holds all of your addresses
 */
$recipients = new Swift_RecipientList();


/* Grab the addresses from the DB (this is using MDB2)
 */
$result = ...

while ($row = $result-fetchRow())
{
  $recipients-addTo($row['address'], $row['name']);
}
@$result-free();

try
{
  $swift = new Swift(new Swift_Connection_SMTP('localhost'),
'your_domain');

  set_time_limit(0);
  $swift-log-enable();

  /* 100 mails per batch with a 60 second pause between batches
   */
  $swift-attachPlugin(new Swift_Plugin_AntiFlood(100, 60),
'anti-flood');

  flush();

  $message = new Swift_Message('your subject');

  $message-setCharset('utf-8');
  $message-setReplyTo(...);
  $message-setReturnPath(...);
  $message-headers-set('Errors-To', ...);

  $message-attach(new Swift_Message_Part($plain_content));
  $message-attach(new Swift_Message_Part($html_content,
'text/html'));

  $num_sent = $swift-batchSend($message, $recipients, new
Swift_Address(..., '...'));

  $swift-disconnect();

...


This is a rough example taken from my own script. This would need to be
modified if you're not sending the same message to all recipients, of
course. It's not clear to me from your example.

b



Nice! I'll have to look into this library some time. How do you
control it to prevent sending the same message though?
  

I'm not sure about that. Mine is for a newsletter (not personalised) so
Swift just needs a list of addresses. I can't remember if AntiFlood can be
used for many unique mails. I suspect that it doesn't.



I can't imagine
this is called from a web page, because I'm guessing it would take a
few minutes to finish.
  

cron. But, if you wanted it fired from an admin page (I can't imagine a good
situation where something like this would be public) you could add
ignore_user_abort() and then jazz up the page with some async JS.

If it's called from a cron job, don't you still


have to somehow flag the message as having been delivered so that the
next process doesn't come along and send the same thing all over
again?
  

Yeah, I just twigged to the fact that your messages are stored in the
database. This is some kind of messaging system? As opposed to a
newsletter-type thing, I mean. As above, I don't know that AntiFlood  is
what you want. That's meant for multiple-recipient mails.

There's also a Throttler plugin, though, again, it's meant for batches.

You might also look at the IMAP functions. Instead of storing the messages
in the DB, you can let the MTA deal with pushing them out and cut Swift (and
the cro0n job) out of the loop.

b




The case I have in mind is for a newsletter, and in this instance they
are all the same. In this instance, I am limited by the host to 2500
messages/hour. (Originally it was 900). At this point, 2500 is more
than enough for this group, but I'd still like to play kindly with the
server resources since this is a shared host. I just set up a generic
message queue and dump mail there rather than sending it real time.
For now, all the messages in a given batch are the same, but I was
leaving flexibility in case I hit a situation where that changed.

It looks like this would work pretty well when I'm up for a rewrite. :)

I understand the general idea:

1. read message body from storage (file, database, etc.)
2. get result set containing addresses from database
3. build recipient list from result set
4. send everything to sendBatch()

It seems to me that step 5 still has to either (a) delete the message
body from storage or else (b) flag it as sent so that the next process
spawned via cron sees that there is no work to do and dies rather than
repeating the whole process again.

Andrew
  


Thanks to everybody.
I have figured this out. I am using swift but I am limiting the send by 
a 100 and setting the table with the date sent. Then the crontab runes 
again and grabs another 100 that have not had the date set

[PHP] limiting the amount of emails sent at a time in a batch send

2008-07-29 Thread Richard Kurth
I want to limit these script two send 100 email and then pause for a few 
seconds and then send another 100 emails and repeat this tell it has 
sent all the emails that are dated for today. This script is runs by 
cron so it is running in the background.


How would I do this and is it the best way to do it. I am using swift 
mailer to send the mail.


I think I would use limit 100 in the query but how would I tell it to 
get the next 100.


$today = date(Y-m-d);
# Cache the Contact that will recive campain messages today
$query = SELECT emailmessages. * , contacts.* FROM emailmessages, 
contacts WHERE emailmessages.contact_id = contacts.id  AND 
emailmessages.nextmessagedate = '$today' AND contacts.emailstatus = 
'Active';  
$DB_Contact_Result = mysql_query($query);

if (!$DB_Contact_Result) {
   die('Invalid query: ' . mysql_error());
}
while ($this_row = mysql_fetch_array ($DB_Contact_Result)){

$CustomerID=$this_row[id];

//get the message for the contact
$query1 = SELECT * FROM emailcampaign where member_id = 
'$this_row[members_id]' AND campaign_id = '$this_row[emailcampaign]' AND 
day = '$this_row[email_number]';


$DB_Mail_Result =  mysql_query($query1);
if (!$DB_Mail_Result) {
   die('Invalid query: ' . mysql_error());
}
$Mail_row = mysql_fetch_array($DB_Mail_Result);
//get member stuff
$query2 = SELECT * FROM member where members_id = 
'$this_row[members_id]';


$DB_Member_Result =  mysql_query($query2);
 if (!$DB_Member_Result) {
   die('Invalid query: ' . mysql_error());
}

$subject=stripslashes($Mail_row['subject']);

$message=stripslashes($Mail_row['textmessage']);

$hmessage=stripslashes($Mail_row['htmlmessage']);

$swiftPlain = $message;
$MailFrom1=$this_row['emailaddress'];
$MailFromName1=$this_row['firstname'];

$full_name=stripslashes($this_row['firstname']) .  . 
stripslashes($this_row['lastname']);

//Create the message
$message = new Swift_Message($subject);
$message-attach(new Swift_Message_Part($swiftPlain));
$message-attach(new Swift_Message_Part($swiftHtml, text/html));
$message-setReturnPath($MailAddReplyTo);
$message-setReplyTo($MailFrom1,$MailFromName1);
//Now check if Swift actually sends it
$swift-send($message, 
$this_row['emailaddress'],$MailFrom1,$MailFromName1);


#After we send the email we need to update the database to send the next 
message

# get the next message number
$nextday=getnextday(stripslashes($this_row['emailcampaign']),stripslashes($this_row['members_id']),stripslashes($this_row['email_number']));
# get the new dates
$newdate=getnewdate(stripslashes($this_row['emailstarted']),$nextday);
#update the emailmessages
//unsubscribecode
updateemailmessages($unpass,$nextday,$newdate,stripslashes($this_row['em_id']),stripslashes($this_row['email_number']));



}//end of mail loop


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



Re: [PHP] limiting the amount of emails sent at a time in a batch send

2008-07-29 Thread Richard Kurth

Andrew Ballard wrote:

On Tue, Jul 29, 2008 at 4:52 PM, Richard Kurth
[EMAIL PROTECTED] wrote:
  

I want to limit these script two send 100 email and then pause for a few
seconds and then send another 100 emails and repeat this tell it has sent
all the emails that are dated for today. This script is runs by cron so it
is running in the background.

How would I do this and is it the best way to do it. I am using swift mailer
to send the mail.

I think I would use limit 100 in the query but how would I tell it to get
the next 100.

$today = date(Y-m-d);
# Cache the Contact that will recive campain messages today
$query = SELECT emailmessages. * , contacts.* FROM emailmessages, contacts
WHERE emailmessages.contact_id = contacts.id  AND
emailmessages.nextmessagedate = '$today' AND contacts.emailstatus =
'Active';  $DB_Contact_Result = mysql_query($query);
if (!$DB_Contact_Result) {
  die('Invalid query: ' . mysql_error());
}
while ($this_row = mysql_fetch_array ($DB_Contact_Result)){

$CustomerID=$this_row[id];

//get the message for the contact
$query1 = SELECT * FROM emailcampaign where member_id =
'$this_row[members_id]' AND campaign_id = '$this_row[emailcampaign]' AND day
= '$this_row[email_number]';

   $DB_Mail_Result =  mysql_query($query1);
   if (!$DB_Mail_Result) {
  die('Invalid query: ' . mysql_error());
}
   $Mail_row = mysql_fetch_array($DB_Mail_Result);
   //get member stuff
   $query2 = SELECT * FROM member where members_id =
'$this_row[members_id]';

   $DB_Member_Result =  mysql_query($query2);
if (!$DB_Member_Result) {
  die('Invalid query: ' . mysql_error());
}

$subject=stripslashes($Mail_row['subject']);

$message=stripslashes($Mail_row['textmessage']);

$hmessage=stripslashes($Mail_row['htmlmessage']);

$swiftPlain = $message;
$MailFrom1=$this_row['emailaddress'];
$MailFromName1=$this_row['firstname'];

$full_name=stripslashes($this_row['firstname']) .  .
stripslashes($this_row['lastname']);
//Create the message
$message = new Swift_Message($subject);
$message-attach(new Swift_Message_Part($swiftPlain));
$message-attach(new Swift_Message_Part($swiftHtml, text/html));
$message-setReturnPath($MailAddReplyTo);
$message-setReplyTo($MailFrom1,$MailFromName1);
//Now check if Swift actually sends it
$swift-send($message, $this_row['emailaddress'],$MailFrom1,$MailFromName1);

#After we send the email we need to update the database to send the next
message
# get the next message number
$nextday=getnextday(stripslashes($this_row['emailcampaign']),stripslashes($this_row['members_id']),stripslashes($this_row['email_number']));
# get the new dates
$newdate=getnewdate(stripslashes($this_row['emailstarted']),$nextday);
#update the emailmessages
//unsubscribecode
updateemailmessages($unpass,$nextday,$newdate,stripslashes($this_row['em_id']),stripslashes($this_row['email_number']));



}//end of mail loop




I've done something very similar. I have a delivery timestamp column
in the table that is initially NULL, and I set it to UTC_TIMESTAMP()
for each row as I send the message. My query looks like this then:

SELECT * FROM mail_queue WHERE delivery_timestamp IS NULL LIMIT 100.

Andrew

  

Then what do you do to get the next 100 emails without sending the same ones

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



[PHP] Problem with using array_diff and array_combine

2008-07-28 Thread Richard Kurth

I hope I can explain what I am trying to do.
I have two tables the first one has the custom form elements


elements_id elements_field_type elements_field_caption members_id
  35  text   test  8
  36  text   test2 8


The second one has the customer id and the field value withe the field name

dbelements_field_name   dbelements_field_value  members_id customer_id
  35   Test This Field   8346
  36 8346
  36   Test2 8347


If you look at the second table you will see that one field name is
related to two different  customers and one field name on relates to one 
customer.

I am trying to look at these two tables and find customer that do not
have a row for each field name.

I have been trying with

array_combine($dbelements_field_array,$dbelements_id_array)
and also array_diff($customf_array,$dbelements_field_array)

This are the tables  I /am using to create the arrays

/$contactsql = SELECT * FROM contacts WHERE members_id = '8';
$contact_result = |mysql_query|($contactsql);
while($contact_row=mysql_fetch_array($contact_result)){
$contactid_array[] = $contact_row['id'];
}
$sql1 = SELECT * FROM dbelements WHERE members_id = '8';
$sql_result1 = |mysql_query|($sql1);
while($row1=mysql_fetch_array($sql_result1)){
$dbelements_field_array[]=$row1[customer_id];
$dbelements_field_array[].=$row1[dbelements_field_name];
}

$sql2 = SELECT * FROM customformelements WHERE members_id = '8';
$sql_result2 =  |mysql_query|($sql2);
while($row2=mysql_fetch_array($sql_result2)){
$customf_array[]=$row2[formelements_id];
}

Could somebody get me going in the right directions




--
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] Problem with using array_diff and array_combine

2008-07-27 Thread Richard Kurth

I hope I can explain what I am trying to do.

I have two tables the first one has the custom form elements


formelements_id formelements_field_type formelements_field_caption 
members_id

35  texttest8
36  texttest2   8


The second one has the customer id and the field value withe the field
name



dbelements_field_name   dbelements_field_value  members_id  customer_id
35  Test This Field 8   346
36  8   346
36   Test2  8   347


If you look at the second table you will see that one field name is
related to two different  customers
and one field name on relates to one customer.

I am trying to look at these two tables and find customer that do not
have a row for each field name.
I have been trying with
array_combine($dbelements_field_array,$dbelements_id_array)
and also
array_diff($customf_array,$dbelements_field_array)

This are the tables  I /am using to create the arrays

/$contactsql = SELECT * FROM contacts WHERE members_id = '8';
$contact_result = |mysql_query|($contactsql);
while($contact_row=mysql_fetch_array($contact_result)){
$contactid_array[] = $contact_row['id'];
}
$sql1 = SELECT * FROM dbelements WHERE members_id = '8';
$sql_result1 = |mysql_query|($sql1);
while($row1=mysql_fetch_array($sql_result1)){
$dbelements_field_array[]=$row1[customer_id];
$dbelements_field_array[].=$row1[dbelements_field_name];
}

$sql2 = SELECT * FROM customformelements WHERE members_id = '8';
$sql_result2 =  |mysql_query|($sql2);
while($row2=mysql_fetch_array($sql_result2)){
$customf_array[]=$row2[formelements_id];
}

Could somebody get me going in the right directions




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



[PHP] looping through a database

2008-06-16 Thread Richard Kurth
I am looping through a database of files that are numbers 1 through 10 
if  number 1 is in the database I what to print out the first table 
below if it is not then print the else section below. Then loop through 
the database to see if 2 through 10 are there and do the same thing. Of 
course what I am doing does not work. Should I move it all to an array 
and then loop through it. Or use a foreach loop.

Could you please give me an idea where to start looking

while($row=mysql_fetch_array($sql_result)){

if ($row[number]==1) {
tr
td File 1/td
tdThis is the file/td
tdDelete/td
/tr
}else{
tr
tdFile1/td
td/td
tdAdd/td
/tr
}

}

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



Re: [PHP] looping through a database

2008-06-16 Thread Richard Kurth

Wolf wrote:

Richard Kurth wrote:
I am looping through a database of files that are numbers 1 through 
10 if  number 1 is in the database I what to print out the first 
table below if it is not then print the else section below. Then loop 
through the database to see if 2 through 10 are there and do the same 
thing. Of course what I am doing does not work. Should I move it all 
to an array and then loop through it. Or use a foreach loop.

Could you please give me an idea where to start looking

while($row=mysql_fetch_array($sql_result)){

if ($row[number]==1) {
tr
td File 1/td
tdThis is the file/td
tdDelete/td
/tr
}else{
tr
tdFile1/td
td/td
tdAdd/td
/tr
}

}



What is the query being executed?

Seriously, this needs more information.  On the upside, it LOOKS like 
it should work, however...


Here's what I use to get 1 random quote from a table I have:
--
$query=select quote from quotes where id=$id;
$query_res = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($query_res)  1)
{ //print message
 $display_block = PSomething blew up./P;
}
else
{ //get info and build Quote display
 $Quote = mysql_fetch_array($query_res);
 echo $Quote['quote'];
}


It could be as simple as the  not working where you really need '  
but that depends on what/how you are doing things.


Wolf




This is the query being executed
$sql = SELECT * FROM table WHERE members_id = . $_SESSION[members_id];
$sql_result = mysql_query($sql) or die(mysql_error());

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



Re: [PHP] creating an xls file from mysql data

2008-05-13 Thread Richard Kurth

Chris wrote:

Richard Kurth wrote:
  

This script will create an xls file from the data that is sent to it
When I run this it only gets one recored and it is supposet to get all
the records that are past by the  $_POST[selectedcontactlist]
I think I have a } in the wrong place but I can not figure it out
anybody have a suggestion

$_POST[selectedcontactlist]=3,45,65,23,12,4,56; //this is a sample of
what is past

$ExplodeIt = explode(,,rtrim($_POST[selectedcontactlist],,));
$Count = count($ExplodeIt);
for ($i=0; $i  $Count; $i++) {
$sql = SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]';



Instead of doing that, do this:

/**
* This section makes sure the id's you are going to use in your query
are actually integer id's.
* If they aren't, you'll get an sql error.
*
*/
$ids = array();
foreach ($_POST['selectedcontactlist'] as $id) {
  if (!is_int($id)) {
continue;
  }
  $ids[] = $id;
}

// all posted values are duds? show an error.
if (empty($ids)) {
  echo No id's are numeric, try again;
  exit;
}

$sql = select * from contacts where id in ( . implode(',', $ids) . );


That'll get everything for all of those id's and then you can loop over
it all once:

// print out the header for the csv file here.

// then loop over the results:
while ($row = mysql_fetch_assoc($sql_result)) {
  // put it into file here.
}

// close the file
// print it out.

  

This is what the $_POST['selectedcontactlist'] looks like

121,17,97,123,243,52,138,114,172,170,64,49,60,256,176,244,201,42,95,4,

it is not coming across as an array so the foreach is throwing an error

how can I make this an array in the proper format.

This number are selected in a checkbox and passed with a javascript to the 
script should I be converting them to an array in the javascript.
this is the javascript that is passing the numbers.

function exportContacts(theform)
{
   //theform.action = cmexport.php;

   theform.action=cmexport.php;
   if (getSelectedContacts(theform) != )
   {
   theform.submit();
   }
   else
   {
   alert(Please select contacts to export by checking the boxes to the 
left of the contact's name.);
   }
}


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



[PHP] creating an xls file from mysql data

2008-05-12 Thread Richard Kurth


This script will create an xls file from the data that is sent to it
When I run this it only gets one recored and it is supposet to get all
the records that are past by the  $_POST[selectedcontactlist]
I think I have a } in the wrong place but I can not figure it out
anybody have a suggestion

$_POST[selectedcontactlist]=3,45,65,23,12,4,56; //this is a sample of
what is past

$ExplodeIt = explode(,,rtrim($_POST[selectedcontactlist],,));
$Count = count($ExplodeIt);
for ($i=0; $i  $Count; $i++) {
$sql = SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]';
$sql_result = query($sql);
$count = mysql_num_fields($sql_result);

for ($i = 0; $i  $count; $i++){
   $header .= mysql_field_name($sql_result, $i).\t;
}

while($row = mysql_fetch_row($sql_result)){
 $line = '';
 foreach($row as $value){
   if(!isset($value) || $value == ){
 $value = \t;
   }else{
# important to escape any quotes to preserve them in the data.
 $value = str_replace('', '', $value);
# needed to encapsulate data in quotes because some data might be multi
line.
# the good news is that numbers remain numbers in Excel even though quoted.
 $value = '' . $value . '' . \t;
   }
   $line .= $value;
 }
 $data .= trim($line).\n;
}
}
# this line is needed because returns embedded in the data have \r
# and this looks like a box character in Excel
 $data = str_replace(\r, , $data);


# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.
if ($data == ) {
 $data = \nno matching records found\n;
}

# This line will stream the file to the user rather than spray it across
the screen
header(Content-type: application/octet-stream);

# replace excelfile.xls with whatever you want the filename to default to
header(Content-Disposition: attachment; filename=excelfile.xls);
header(Pragma: no-cache);
header(Expires: 0);

echo $header.\n.$data;



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



[PHP] creating an xls file from mysql data

2008-05-11 Thread Richard Kurth


This script will create an xls file from the data that is sent to it
When I run this it only gets one recored and it is supposet to get all 
the records that are past by the  $_POST[selectedcontactlist]
I think I have a } in the wrong place but I can not figure it out 
anybody have a suggestion


$_POST[selectedcontactlist]=3,45,65,23,12,4,56; //this is a sample of 
what is past


$ExplodeIt = explode(,,rtrim($_POST[selectedcontactlist],,));
$Count = count($ExplodeIt);
for ($i=0; $i  $Count; $i++) {
$sql = SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]';
$sql_result = query($sql);
$count = mysql_num_fields($sql_result);

for ($i = 0; $i  $count; $i++){
   $header .= mysql_field_name($sql_result, $i).\t;
}

while($row = mysql_fetch_row($sql_result)){
 $line = '';
 foreach($row as $value){
   if(!isset($value) || $value == ){
 $value = \t;
   }else{
# important to escape any quotes to preserve them in the data.
 $value = str_replace('', '', $value);
# needed to encapsulate data in quotes because some data might be multi 
line.

# the good news is that numbers remain numbers in Excel even though quoted.
 $value = '' . $value . '' . \t;
   }
   $line .= $value;
 }
 $data .= trim($line).\n;
}
}
# this line is needed because returns embedded in the data have \r
# and this looks like a box character in Excel
 $data = str_replace(\r, , $data);


# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.
if ($data == ) {
 $data = \nno matching records found\n;
}

# This line will stream the file to the user rather than spray it across 
the screen

header(Content-type: application/octet-stream);

# replace excelfile.xls with whatever you want the filename to default to
header(Content-Disposition: attachment; filename=excelfile.xls);
header(Pragma: no-cache);
header(Expires: 0);

echo $header.\n.$data;


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



[PHP] Setting up a program that can be accessed by all domain on a server

2008-05-08 Thread Richard Kurth
I have a program that I am writing that I what to install on my server 
that can be accessed by all domains on the server just like it was on 
there domain. Could somebody give me an idea on how I can do this or 
point me to some article that tells how to set this up.


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



Re: [PHP] Setting up a program that can be accessed by all domain on a server

2008-05-08 Thread Richard Kurth

Dan Joseph wrote:

On Thu, May 8, 2008 at 11:47 AM, Richard Kurth [EMAIL PROTECTED]
wrote:

  

I have a program that I am writing that I what to install on my server that
can be accessed by all domains on the server just like it was on there
domain. Could somebody give me an idea on how I can do this or point me to
some article that tells how to set this up.

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





Accessible as in able to talk to it and pull information, or be able to
integrate it into the web site?  If its just needing to get data, you could
build a web service and give access to it for all other domains.
  
To Be able to integrate it into the web site is what I am trying to 
figure out



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



Re: [PHP] Setting up a program that can be accessed by all domain on a server

2008-05-08 Thread Richard Kurth

Dan Joseph wrote:

On Thu, May 8, 2008 at 11:54 AM, Richard Kurth [EMAIL PROTECTED]
wrote:

  

Dan Joseph wrote:



On Thu, May 8, 2008 at 11:47 AM, Richard Kurth 
[EMAIL PROTECTED]
wrote:



  

I have a program that I am writing that I what to install on my server
that
can be accessed by all domains on the server just like it was on there
domain. Could somebody give me an idea on how I can do this or point me
to
some article that tells how to set this up.

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






Accessible as in able to talk to it and pull information, or be able to
integrate it into the web site?  If its just needing to get data, you
could
build a web service and give access to it for all other domains.


  

To Be able to integrate it into the web site is what I am trying to figure
out




You should be able to configure Apache (assuming you're using Apache) in a
way that for instance:  http://domain.com/globalapplication/ would be
pointing to a specified folder.  You would just have to tell it to make that
path for all domains on the server.  Although that might be better suited
for someone on an Apache list or forum to explain better.

  

Thanks that is what I needed to know I will now check on an apache list

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



[PHP] problem with for loop

2008-05-02 Thread Richard Kurth
Way does my for loop not complete the task if there are 4 emails it only 
process 3 emails through the foreach loop if there is 3 it only process 2


#  Connect up
$host =domain.com;
$port =110;
$mailtype = pop3;
$mailbox =INBOX;
$username =[EMAIL PROTECTED];
$password =boat1234;
   
$conn = @imap_open({ . $host . : . $port . / . $mailtype . 
/notls} . $mailbox, $username, $password);


$number=imap_num_msg($conn);
for($i = 1; $i = $number; $i++) {
$file=C:\web\bouncehandler\eml\em$i;
imap_savebody($conn,$file,$i);


$file=file_get_contents(C:\web\bouncehandler\eml\em$i);
$multiArray = Bouncehandler::get_the_facts($file);

$EMAIL = $the['recipient'];
foreach($multiArray as $the){
   switch($the['action']){
   case 'failed':
   $sql=UPDATE contacts SET emailstatus = 'Fatal-Bounced' WHERE 
emailaddress = '$EMAIL';
   mysql_query($sql) or die(Invalid query:  . mysql_error());
   break;

   case 'transient':
   $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE 
emailaddress = '$EMAIL';

   mysql_query($sql) or die(Invalid query:  . mysql_error());
   break;
   case 'autoreply':
   $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE 
emailaddress = '$EMAIL';

   mysql_query($sql) or die(Invalid query:  . mysql_error());
   break;
   default:
   //don't do anything
   break;
   }
   }

}



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



Re: [PHP] problem with for loop

2008-05-02 Thread Richard Kurth

Nathan Nobbe wrote:
On Fri, May 2, 2008 at 1:20 AM, Richard Kurth 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


Way does my for loop not complete the task if there are 4 emails
it only process 3 emails through the foreach loop if there is 3 it
only process 2

$file=file_get_contents(C:\web\bouncehandler\eml\em$i);
$multiArray = Bouncehandler::get_the_facts($file);


have you checked $multiArray here to verify it has the number of 
emails you expect there are to be processed ?


 


$EMAIL = $the['recipient'];
foreach($multiArray as $the){
  switch($the['action']){
  case 'failed':
  $sql=UPDATE contacts SET emailstatus = 'Fatal-Bounced'
WHERE emailaddress = '$EMAIL';
  mysql_query($sql) or die(Invalid query:  . mysql_error());
  break;
  case 'transient':
  $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE
emailaddress = '$EMAIL';
  mysql_query($sql) or die(Invalid query:  . mysql_error());
  break;
  case 'autoreply':
  $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE
emailaddress = '$EMAIL';
  mysql_query($sql) or die(Invalid query:  . mysql_error());
  break;
  default:
  //don't do anything
  break;
  }


have you done any logging, or error checking to see if one (or more) 
of the emails isnt falling into the default case of the switch 
statement ?

-nathan

Yes I have it is just no processing the last email. I have even printed 
them out before the foreach and it always comes out one less that there 
are emails.
It is downloading the correct amount and creating them in the directory 
it is just not passing the last one on



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



[PHP] problem imap_headerinfo

2008-04-30 Thread Richard Kurth
I get a *Catchable fatal error*: Object of class stdClass could not be 
converted to string  on this line  $mail_head = imap_headerinfo($conn, $i);
if I remove it it works fine what would be casing this I really need to 
read the header. I am using php version  5.2.5


$conn = @imap_open({ . $bouncer['host'] . : . $bouncer['port'] . / 
. $bouncer['mailtype'] . /notls} . $bouncer['mailbox'], 
$bouncer['username'], $bouncer['password']);

$headers = @imap_headers($conn);
   if ($headers) {
 $email_count = sizeof($headers);
 for($i = 1; $i = $email_count; $i++) {
  # Check the body against all saved patterns
  $mail_head = imap_headerinfo($conn, $i); 
  $mail_body = imap_fetchbody($conn, $i, 1);

   echo mail head: $mail_headbr\n;
   echo mail body: $mail_bodybr\n;


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



Re: [PHP] reading Qmail boxes

2008-04-26 Thread Richard Kurth

Manuel Lemos wrote:

Hello,

Richard Kurth wrote:
  

I what to read the email headers that are in a Qmail mailbox so that I
can run it threw a filter and see what mail bounced for what reason.
How do I do this being that the ownership on Qmail mailboxes are
diferent from  the  owner that runs php and apache



You can use this class to parse the messages and extract the addresses
from bouncing messages.

http://www.phpclasses.org/mimeparser

  
I have looked at this many times I just can't figure out how to use it. 
All I what to do is grab the mail out of the mailbox and see way it bounced

then add that info to my program for the email user that sent it.

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



[PHP] reading Qmail boxes

2008-04-25 Thread Richard Kurth
I what to read the email headers that are in a Qmail mailbox so that I 
can run it threw a filter and see what mail bounced for what reason.
How do I do this being that the ownership on Qmail mailboxes are 
diferent from  the  owner that runs php and apache


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



[PHP] open_basedir restriction in effect

2008-04-24 Thread Richard Kurth
*I keep getting this warning when I try run my script that I what to 
look at the data in the mailbox for bounced email


Warning*: opendir() [function.opendir 
http://easycontactpro.com/function.opendir]: open_basedir restriction 
in effect. 
File(/var/qmail/mailnames/easycontactpro.com/bounce/Maildir/new) is not 
within the allowed path(s): 
(/var/www/vhosts/easycontactpro.com/httpdocs:/tmp)



I have set open_basedir 
=/var/qmail/mailnames/easycontactpro.com/bounce/Maildir/new in the 
php.ini file and restarted apache.


How can I look at the files in this directory

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



[PHP] Opening a new window from Header Location or any other way

2008-04-20 Thread Richard Kurth

I have my login.php file that when I access the login fields they are in
a small window width=400,height=250. When I click on submit I what it to
close this window and open another full window with the web page that
the script directs it to. But nomater what I do it opens it in the same
window which is to small. Is there anyway to make it open the window up
or close it and open another full window. I know PHP is server side and
it does not have control of the client.

Of course this does not work. Is there a way to do this in javascript or
something else.
$link = http://www.domain.com/main.php target=\_blank\;
   header(Location:$link);
   ob_end_flush();
   exit;



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



[PHP] pulling text from a file

2008-03-21 Thread Richard Kurth
I have a text file that looks like the one below. I need to read the 
file into a database.

I was trying the script below but is not working can you help?

$lines = file_get_contents('clientlist1.txt');

$find=Address:;
$f= strstr($f,$find);
$separat=City:;
$ADDRESS = substr($f, 0, strpos($f,$separat));
$ADDRESS=ltrim($ADDRESS,Address:);
$ADDRESS=trim($ADDRESS);
echo $ADDRESS;
echo br;

$find=City:;
$f= strstr($f,$find);
$separat=State:;
$CITY = substr($f, 0, strpos($f,$separat));
$CITY=ltrim($CITY,City:);
$CITY=trim($CITY);
echo $CITY;
echo br;

Text File

Address:  5070 myaddress.
City: mycity State: mystateZip: 97268
County: 


Signers
Name: my name

Address:  3925 myaddress.
City: mycity2 State: mystate2 Zip: 97268
County: 


Signers
Name: my name2

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



Re: [PHP] pulling text from a file

2008-03-21 Thread Richard Kurth

Richard Kurth wrote:
I have a text file that looks like the one below. I need to read the 
file into a database.

I was trying the script below but is not working can you help?

$lines = file_get_contents('clientlist1.txt');

$find=Address:;
$f= strstr($f,$find);
$separat=City:;
$ADDRESS = substr($f, 0, strpos($f,$separat));
$ADDRESS=ltrim($ADDRESS,Address:);
$ADDRESS=trim($ADDRESS);
echo $ADDRESS;
echo br;

$find=City:;
$f= strstr($f,$find);
$separat=State:;
$CITY = substr($f, 0, strpos($f,$separat));
$CITY=ltrim($CITY,City:);
$CITY=trim($CITY);
echo $CITY;
echo br;

Text File

Address:  5070 myaddress.
City: mycity State: mystateZip: 97268
County:
Signers

Name: my name

Address:  3925 myaddress.
City: mycity2 State: mystate2 Zip: 97268
County:
Signers

Name: my name2


Never mined I forgot to change $line to $f

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



[PHP] Run Process in back ground

2008-02-11 Thread Richard Kurth
Is there a way that I can call a function that will send an email and 
then move on redirecting to another website without having to what for 
the email to send?

SendEmail($memberemail,$MailFrom,$MailHost);
header(Location:http://domain.com;);

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



[PHP] looping through a $_POST variable

2007-12-30 Thread Richard Kurth
I am trying to loop through a $_POST variable.   It comes  from a text 
area and it will have data like many email address or just one listed 
with a space or on a new line. I can't seam to get the data to extract 
properly. I have tried this below


$array = explode(' ', $_POST['emails']);
foreach ($array as $value) {
$sql = SELECT id FROM contacts where emailaddress = '$value' AND 
members_id = '$memberid';

$sql_result=safe_query($sql);
while ($row=mysql_fetch_array($sql_result)){
$id = $row[id];
$sql1=UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id = '$id';
safe_query($sql1);
}}

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



Re: [PHP] looping through a $_POST variable

2007-12-30 Thread Richard Kurth
I am trying to get one email at a time and run it through the loop and 
process it but if I have more than one email in the text area it gives 
me nothing and does not run

What kind of problems are you having in extracting the data?

On Dec 30, 2007, at 4:29 PM, Richard Kurth wrote:

I am trying to loop through a $_POST variable.   It comes  from a 
text area and it will have data like many email address or just one 
listed with a space or on a new line. I can't seam to get the data to 
extract properly. I have tried this below


$array = explode(' ', $_POST['emails']);
foreach ($array as $value) {
$sql = SELECT id FROM contacts where emailaddress = '$value' AND 
members_id = '$memberid';

$sql_result=safe_query($sql);
while ($row=mysql_fetch_array($sql_result)){
$id = $row[id];
$sql1=UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id = 
'$id';

safe_query($sql1);
}}

--
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] looping through a $_POST variable

2007-12-30 Thread Richard Kurth

When I do a var_dump($_POST['emails']); it has all the emails in it
string(65) [EMAIL PROTECTED] [EMAIL PROTECTED] 
[EMAIL PROTECTED]

I will validate the emails after I get the loop to work
$memberid comes from a part of the script I did not show you  $memberid 
=$_POST[members_id];

safe_query  is a function that I call that does query stuff

function safe_query ($query = ){
include (dataconf.inc.php);
dbconnect($dbname,$rootusername,$rootpassword,$roothostname);
   global$query_debug;

   if (empty($query)) { return FALSE; }

   if (!empty($query_debug)) { print pre$query/pre\n; }

   $result = mysql_query($query)
   or die(Query Failed: 
   .lierrorno=.mysql_errno(). br
   .lierror=.mysql_error(). brbr
   .liquery=.$query
   );
   return $result;
}


On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:
  

I am trying to loop through a $_POST variable.   It comes  from a text
area and it will have data like many email address or just one listed
with a space or on a new line. I can't seam to get the data to extract
properly. I have tried this below

$array = explode(' ', $_POST['emails']);



//see what you have.
//maybe it's not hat you think
var_dump($_POST['emails']);


  

foreach ($array as $value) {



//you should probably validate the emails using:

http://php.net/imap_rfc822_parse_adrlist

$value_sql = mysql_real_escape_string($value);

  

$sql = SELECT id FROM contacts where emailaddress = '$value' AND
members_id = '$memberid';



Use '$value_sql' here.

And I dunno where $memberid came from, but maybe it should be escaped
as well.

  

$sql_result=safe_query($sql);



I'm not sure what safe_query is doing, and maybe you think it can
escape the data you embedded into the SQL, but I don't see how you can
do that...  Sort of a Humpty-Dumpty problem...

  

while ($row=mysql_fetch_array($sql_result)){
$id = $row[id];
$sql1=UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
'$id';
safe_query($sql1);
}}




  


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



Re: [PHP] looping through a $_POST variable

2007-12-30 Thread Richard Kurth

looks like that is my problem it is not separating the emails
string(67) [EMAIL PROTECTED] [EMAIL PROTECTED] 
[EMAIL PROTECTED]
array(1) { [0]= string(67) [EMAIL PROTECTED] [EMAIL PROTECTED] 
[EMAIL PROTECTED] }


$array = explode(' ', $_POST['emails']);
what should I use for spaces or next line to separate them



Okay.

Now var_dump($array) and see what it has.

On Sun, December 30, 2007 6:34 pm, Richard Kurth wrote:
  

When I do a var_dump($_POST['emails']); it has all the emails in it
string(65) [EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED]
I will validate the emails after I get the loop to work
$memberid comes from a part of the script I did not show you
$memberid
=$_POST[members_id];
safe_query  is a function that I call that does query stuff

function safe_query ($query = ){
 include (dataconf.inc.php);
 dbconnect($dbname,$rootusername,$rootpassword,$roothostname);
global$query_debug;

if (empty($query)) { return FALSE; }

if (!empty($query_debug)) { print pre$query/pre\n; }

$result = mysql_query($query)
or die(Query Failed: 
.lierrorno=.mysql_errno(). br
.lierror=.mysql_error(). brbr
.liquery=.$query
);
return $result;
}



On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:

  

I am trying to loop through a $_POST variable.   It comes  from a
text
area and it will have data like many email address or just one
listed
with a space or on a new line. I can't seam to get the data to
extract
properly. I have tried this below

$array = explode(' ', $_POST['emails']);



//see what you have.
//maybe it's not hat you think
var_dump($_POST['emails']);



  

foreach ($array as $value) {



//you should probably validate the emails using:

http://php.net/imap_rfc822_parse_adrlist

$value_sql = mysql_real_escape_string($value);


  

$sql = SELECT id FROM contacts where emailaddress = '$value' AND
members_id = '$memberid';



Use '$value_sql' here.

And I dunno where $memberid came from, but maybe it should be
escaped
as well.


  

$sql_result=safe_query($sql);



I'm not sure what safe_query is doing, and maybe you think it can
escape the data you embedded into the SQL, but I don't see how you
can
do that...  Sort of a Humpty-Dumpty problem...


  

while ($row=mysql_fetch_array($sql_result)){
$id = $row[id];
$sql1=UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
'$id';
safe_query($sql1);
}}




  




  


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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Richard Kurth

M. Sokolewicz wrote:

Rick Pasotto wrote:

On Sun, Sep 16, 2007 at 06:04:45PM -0700, Richard Kurth wrote:

Richard Kurth wrote:

Rick Pasotto wrote:

On Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote:
 

Richard Kurth wrote:
  

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. 
What I do not understand is if I know the last number was say 5 
how do I tell the script that that is the current number so I 
can select the next  record

||
  

I think you'll need your own function for this.


Nope. Just use array_search().

$k = array_search('5',$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 
1]; }


  

I tried this and it gives me nothing back. It should give me a 8

$Campaign_array= array('0','1','3','5','8','15','25');
$val=5;

$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

I figured out way it was not working  $k + 1  count  needed to be 
$k + 1  count


Yup. Sorry 'bout that.


But now it works perfect




if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

is very over-the-top. What's wrong with
if (isset($Campaign_array[$k+1]) { echo $Campaign_array[$k + 1]; }

Not to mention I don't really like the whole way this has been 
handled, I'm sure there are better ways, but for this we'd need to 
know more about what you're doing and what you're trying to achieve, 
which we obviously don't.
What I am trying to is get all the days from a table where email 
campaign =  number. and then look at the last day that was sent and find 
it in the list and get the next day that follows that day. At this point 
the script below is not working. So if you have any Ideas that would be 
a better way of doing this please let me know.



$query = SELECT day FROM emailcampaign where campaign_id = 
'$emailcampaign' AND member_id = '$members_id';

$DB_Change_Campaign_Results = safe_query($query);
for ($i=0; $i  mysql_num_rows($DB_Change_Campaign_Results); $i++) {
$Change_Campaign_row = mysql_fetch_array($DB_Change_Campaign_Results);
$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;
}
$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)){ echo $Campaign_array[$k + 1]; }

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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Richard Kurth

brian wrote:

Richard Kurth wrote:


What I am trying to is get all the days from a table where email 
campaign =  number. and then look at the last day that was sent and 
find it in the list and get the next day that follows that day. At 
this point the script below is not working. So if you have any Ideas 
that would be a better way of doing this please let me know.



$query = SELECT day FROM emailcampaign where campaign_id = 
'$emailcampaign' AND member_id = '$members_id';

$DB_Change_Campaign_Results = safe_query($query);
for ($i=0; $i  mysql_num_rows($DB_Change_Campaign_Results); $i++) {
$Change_Campaign_row = mysql_fetch_array($DB_Change_Campaign_Results);
$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;
}
$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)){ echo $Campaign_array[$k + 1]; }




You can simplify this greatly:

$Campaign_array = Array();

$DB_Change_Campaign_Results = safe_query($query);

while ($row = mysql_fetch_array($DB_Change_Campaign_Results))
{
  array_push($Campaign_array, $row['day']);
}

Because you're only selecting day from the table, your row data 
consists of only one column. You're repeating stuff unnecessarily by 
doing this:


$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;

IOW, for the row that contains '5', you'd end up with 
$Campaign_array[5] == an array that essentially just points to the 
value '5'.


I also noticed that your dump shows that the days begin with 0. If 
these are calendar days you're adding a further layer of complexity.




0 represents the email campain to send 0 mens send the one that gois out 
the day the campain starts. the next number in the list is the next day 
a email is sent out  would represent 5 day after the starting day


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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Richard Kurth

Jim Lucas wrote:

Richard Kurth wrote:


$query = SELECTday
FROMemailcampaign
wherecampaign_id = '$emailcampaign'
ANDmember_id = '$members_id'
;
$DB_Change_Campaign_Results = safe_query($query);

while ( $row = mysql_fetch_array($DB_Change_Campaign_Results) ) {
$Campaign_array[$row['day']] = $row;
}

# At this point you have arrays as values for your $Campaign_array
# So, unless $k is an array that matches a sub array of $Campaign_array
# you're never going to get a match

$k = array_search($val,$Campaign_array);

# What is $k at this point?  An int (1, 2, 3, etc...) , string 
(Sunday, Monday, etc...)

# Before I go any further I will need to know the above information.

if ( ($k + 1)  count($Campaign_array) ) {
echo $Campaign_array[$k + 1];
}



This is what I get if I run the above script.
From a var_dump($Campaign_array); I get

*array*
 0 = 
   *array*

 0 = string '0' /(length=1)/
 'day' = string '0' /(length=1)/
 1 = 
   *array*

 0 = string '1' /(length=1)/
 'day' = string '1' /(length=1)/
 3 = 
   *array*

 0 = string '3' /(length=1)/
 'day' = string '3' /(length=1)/
 6 = 
   *array*

 0 = string '6' /(length=1)/
 'day' = string '6' /(length=1)/
 9 = 
   *array*

 0 = string '9' /(length=1)/
 'day' = string '9' /(length=1)/
 12 = 
   *array*

 0 = string '12' /(length=2)/
 'day' = string '12' /(length=2)/
 15 = 
   *array*

 0 = string '15' /(length=2)/
 'day' = string '15' /(length=2)/
 20 = 
   *array*

 0 = string '20' /(length=2)/
 'day' = string '20' /(length=2)/
 25 = 
   *array*

 0 = string '25' /(length=2)/
 'day' = string '25' /(length=2)/
 30 = 



   *array*
 0 = string '30' /(length=2)/
 'day' = string '30' /(length=2)/

From a $val=5;
$k = array_search($val,$Campaign_array);
var_dump($k); I get

boolean false

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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Richard Kurth

Jim Lucas wrote:

REVISED

Try this

?php

$query = SELECTday
FROMemailcampaign
WHEREcampaign_id = '$emailcampaign'
ANDmember_id = '$members_id'
;

$DB_Change_Campaign_Results = safe_query($query);

##
## NOTICE: changed from array to assoc
##
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
## Switched to an indexed array with the day as the value instead of 
the key

$Campaign_array[] = $row['day'];
}

# At this point you have arrays as values for your $Campaign_array
# So, unless $k is an array that matches a sub array of $Campaign_array
# you're never going to get a match

$k = array_search($val,$Campaign_array);

# What is $k at this point?  An int (1, 2, 3, etc...) , string 
(Sunday, Monday, etc...)

# Before I go any further I will need to know the above information.
if ( isset($Campaign_array[($k + 1)])) {
echo $Campaign_array[($k + 1)];
} else {
echo 'Not found';
}



include (includes/location.php);
$query = SELECTday
   FROMemailcampaign
   wherecampaign_id = '1'
   ANDmember_id = '8'
   ;
$DB_Change_Campaign_Results = safe_query($query);
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
  $Campaign_array[] = $row['day'];
}
if ( isset($Campaign_array[($k + 1)])) {
   echo $Campaign_array[($k + 1)];
} else {
   echo 'Not found';
}
var_dump($Campaign_array);


This is what I get now when I run this

1

*array*
 0 = string '0' /(length=1)/
 1 = string '1' /(length=1)/
 2 = string '3' /(length=1)/
 3 = string '6' /(length=1)/
 4 = string '9' /(length=1)/
 5 = string '12' /(length=2)/
 6 = string '15' /(length=2)/
 7 = string '20' /(length=2)/
 8 = string '25' /(length=2)/
 9 = string '30' /(length=2)/

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



[PHP] Finding next recored in a array

2007-09-16 Thread Richard Kurth

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I do 
not understand is if I know the last number was say 5 how do I tell the 
script that that is the current number so I can select the next  record

||

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



Re: [PHP] Finding next recored in a array

2007-09-16 Thread Richard Kurth

brian wrote:

Richard Kurth wrote:

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I 
do not understand is if I know the last number was say 5 how do I 
tell the script that that is the current number so I can select the 
next  record

||



I think you'll need your own function for this. Pass in the array and 
loop through it until you find the key, increment that, ensure that 
there is another value with that key, and return the key (or the value).


(untested)

function nextInArray($arr, $val)
{
$next_key = NULL;

for ($i = 0; $i  sizeof($arr);$i++)
{
if ($arr[$i] == $val)
{
$next_key = ++$i;
break;
}
}

// return the key:
return (array_key_exists($next_key) ? $next_key : NULL);

// or the value:
return (array_key_exists($next_key) ? $arr[$next_key] : NULL);

}

However, in your example, you're searching for the key that points to 
the value '5'. What if the value '5' occurs more than once?


brian

In my script the value of  5 will not reoccur the numbers are number of 
days from 0 up to 30 days.


Thanks for the function

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



Re: [PHP] Finding next recored in a array

2007-09-16 Thread Richard Kurth

Rick Pasotto wrote:

On Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote:
  

Richard Kurth wrote:


$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I do 
not understand is if I know the last number was say 5 how do I tell the 
script that that is the current number so I can select the next  record

||
  

I think you'll need your own function for this.



Nope. Just use array_search().

$k = array_search('5',$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

  

I tried this and it gives me nothing back. It should give me a 8

$Campaign_array= array('0','1','3','5','8','15','25');
$val=5;

$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

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



Re: [PHP] Finding next recored in a array

2007-09-16 Thread Richard Kurth

Richard Kurth wrote:

Rick Pasotto wrote:

On Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote:
 

Richard Kurth wrote:
   

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What 
I do not understand is if I know the last number was say 5 how do I 
tell the script that that is the current number so I can select the 
next  record

||
  

I think you'll need your own function for this.



Nope. Just use array_search().

$k = array_search('5',$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

  

I tried this and it gives me nothing back. It should give me a 8

$Campaign_array= array('0','1','3','5','8','15','25');
$val=5;

$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

I figured out way it was not working  $k + 1  count  needed to be $k + 
1  count

But now it works perfect

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



[PHP] determine which string is longer and then what is different in that string

2007-08-26 Thread Richard Kurth
I am trying to find out which string is the longest and then find out what
is different between the two string. Sometimes String 2 is longer than
String 1 The script below works sometimes but not all the time.
Is there a better way to do this or tell me what is wrong with the script I
am using
 
$string1 = 1,2,3,4,5,6,7,8;
$string2 = 1,2,3,4,6,7,8; 
 
 
 
function compare_by_length ($a, $b)
{
$la = strlen ($a);
$lb = strlen ($b);
if ($la == $lb) return (0);
return ($a  $b) ? 1 : 2;
}
 
$string1 = 1,2,3,4,5,6,7,8;
$string2 = 1,2,3,4,6,7,8; 
 
$longstring=compare_by_length ($string1, $string2);
 
if ($longstring==0){
  echo nochange . $longstring;
  echobr;
}
if ($longstring==1){
  echo List  . $longstring;
  echobr;
  $array1 = explode(,, $string1);
  $array2 = explode(,, $string2);
}
if ($longstring==2){
  echo List  . $longstring;
  echobr;
  $array1 = explode(,, $string2);
  $array2 = explode(,, $string1);
 
}
 
   for ($i = 0; $i  count($array1); $i++) {
  $associative_array[$array1[$i]] = 1;
   }
   
   // print Not a member of the following lists:br\n;
   for ($i = 0; $i  count($array2); $i++) {
  if (!$associative_array[$array2[$i]]) {
 print $array2[$i]br\n;
  }
   }


[PHP] RE: determine which string is longer and then what is different in that string

2007-08-26 Thread Richard Kurth
 
 
 I am trying to find out which string is the longest and then 
 find out 
 what is different between the two string. Sometimes String 2 
 is longer 
 than String 1 The script below works sometimes but not all the time.
 Is there a better way to do this or tell me what is wrong with the 
 script I am using
 
 $string1 = 1,2,3,4,5,6,7,8;
 $string2 = 1,2,3,4,6,7,8;
 
 
 Can you give us an example of two strings where the comparison fails? 
 I suspect you are looking for the number of entries in the 
 string, rather than the length of the string. For example:
 $string1 = 1,2,3,4,5,6,9;
 $string2 = 1,2,3,10,11,12;
 
 number of entries in $string1 is 7, number of entries in 
 $string2 is 6, but length($string1) = 13, while 
 length($string2) = 14. Is this the problem you are seeing?
 
Yes that is the problem $string2 is what is saved in the database and
string1 is coming from a form. The form has every thing that is in the
database but could have some items added and some removed. I need to know
what is different so I can add to or remove from a separate table so both
tables are the same. 

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



[PHP] subtracting time from date and time

2007-06-18 Thread Richard Kurth
I am trying to figure out what is the most accurate way to find the time
after I subtract 5 min,15 min, 30 min 1 hour 2 hours and 5 hours from a date
and time that is formatted like this 
20070617T193500 this is the way it has to be formatted to work in a
vcalendar
 
 
 


RE: [PHP] subtracting time from date and time

2007-06-18 Thread Richard Kurth
 

 -Original Message-
 From: Chris Boget [mailto:[EMAIL PROTECTED] 
 Sent: Monday, June 18, 2007 10:55 AM
 To: Brad Bonkoski; Richard Kurth
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] subtracting time from date and time
 
  Something like this will get it into a time stamp...and 
 then you can 
  do your calculations with ease, and reformat...
  ?php
 $str = 20070617T193500;
 list($date, $time) = explode(T,$str); ?
 
 Even easier:
 
 $timestamp = strtotime( $str );
 http://us2.php.net/manual/en/function.strtotime.php
 
 $oneMinute = 60; // seconds
 $oneHour= $oneMinute * 60;
 $oneDay = $oneHour * 24;
 
 echo '5 minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( 
 $oneMinute *
 5 ));
 echo '5 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( 
 $oneHour * 5 )); echo '5 days ago: ' . date( 'm/d/Y h:i:s', 
 $timestamp - ( $oneDay * 5 ));

This works great tell you get to 8 hours ago it shows the correct time but
it does not change the date to the day before. 8 hours ago should be 
06/16/2007 11:35:00 but what it shows is 06/17/2007 11:35:00

$str = 20070617T193500;
$timestamp = strtotime( $str );
$oneMinute = 60; // seconds
$oneHour= $oneMinute * 60;
$oneDay = $oneHour * 24;
echo 'time: ' . date( 'm/d/Y h:i:s', $timestamp );
echobr;
echo '5 minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneMinute *5
));
echobr;
echo '15 minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneMinute *15
));
echobr;
echo '30 minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneMinute *30
));
echobr;
echo '1 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour * 1 )); 
echobr;
echo '2 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour * 2 )); 
echobr;
echo '5 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour  * 5 ));
echobr;
echo '7 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour  * 7 ));
echobr;
echo '8 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour  * 8));

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



RE: [PHP] subtracting time from date and time

2007-06-18 Thread Richard Kurth
 
You are right I was looking at it as 0735 was in the morning sorry about
that.
In that case it works perfect

 -Original Message-
 From: Jim Lucas [mailto:[EMAIL PROTECTED] 
 Sent: Monday, June 18, 2007 12:21 PM
 To: Richard Kurth
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] subtracting time from date and time
 
 Richard Kurth wrote:
   
  
  -Original Message-
  From: Chris Boget [mailto:[EMAIL PROTECTED]
  Sent: Monday, June 18, 2007 10:55 AM
  To: Brad Bonkoski; Richard Kurth
  Cc: php-general@lists.php.net
  Subject: Re: [PHP] subtracting time from date and time
 
  Something like this will get it into a time stamp...and
  then you can
  do your calculations with ease, and reformat...
  ?php
 $str = 20070617T193500;
 list($date, $time) = explode(T,$str); ?
  Even easier:
 
  $timestamp = strtotime( $str );
  http://us2.php.net/manual/en/function.strtotime.php
 
  $oneMinute = 60; // seconds
  $oneHour= $oneMinute * 60;
  $oneDay = $oneHour * 24;
 
  echo '5 minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( 
  $oneMinute *
  5 ));
  echo '5 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( 
 $oneHour * 
  5 )); echo '5 days ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( 
  $oneDay * 5 ));
  
  This works great tell you get to 8 hours ago it shows the 
 correct time 
  but it does not change the date to the day before. 8 hours 
 ago should 
  be
  06/16/2007 11:35:00 but what it shows is 06/17/2007 11:35:00
  
  $str = 20070617T193500;
 
 Notice that this time stamp is formatted in 24/hr days.
 
 so
 year  2007
 month 6
 day   17
 
 hour  19  = 7pm  (not 7am)
 minute15
 second00
 
 
  $timestamp = strtotime( $str );
  $oneMinute = 60; // seconds
  $oneHour= $oneMinute * 60;
  $oneDay = $oneHour * 24;
  echo 'time: ' . date( 'm/d/Y h:i:s', $timestamp ); 
 echobr; echo '5 
  minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( 
 $oneMinute *5 )); 
  echobr; echo '15 minutes ago: ' . date( 'm/d/Y h:i:s', 
 $timestamp 
  - ( $oneMinute *15 )); echobr; echo '30 minutes ago: ' . date( 
  'm/d/Y h:i:s', $timestamp - ( $oneMinute *30 )); 
 echobr; echo '1 
  hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour * 1 )); 
  echobr; echo '2 hours ago: ' . date( 'm/d/Y h:i:s', 
 $timestamp - ( 
  $oneHour * 2 )); echobr; echo '5 hours ago: ' . date( 'm/d/Y 
  h:i:s', $timestamp - ( $oneHour  * 5 )); echobr; echo '7 hours 
  ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour  * 7 )); 
  echobr; echo '8 hours ago: ' . date( 'm/d/Y h:i:s', 
 $timestamp - ( 
  $oneHour  * 8));
  
 
 
 --
 Jim Lucas
 
 Some men are born to greatness, some achieve greatness,
 and some have greatness thrust upon them.
 
 Twelfth Night, Act II, Scene V
  by William Shakespeare
 
 --
 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 and Ajax problem

2007-05-28 Thread Richard Kurth
I can not figure out way this is not working can somebody help?
 
html
head
 titleUntitled/title
script language=JavaScript
function createRequestObject() {
 
   var req;
 
   if(window.XMLHttpRequest){
  // Firefox, Safari, Opera...
  req = new XMLHttpRequest();
   } else if(window.ActiveXObject) {
  // Internet Explorer 5+
  req = new ActiveXObject(Microsoft.XMLHTTP);
   } else {
  // There is an error creating the object,
  // just as an old browser is being used.
  alert('Problem creating the XMLHttpRequest object');
   }
 
   return req;
 
}
 
// Make the XMLHttpRequest object
var http = createRequestObject();
 
function sendRequest(action,arg) {
   // Open PHP script for requests
   http.open('get', 'eventaction.php?takeaction='+action+'uid='+arg);
   http.onreadystatechange = handleResponse;
   http.send(null);
 
}
 
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
 
if(response.indexOf('|' != -1)) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
/script
/head
 
body
?php 
 $event['deleteevent']='a
href=javascript:sendRequest(delete,32423434234234234324)Delete this
event/a';
 
 echo $event['deleteevent'];
?
/body
/html
 
 
 
this  is the 'eventaction.php script yo test if the ajax script works
?
if($_GET['takeaction']==delete){
$uid=$_GET['uid'];
echo $uid;
exit;
}
 

?


RE: [PHP] finding next and prev record in mysql

2007-05-11 Thread Richard Kurth
 

-Original Message-
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 10, 2007 10:09 PM
To: Richard Kurth
Cc: php-general@lists.php.net
Subject: Re: [PHP] finding next and prev record in mysql

Richard Kurth wrote:
 How would I find the next id and the prev id in sql statement like the 
 one below. The id number is not going to be in order so I can't do a  
 or  limit 1 on the search
  
 SELECT id FROM contacts WHERE category = '5' AND subcategory = '1' AND 
 members_id= '8' ORDER BY lastname

Ask the mysql list: http://lists.mysql.com/

I'm sure they have been asked a similar thing many times in the past.

I did but have not received any awes

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



RE: [PHP] finding next and prev record in mysql

2007-05-11 Thread Richard Kurth
 

-Original Message-
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 10, 2007 10:09 PM
To: Richard Kurth
Cc: php-general@lists.php.net
Subject: Re: [PHP] finding next and prev record in mysql

Richard Kurth wrote:
 How would I find the next id and the prev id in sql statement like the 
 one below. The id number is not going to be in order so I can't do a  
 or  limit 1 on the search
  
 SELECT id FROM contacts WHERE category = '5' AND subcategory = '1' AND 
 members_id= '8' ORDER BY lastname

Ask the mysql list: http://lists.mysql.com/

I'm sure they have been asked a similar thing many times in the past.

I did but have not received any reply at all

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



[PHP] finding next and prev record in mysql

2007-05-10 Thread Richard Kurth
How would I find the next id and the prev id in sql statement like the one
below. The id number is not going to be in order so I can't do a  or 
limit 1 on the search
 
SELECT id FROM contacts WHERE category = '5' AND subcategory = '1' AND
members_id= '8' ORDER BY lastname


[PHP] Delete first line of a csv file if it is the headers

2007-04-29 Thread Richard Kurth
 The below script will parse a csv file to a database I need to remove
the first line because it is the header files and I don't need them. How can
I test for that and remove them.
 
 $file = fopen($_POST['copy'], 'r') or $message .= Could not open .
$_POST[copy] . for reading.BR\n;
while (!feof($file)){
# We could easily be importing 10,000 records.  Give us
some time here, okay?
set_time_limit(30);
$fields = fgetcsv($file, 100);
   
if ($fields  count($fields)){
$recordcount++;
 
# Wipe out every possible field, in case they have
some missing:
reset($possiblefields);
while (list(,$fieldname) = each($possiblefields)){
$$fieldname = '';
}
 
reset($_POST['fieldorder']);
$fieldcount = 0;
$notes = '';
while (list(,$field) = each($fields)){
$fieldname =
$_POST['fieldorder'][$fieldcount++];
if ($fieldname == 'notes'){
$notes .= addslashes($field\n);
}
elseif ($fieldname == '-- ignore --'){
# ignore it
}
else{
# Note that file data is not Magic-Quoted:
$$fieldname = addslashes($field);
}
}
  require 'importinsert.php';
}


[PHP] Do two lists in a while statement

2007-04-21 Thread Richard Kurth
How can I do something like this in the same while statement. This does not
work
while (list(,$possible) = each($possiblefields)  list(,$possibleview) =
each($possiblefieldsdiscription)){
}


RE: [PHP] Do two lists in a while statement

2007-04-21 Thread Richard Kurth

On 4/21/07, Richard Kurth [EMAIL PROTECTED] wrote:
 How can I do something like this in the same while statement. This 
 does not work while (list(,$possible) = each($possiblefields)  
 list(,$possibleview) = each($possiblefieldsdiscription)){
 }


What about using  ?


while (list(,$possible) = each($possiblefields) 
list(,$possibleview) = each($possiblefieldsdiscription)){
}


Doesn't  mean if both variables are TRUE.

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



RE: [PHP] Do two lists in a while statement

2007-04-21 Thread Richard Kurth

On 4/21/07, Richard Kurth [EMAIL PROTECTED] wrote:

 On 4/21/07, Richard Kurth [EMAIL PROTECTED] wrote:
  How can I do something like this in the same while statement. This 
  does not work while (list(,$possible) = each($possiblefields)
  list(,$possibleview) = each($possiblefieldsdiscription)){
  }
 

 What about using  ?


 while (list(,$possible) = each($possiblefields) 
 list(,$possibleview) = each($possiblefieldsdiscription)){
 }


 Doesn't  mean if both variables are TRUE.

Yes, isn't that what you wanted?
Normaly a while checks also if it was TRUE. now it checks if both are TRUE..
If you only require one of both to be TRUE, use || instead of .


I am trying to fill in the drop down box in the script below but it is not
working it is only giving me the $possibleview data but not the 
$possible data


  $fieldnumber = 0;
while (list(,$field) = each($fields)){
echo TR\n;
echo TDSELECT NAME=fieldorder[]\n;
reset($possiblefields);
 reset($possiblefieldsdiscription);
$anyselected = '';
while (list(,$possible) = each($possiblefields)
list(,$possibleview) = each($possiblefieldsdiscription)){
 
$selected = @(($fieldorder[$fieldnumber] == $possible) ?
'SELECTED' : '');
if ($fieldnumber = count($fieldorder) 
!$anyselected){
$selected = 'SELECTED';
}
echo OPTION value=\$possible\
$selected$possibleview/OPTION\n;
}
echo /SELECT/TD\n;
echo TD$field/TD\n;
echo /TR\n;
$fieldnumber++;
}

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



RE: [PHP] Do two lists in a while statement

2007-04-21 Thread Richard Kurth
 

-Original Message-
From: Tijnema ! [mailto:[EMAIL PROTECTED] 
Sent: Saturday, April 21, 2007 1:13 PM
To: Richard Kurth
Cc: php-general@lists.php.net
Subject: Re: [PHP] Do two lists in a while statement

On 4/21/07, Richard Kurth [EMAIL PROTECTED] wrote:

 On 4/21/07, Richard Kurth [EMAIL PROTECTED] wrote:
 
  On 4/21/07, Richard Kurth [EMAIL PROTECTED] wrote:
   How can I do something like this in the same while statement. This 
   does not work while (list(,$possible) = each($possiblefields)
   list(,$possibleview) = each($possiblefieldsdiscription)){
   }
  
 
  What about using  ?
 
 
  while (list(,$possible) = each($possiblefields) 
  list(,$possibleview) = each($possiblefieldsdiscription)){
  }
 
 
  Doesn't  mean if both variables are TRUE.

 Yes, isn't that what you wanted?
 Normaly a while checks also if it was TRUE. now it checks if both are
TRUE..
 If you only require one of both to be TRUE, use || instead of .


 I am trying to fill in the drop down box in the script below but it is 
 not working it is only giving me the $possibleview data but not the 
 $possible data
Hmm strange, i don't see any real error, so to test if it's a problem with
the while loop, you could assign the backward order. So the code would look
like the one below. Please test it, and see if you still get the same
problem, or if you get $possible now instead of $possibleview.

Tijnema


 $fieldnumber = 0;
   while (list(,$field) = each($fields)){
   echo TR\n;
   echo TDSELECT NAME=fieldorder[]\n;
   reset($possiblefields);
reset($possiblefieldsdiscription);
   $anyselected = '';

   while (list(,$possibleview) =
each($possiblefieldsdiscription)  list(,$possible) =
each($possiblefields)){


   $selected = @(($fieldorder[$fieldnumber] == $possible) ?
'SELECTED' : '');
   if ($fieldnumber = count($fieldorder)  !$anyselected){
   $selected = 'SELECTED';
   }
   echo OPTION value=\$possible\
$selected$possibleview/OPTION\n;
   }
   echo /SELECT/TD\n;
   echo TD$field/TD\n;
   echo /TR\n;
   $fieldnumber++;
   }


It now passes the $possible fields but not the $possibleview so it is
picking up the last list but not the first
I also tried it with || and it does the same thing

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



[PHP] Problem with uploading file using FireFox

2007-04-21 Thread Richard Kurth
I know this is not a PHP problem it is a Browser problem but I need a
workaround to make this work. So I can finishing my php script
Using  this to select the file and path
 
form action=test7.php method=post
 input type=file name=uploadfile id=original size=60BR
BR
input type=submit name=submit value=UPLOAD
/FORM
 
My problem I Internet explore this will produce
C:\directory\directory\uploaded.file
But it FireFox,Netscape and Opery it will only give me
uploaded.file
How do I get the Path for this upload in these browsers


[PHP] isset

2007-04-14 Thread Richard Kurth
What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like 
if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because $_REQUEST['var'] = 
and isset thinks  is set


[PHP] changing array to a string

2007-03-27 Thread Richard Kurth
When I submit the for below it gives me an array that looks like this
array(5) { [0]= string(1) 3 [1]= string(1) 4 [2]= string(1) 5
[3]= string(1) 6 [4]= string(1) 7 } 
I would like to convert it to a string like this  3,4,5,6,7
 
 
form action=test.php method=post
table
trtd colspan=2 align=leftinput name=subscriptions[] value=3
type=checkboxtest message
/td/trtrtd colspan=2 align=leftinput name=subscriptions[]
value=4 type=checkboxtest message
/td/trtrtd colspan=2 align=leftinput name=subscriptions[]
value=5 type=checkboxtest message
/td/trtrtd colspan=2 align=leftinput name=subscriptions[]
value=6 type=checkboxtest message
/td/trtrtd colspan=2 align=leftinput name=subscriptions[]
value=7 type=checkboxtest message
/td/tr
/table
input type=hidden name=doit value=yes
input type=submit name=submit
 
/form


RE: [PHP] changing array to a string

2007-03-27 Thread Richard Kurth


Richard Kurth wrote:
 When I submit the for below it gives me an array that looks like this
 array(5) { [0]= string(1) 3 [1]= string(1) 4 [2]= string(1) 5
 [3]= string(1) 6 [4]= string(1) 7 } 
 I would like to convert it to a string like this  3,4,5,6,7

$ids = implode(',', $_POST['subscriptions']);

 Thanks I keep trying explode and forgot about implode

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



RE: [PHP] Using array_search I get error

2007-03-12 Thread Richard Kurth
 

-Original Message-
From: Tijnema ! [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 12, 2007 1:16 AM
To: Richard Kurth
Cc: Stut; php-general@lists.php.net
Subject: Re: [PHP] Using array_search I get error

On 3/12/07, Richard Kurth [EMAIL PROTECTED] wrote:



 Richard Kurth wrote:
 
 
  -Original Message-
  From: Stut [mailto:[EMAIL PROTECTED]
  Sent: Sunday, March 11, 2007 2:53 PM
  To: Richard Kurth
  Cc: php-general@lists.php.net
  Subject: Re: [PHP] Using array_search I get error
 
  Richard Kurth wrote:
  This array comes from  $_REQUEST of all data submitted
 
  $array='Array ( [id] = 17 [takeaction] = saveCustomFields [notes] 
  =
  -- Feb 4, 2007 @ 9:16 PM --fdsfdsfsdfdsfsfsfds -- Feb 4, 2007 @ 
  9:21 PM --fdfdsfsdffsd -- February 11, 2007, @ 9:31 PM -- This is a 
  tes -- February 14, 2007, @ 10:10 PM -- jhafjhfa afjahfajfhda 
  kasjdaksdhADSKJL [firstname] = NANCY [lastname] = ADKINS  
  [phone2] =
  [address1] = 25 ALWARD CT.
  [address2] = [city] = MARTINSVILLE [State] = AK [other] = [zip] 
  =
  24112 [country] = US [date18] = 03-13-2007 [text19] = test1 
  [text20] = [rating] = 0 [status] = Active )';  when I use 
  array_search to find date18
 
  $key = array_search('date18', $array);  // $key = 1;
 
  I get Wrong datatype for second argument How come the array is 
  wrong datatype isn't a array an array or am I using this wrong
 
  $array is a string, and array_search is expecting an array, so it's
 correct.
  Where did you get that array?
 
  -Stut
 
  This array comes from  $_REQUEST of all data submitted from a form

 Yeah, you said that in your first post. What I meant was where did it 
 come from?

 What you have there is the output from print_r($_REQUEST). How exactly 
 are you getting that string? Why are you creating it as a literal 
 array rather than using $_REQUEST directly?

 What you have there is the output from print_r($_REQUEST). How exactly 
 are you getting that string? Why are you creating it as a literal 
 array rather than using $_REQUEST directly?

 -Stut

 This is for saving data from custom fields created by the user I don't 
 know what they are named so I can't use $_REQUEST[name] to pull them 
 from the array.
 I am submitting a form to a script that will search thru the array and 
 find the fields that are in there date18 text19 text20 these are user 
 custom fields that I do not know what they are named. I what to 
 compare what is in the array  with a database table and if they match 
 then save the information in the array for that item to the database.


Somehow you managed to get an array become a string..., if your are using
$_REQUEST directly, or a copy of it, then you should have an array.
I also don't really understand what you are trying to do, as 'date18' is a
key, not a value, and array_search searches vor values, in this case it
searches for the value 'date18' and then try's to get the key of that value,
but date18 is a key, so it would probably return false.

Then how would I search for the Key date18 and once I find it how would I
get the value of that key. Because even if I change the date18 to it's value
03-13-2007 I still get the error Wrong datatype for second argument. I have
also tried print_r(array_keys($array)); and I get The first argument should
be an array.


 

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



[PHP] Using array_search I get error

2007-03-11 Thread Richard Kurth
This array comes from  $_REQUEST of all data submitted
 
$array='Array ( [id] = 17 [takeaction] = saveCustomFields [notes] = --
Feb 4, 2007 @ 9:16 PM --fdsfdsfsdfdsfsfsfds -- Feb 4, 2007 @ 9:21 PM
--fdfdsfsdffsd -- February 11, 2007, @ 9:31 PM -- This is a tes -- February
14, 2007, @ 10:10 PM -- jhafjhfa afjahfajfhda kasjdaksdhADSKJL [firstname]
= NANCY [lastname] = ADKINS  [phone2] = [address1] = 25 ALWARD CT.
[address2] = [city] = MARTINSVILLE [State] = AK [other] = [zip] = 24112
[country] = US [date18] = 03-13-2007 [text19] = test1 [text20] =
[rating] = 0 [status] = Active )';
 when I use array_search to find date18

$key = array_search('date18', $array);  // $key = 1;
 
I get Wrong datatype for second argument 
How come the array is wrong datatype isn't a array an array or am I using
this wrong


RE: [PHP] Using array_search I get error

2007-03-11 Thread Richard Kurth
 

-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Sunday, March 11, 2007 2:53 PM
To: Richard Kurth
Cc: php-general@lists.php.net
Subject: Re: [PHP] Using array_search I get error

Richard Kurth wrote:
 This array comes from  $_REQUEST of all data submitted
  
 $array='Array ( [id] = 17 [takeaction] = saveCustomFields [notes] = 
 -- Feb 4, 2007 @ 9:16 PM --fdsfdsfsdfdsfsfsfds -- Feb 4, 2007 @ 9:21 
 PM --fdfdsfsdffsd -- February 11, 2007, @ 9:31 PM -- This is a tes -- 
 February 14, 2007, @ 10:10 PM -- jhafjhfa afjahfajfhda 
 kasjdaksdhADSKJL [firstname] = NANCY [lastname] = ADKINS  [phone2] =
[address1] = 25 ALWARD CT.
 [address2] = [city] = MARTINSVILLE [State] = AK [other] = [zip] = 
 24112 [country] = US [date18] = 03-13-2007 [text19] = test1 
 [text20] = [rating] = 0 [status] = Active )';  when I use 
 array_search to find date18
 
 $key = array_search('date18', $array);  // $key = 1;
  
 I get Wrong datatype for second argument How come the array is wrong 
 datatype isn't a array an array or am I using this wrong

$array is a string, and array_search is expecting an array, so it's correct.
Where did you get that array?

-Stut

This array comes from  $_REQUEST of all data submitted from a form

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



RE: [PHP] Using array_search I get error

2007-03-11 Thread Richard Kurth


Richard Kurth wrote:
  
 
 -Original Message-
 From: Stut [mailto:[EMAIL PROTECTED]
 Sent: Sunday, March 11, 2007 2:53 PM
 To: Richard Kurth
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Using array_search I get error
 
 Richard Kurth wrote:
 This array comes from  $_REQUEST of all data submitted
  
 $array='Array ( [id] = 17 [takeaction] = saveCustomFields [notes] 
 =
 -- Feb 4, 2007 @ 9:16 PM --fdsfdsfsdfdsfsfsfds -- Feb 4, 2007 @ 9:21 
 PM --fdfdsfsdffsd -- February 11, 2007, @ 9:31 PM -- This is a tes -- 
 February 14, 2007, @ 10:10 PM -- jhafjhfa afjahfajfhda 
 kasjdaksdhADSKJL [firstname] = NANCY [lastname] = ADKINS  [phone2] 
 =
 [address1] = 25 ALWARD CT.
 [address2] = [city] = MARTINSVILLE [State] = AK [other] = [zip] 
 =
 24112 [country] = US [date18] = 03-13-2007 [text19] = test1 
 [text20] = [rating] = 0 [status] = Active )';  when I use 
 array_search to find date18

 $key = array_search('date18', $array);  // $key = 1;
  
 I get Wrong datatype for second argument How come the array is wrong 
 datatype isn't a array an array or am I using this wrong
 
 $array is a string, and array_search is expecting an array, so it's
correct.
 Where did you get that array?
 
 -Stut
 
 This array comes from  $_REQUEST of all data submitted from a form

Yeah, you said that in your first post. What I meant was where did it come
from?

What you have there is the output from print_r($_REQUEST). How exactly are
you getting that string? Why are you creating it as a literal array rather
than using $_REQUEST directly?

What you have there is the output from print_r($_REQUEST). How exactly are
you getting that string? Why are you creating it as a literal array rather
than using $_REQUEST directly?

-Stut

This is for saving data from custom fields created by the user I don't know
what they are named so I can't use $_REQUEST[name] to pull them from the
array.
I am submitting a form to a script that will search thru the array and find
the fields that are in there date18 text19 text20 these are user custom
fields that I do not know what they are named. I what to compare what is in
the array  with a database table and if they match then save the information
in the array for that item to the database.

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



RE: [PHP] determine time in city using GMT offset

2007-03-07 Thread Richard Kurth
That is what I am asking where do I start. I just need to be pointed in the
right direction. I have looked thru the manual for time and date and I have
searched this user group. Maybe I am not asking the question correctly.

-Original Message-
From: Jim Lucas [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 07, 2007 10:36 AM
To: Richard Kurth
Cc: php-general@lists.php.net
Subject: Re: [PHP] determine time in city using GMT offset

Richard Kurth wrote:
 How would I determine the time in a different city If I know the GMT
offset
 in both placesSay GMT -1 in one city   and GMT -7 in another city.
What
 would the math and code look like for this
 
show us what you have so far...

--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different
strings. But there are times for you and me when all such things agree.

- Rush

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



[PHP] Turning serialize data into an array

2007-03-05 Thread Richard Kurth
How can I get the data out of this string that has been serialize I need to
get it into an array so I can access the data with something like
$testdata[1]
I have tried  
$testdata= unserialize($testdata);
also
$sst= base64_encode(serialize($testdata));
$testdata1= unserialize(base64_decode($sst)); 
 
I ether get an error bool(false) or the same data back.
I do not have control of the script that serializes it 
 
$testdata='a:17:{s:11:event_start;s:4:2230;s:9:event_end;s:4:2300;s:
14:start_unixtime;i:1173076200;s:12:end_unixtime;i:1173078000;s:10:even
t_text;s:37:Call+NANCYADKINS+-+%28276%29+681-6548;s:12:event_length;i:1
800;s:13:event_overlap;i:0;s:11:description;s:17:This+is+test+Data;s:6
:status;s:0:;s:5:class;s:7:CONTACT;s:9:spans_day;b:0;s:8:location
;s:0:;s:9:organizer;s:6:a:0:{};s:8:attendee;s:6:a:0:{};s:9:calnu
mber;i:1;s:7:calname;s:5:admin;s:3:url;s:0:';
 
 


[PHP] Getting bool(false) when using unserialize

2007-03-04 Thread Richard Kurth
Way am I getting Error at offset 499 of 497 bytes bool(false)  when I run
this script below according to the manual this should work';?
$testdata=a:17:{s:11:\event_start\;s:4:\2230\;s:9:\event_end\;s:4:\2
300\;s:14:\start_unixtime\;i:1173076200;s:12:\end_unixtime\;i:117307800
0;s:10:\event_text\;s:37:\Call+NANCYADKINS+-+%28276%29+681-6548\;s:12:\
event_length\;i:1800;s:13:\event_overlap\;i:0;s:11:\description\;s:17:\
This+is+test+Data\;s:6:\status\;s:0:\\;s:5:\class\;s:7:\CONTACT\;s
:9:\spans_day\;b:0;s:8:\location\;s:0:\\;s:9:\organizer\;s:6:\a:0:{
}\;s:8:\attendee\;s:6:\a:0:{}\;s:9:\calnumber\;i:1;s:7:\calname\;s:
5:\admin\;s:3:\url\;s:0:\\;

$testdata= unserialize(stripslashes($testdata));
var_dump($testdata);
?



RE: [PHP] Re: Getting bool(false) when using unserialize

2007-03-04 Thread Richard Kurth
This gets the same error
$testdata=stripslashes($testdata);
$testdata= unserialize($testdata);
var_dump($testdata);
And I can't stripslashes before serializing because I don't have control of
the script that sends the data

-Original Message-
From: Al [mailto:[EMAIL PROTECTED] 
Sent: Sunday, March 04, 2007 2:20 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Getting bool(false) when using unserialize

stripslashes before serializing; not afterwards.

Richard Kurth wrote:
 Way am I getting Error at offset 499 of 497 bytes bool(false)  when I 
 run this script below according to the manual this should work';?
 $testdata=a:17:{s:11:\event_start\;s:4:\2230\;s:9:\event_end\;s
 :4:\2 
 300\;s:14:\start_unixtime\;i:1173076200;s:12:\end_unixtime\;i:117
 307800 

0;s:10:\event_text\;s:37:\Call+NANCYADKINS+-+%28276%29+681-6548\;s:12:\
 event_length\;i:1800;s:13:\event_overlap\;i:0;s:11:\description\;
 s:17:\ 
 This+is+test+Data\;s:6:\status\;s:0:\\;s:5:\class\;s:7:\CONTA
 CT\;s 
 :9:\spans_day\;b:0;s:8:\location\;s:0:\\;s:9:\organizer\;s:6:\
 a:0:{

}\;s:8:\attendee\;s:6:\a:0:{}\;s:9:\calnumber\;i:1;s:7:\calname\;s:
 5:\admin\;s:3:\url\;s:0:\\;
 
 $testdata= unserialize(stripslashes($testdata));
 var_dump($testdata);
 ?
 
 

--
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] save email in original layout

2007-02-23 Thread Richard Kurth
 

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 23, 2007 2:19 PM
To: Richard Kurth
Cc: php-general@lists.php.net
Subject: Re: [PHP] save email in original layout

http://php.net/mysql_real_escape_string is the only thing you need to worry
about as far as MySQL is concerned.

Translating from Email newlines to HTML newlines to OS newlines is another
kettle of fish...

Email newlines are SUPPOSED to be \n, except that some ancient Windows MTAs
insisted on using \r\n and...

So I'm concerned to see the \r in the emails, as they shouldn't be there...

And, of course, if you display this to a browser, you would need something
like:
echo nl2br(htmlentities($email));
to give the appearance of line-breaks in HTML.

To send it back out as email, with a real MTA, you'll probably need to
replace the \r\n with \n, though the real MTA might even be smart enough to
do that, knowing that it came from a broken MTA in the first place.

Did I just confuse email headers (\n only) with the body (\r\n) again?
 I do that all the time...  Experimentation or reading RFCs will straighten
you out on this one, though you're always at the mercy of the MTAs involved,
which may or may not be doing it right...

You also might as well prepare now for the Outlook users who will insist on
using ASCII control characters for things like quote marks because they want
those curly quotes that DO NOT WORK for anybody other than MS users...
There's several solutions at http://str_replace for that one.

On Wed, February 21, 2007 12:11 am, Richard Kurth wrote:
 I need to save  an email in a mysql database so that it retains it's 
 original layout so the example below

Hello ,

   Do you dream of a better life?  Do you wish you had financial 
 stability and freedom?  Would you like to be your own boss?

 would look like this when the file is saved

 \r\n Hello ,\r\n\r\n\r\n  Do you dream of a better life?  Do you wish 
 you had financial stability and freedom?  Would you like to be your 
 own boss?

 how do I insert all the line spaces like above


My problem is I have a JavaScript that will hold all the email templates on
the page that is displayed and when you select one it puts it in the
textarea so you can edit it and then send it out. When it appears in the 
textarea it does not have all the /r/n in there anymore. The JavaScript
errors out if I just put br or spaces in it. That is the only reason I
need the /r/n in the file. Below is what the script looks like. The first
script works the second does not work. The only difference is the spaces I
put in the first email in the second example. I generate the last part of
this script from the database where the email templates are stored


THIS ONE WORKS
form method=post name=scriptform action=sendfollowup.php
script language=JavaScript
!--
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document;
if((p=n.indexOf(?))0parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])d.all) x=d.all[n]; for (i=0;!xid.forms.length;i++)
x=d.forms[i][n];
  for(i=0;!xd.layersid.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
  if(!x  document.getElementById) x=document.getElementById(n); return x;
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function changescript() {
var t1=this is a test subject line;
var s1=This is a test message. This is a test message This is a test
message This is a test message This is a test message This is a test message
This is a test message This is a test message This is a test message This is
a test message This is a test message This is a test message This is a test
message This is a test message This is a test message This is a test message
This is a test message;
var t2=this is a test subject line;
var s2=\r\n This ,\r\n\r\n\r\n  s a test message This is a test message?  s
a test message This is a test message?  s a test message This is a test
message?  \r\ns a test message This is a test message;
switch(document.scriptform.scriptn.value)
{case '1' : MM_setTextOfTextfield('thescript','',s1);
MM_setTextOfTextfield('subject','',t1); break;
case '2' : MM_setTextOfTextfield('thescript','',s2);
MM_setTextOfTextfield('subject','',t2); break;
default : break; }
}
//--
/script
p
Choose Email Follow-up:
select name=scriptn onChange=changescript();
option value=0 selectedSelect.../option
OPTION value=1test1/OPTION
OPTION value=2test2/OPTION
/selectnbsp;nbsp;
p
table cellpadding=5 cellspacing=1
tr
  tdFrom:/td
  td
  
  /td
/tr
tr
  tdTo:/td
  td
 
  /td
/tr
tr
  tdSubject:/td
  tdinput type=text size=38 name=subject value=/td
/tr
tr
  td colspan=2
table cellpadding=0 cellspacing=0 style=width:100%;
tr
  td nowrapMessage:/td
  td align=right width:100%; nowrap
   /td
/tr
/table

textarea name=thescript cols=101 rows=15/textarea
  /td
/tr
tr
  td

RE: [PHP] time

2007-01-29 Thread Richard Kurth
[snip]
I am writing a program for managing leads and contacts. I would like to add
the ability to see what TIME it is where the contact is not there server
time. So if you looked at a list of contacts from all over the country you
would see different times compared to what time it is where the user is at.
What should I be looking at to calculate out the different time zones.
Could
somebody just point me in the write direction at this time I have no idea on
how to proceeded.
[/snip]

You would use JavaScript to capture their local 'browser' time and process
it with PHP

I am not looking for something where I am on line with these people some do
not have internet access. I would be calling them on the phone.
I need a way to get the time at there location using what info I already
have like the address zip code and phone number. It would probably have to
be compared to a database of some sort or the time zone file on a lynx
server.

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



Re[2]: [PHP] failed to open stream error

2005-06-10 Thread Richard Kurth
Hello Duncan,

Friday, June 10, 2005, 12:01:33 AM, you wrote:

DH On Friday 10 June 2005 06:31, Richard Kurth typed:
  Way do I get
  Warning:
 fopen(https://esos.state.nv.us/SOSServices/AnonymousAccess/CorpSearch/CorpD
etails.aspx?CorpID=478765): failed to open stream: Invalid argument
  When I run this. I can access the page from the browser but not from
  inside of a script

DH Is your installation of PHP configured to allow URLs in fopen calls?

Yes it is set to on in php.ini file. I can make it grab files from
other web sites just not with this one. What else can I look at to try
and make it work

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



[PHP] failed to open stream error

2005-06-09 Thread Richard Kurth

 Way do I get
 Warning: 
fopen(https://esos.state.nv.us/SOSServices/AnonymousAccess/CorpSearch/CorpDetails.aspx?CorpID=478765):
 failed to open stream: Invalid argument
 When I run this. I can access the page from the browser but not from
 inside of a script
 

fopen(https://esos.state.nv.us/SOSServices/AnonymousAccess/CorpSearch/CorpDetails.aspx?CorpID=478765;,'r');
  

-- 
Best regards,
 Richard  mailto:[EMAIL PROTECTED]


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



[PHP] stupid question about a class

2004-12-08 Thread Richard Kurth

I have a stupid question but I can not figure it out
I am using a class that creates the select statement for mysql.
I am ale to add all the data with out any problem. But when I run the
class to get the results. I can only see the results by running echo in
front of the call to the class .
echo $q-getQuery();
Output SELECT * FROM listing WHERE state='wa'
if I
$q-getQuery();
echo $g;
Output Object id #1
How do I use the results in my mysql query If I can not move it to a
variable


  

-- 
Best regards,
 Richard  mailto:[EMAIL PROTECTED]

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



[PHP] searching with mutable criteria

2004-12-07 Thread Richard Kurth
I am having a problem with this script what it does is write the sql
needed to search for data based on mutable criteria. It works fine if
you search with all the different fields but if you only search with
one or two of the fields it creates a sql that looks like this
SELECT * FROM listing WHERE state = 'WA' AND LIMIT 0,5
It adds the AND before the limit if you use all three fields it does
not add the AND. How can I change this so it will not add the AND if
there is only a search on one or two of the fields


$cond = AND;
$sql = 'SELECT * FROM listing ';
if($_POST[state] !=  || $_POST[types] !=  || $_POST[county] != 
){$sql .= WHERE ;

if($_POST[state] != ){
$sql .= state  = '. $_POST[state] .';
if($_POST[state] !=  || $_POST[types] !=  || $_POST[county] != 
){$sql .=  $cond ;}
}

if($_POST[type] != ){
$sql .= types = '. $_POST[types] .';
if($_POST[state] !=  || $_POST[types] !=  || $_POST[county] != ) 
{$sql .=  $cond ;}
}

if($_POST[county] != ){
$sql .= county = '. $_POST[county] .';
if($_POST[state] !=  || $_POST[types] !=  || $_POST[county] != 
){$sql.=  $cond ; }
}
)
$sql .=  LIMIT  . $from . , . $max_results;
echo $sql
-- 
Best regards,
 Richard  mailto:[EMAIL PROTECTED]

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



[PHP] Problem with code

2004-12-06 Thread Richard Kurth
I am having a problem with the code below it provides the first page
with out any problem but when I select the next page it shows all the
results from the first page and the results from the second page. It
does the same thing on the third page also. I have been looking at it
for two days and can not fined the error in the code




?php
include(include/common.php);
include($config[template_path]/user_top.html);

// If current page number, use it 
// if not, set one! 
if(!isset($page)){ 
$page = 1; 
} else { 
$page = $page; 
} 
// Define the number of results per page 
$max_results = $config['listings_per_page'];
// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results); 

//Process all the search results to create the sql 
if($searchRule == or){ $cond = OR; } else $cond = and; 
//the main sql statment
$sql = 'SELECT * FROM listing ';
//the sql statment required to set the total number of pages 
$sql1 = 'SELECT COUNT(*) as Num FROM listing ';
if($state !=  || $type !=  || $county !=  || $price != ){
$sql .= WHERE ;
$sql1 .= WHERE ; 
if($state != ){
$sql .= state  = '. $state .';
$sql1 .= state  = '. $state .';
if($state !=  || $type !=  || $county !=  || $price != ){
$sql .=  $cond ; 
$sql1 .=  $cond ; 
} }
if($type != ){  
$sql .= type = '. $type .';
$sql1 .= type = '. $type .'; 
if($state !=  || $type !=  || $county !=  || $price != ) {
$sql .=  $cond ; 
$sql1 .=  $cond ; 
} }
if($county != ){ 
$sql .= county = '. $county .';
$sql1 .= county = '. $county .'; 
if($state !=  || $type !=  || $county !=  || $price != ){
$sql .=  $cond ;
$sql1 .=  $cond ;
 } }
if($Pricerange != ){
if($Pricerange==range1){
$Price1=0;
$Price2=10;
$simbale==;
$sql .= price = '. $Price2.'; 
$sql1 .= price = '. $Price2.'; 
}
if($Pricerange==range2){
$Price1=10;
$Price2=15;
$sql .= (price  '. $Price1.' OR price = '. $Price2.'); 
$sql1 .= (price  '. $Price1.' OR price = '. $Price2.');
}
if($Pricerange==range3){
$Price1=15;
$Price2=20;
$sql .= (price  '. $Price1.' OR price = '. $Price2.');
$sql1 .= (price  '. $Price1.' OR price = '. $Price2.'); 
}
if($Pricerange==range4)
{$Price1=20;
 $Price2=25;
$sql .= (price  '. $Price1.' OR price = '. $Price2.');  
$sql1 .= (price  '. $Price1.' OR price = '. $Price2.');
}
if($Pricerange==range5)
{$Price1=25;
$Price2=30;
$sql .= (price  '. $Price1.' OR price = '. $Price2.'); 
$sql1 .= (price  '. $Price1.' OR price = '. $Price2.');
}
if($Pricerange==range6)
{$Price1=30;
$Price2=;
$sql .= price = '. $Price1.'; 
$sql1 .= price = '. $Price1.';
}}
$sql .=  LIMIT  . $from . , . $max_results; 
}


$result=safe_query($sql);
while ($row = mysql_fetch_array($result)){
extract($row);
?


div align=center
  table border=0 width=631 height=1 cellpadding=0 cellspacing=0
tr
  td width=81 height=1 bgcolor=#60A0F8font color=#FFspan 
class=contentsmallListing/spanspan class=contentbold
#? echo$listingId?/span/fontimg hspace=0 
src=images/user_photos/thumb_5000_1.jpg border=0 width=83 height=50br
  /td
  center
  td width=401 height=1textarea cols=45 rows=6? 
echo$descr1?/textarea br
a href=more_results.php?listingId=? 
echo$listingId?searchlistingid=yes
more info.../a/td
  td width=127 height=1span class=contentbold$? 
echo$price?/spanbr
   ?if ($type==) {}?
?if ($type==BUS) {echo 'Business Opportunities';}?
?if ($type==COM) {echo 'Commercial';}?
?if ($type==CON) {echo 'Condo/Townhouse';}?
?if ($type==DUP) {echo 'Duplex';}?
?if ($type==FAR) {echo 'Farms amp; Ranches';}?
?if ($type==INC) {echo 'Income Properties';}?
?if ($type==LAK) {echo 'Lake Properties/Waterfront';}?
?if ($type==MOB) {echo 'Mobile Home';}?
?if ($type==RES) {echo 'Residential';}?
?if ($type==TIM) {echo 'Time Share';}?
?if ($type==VAC) {echo 'Vacant Land';}? br
? echo$bedrooms? BR / ? echo$bathrooms? BAbr
? echo$city?, ? echo$state?/td
  /tr
/table

 ?}
$total_results = mysql_result(mysql_query($sql1),0); 
// Figure out the total number of pages. Always round up using ceil() 
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks 
echo centerSelect a Pagebr /; 

// Build Previous Link 
if($page  1){ 
$prev = ($page - 1); 
echo a href=\.$PHP_SELF.?page=$prev\Previous/anbsp;; 
} 

for($i = 1; $i = $total_pages; $i++){ 
if(($page) == $i){ 
echo $inbsp;; 
} else { 
echo a href=\.$PHP_SELF.?page=$i\$i/anbsp;; 
} 
} 

// Build Next Link 
if($page  $total_pages){ 
$next = ($page + 1); 
echo a href=\.$PHP_SELF.?page=$next\Next/a; 
} 
echo /center; 


include($config[template_path]/user_bottom.html);
?


  

-- 
Best regards,
 Richard  mailto:[EMAIL PROTECTED]

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



[PHP] searching with mutable criteria

2004-12-06 Thread Richard Kurth
I am having a problem with this script what it does is write the sql
needed to search for data based on mutable criteria. It works fine if
you search with all the different fields but if you only search with
one or two of the fields it creates a sql that looks like this
SELECT * FROM listing WHERE state = 'WA' AND LIMIT 0,5
It adds the AND before the limit if you use all three fields it does
not add the AND. How can I change this so it will not add the AND if
there is only a search on one or two of the fields


$cond = AND;
$sql = 'SELECT * FROM listing ';
if($_POST[state] !=  || $_POST[types] !=  || $_POST[county] != 
){$sql .= WHERE ;

if($_POST[state] != ){
$sql .= state  = '. $_POST[state] .';
if($_POST[state] !=  || $_POST[types] !=  || $_POST[county] != 
){$sql .=  $cond ;}
}

if($_POST[type] != ){
$sql .= types = '. $_POST[types] .';
if($_POST[state] !=  || $_POST[types] !=  || $_POST[county] != ) 
{$sql .=  $cond ;}
}

if($_POST[county] != ){
$sql .= county = '. $_POST[county] .';
if($_POST[state] !=  || $_POST[types] !=  || $_POST[county] != 
){$sql.=  $cond ; }
}
)
$sql .=  LIMIT  . $from . , . $max_results;
echo $sql
-- 
Best regards,
 Richard  mailto:[EMAIL PROTECTED]

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



[PHP] mysql error

2004-12-05 Thread Richard Kurth

Could somebody tell me way these query gets a error 1064 and does not
work.
error=You have an error in your SQL syntax; check the manual that corresponds 
to your
MySQL server version for the right syntax to use near
'SELECT * FROM listing WHERE `state` = 'WA' AND `type` = 'RES'


query=SELECT * FROM listing WHERE `state` = 'WA' AND `type` = 'RES'
AND `county` = 'clark' AND `price`  '15' OR `price` = '20';
  

-- 
Best regards,
 Richard  mailto:[EMAIL PROTECTED]

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



[PHP] Problem with code

2004-12-05 Thread Richard Kurth
I am having a problem with the code below it provides the first page
with out any problem but when I select the next page it shows all the
results from the first page and the results from the second page. It
does the same thing on the third page also. I have been looking at it
for two days and can not fined the error in the code




?php
include(include/common.php);
include($config[template_path]/user_top.html);

// If current page number, use it 
// if not, set one! 
if(!isset($page)){ 
$page = 1; 
} else { 
$page = $page; 
} 
// Define the number of results per page 
$max_results = $config['listings_per_page'];
// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results); 

//Process all the search results to create the sql 
if($searchRule == or){ $cond = OR; } else $cond = and; 
//the main sql statment
$sql = 'SELECT * FROM listing ';
//the sql statment required to set the total number of pages 
$sql1 = 'SELECT COUNT(*) as Num FROM listing ';
if($state !=  || $type !=  || $county !=  || $price != ){
$sql .= WHERE ;
$sql1 .= WHERE ; 
if($state != ){
$sql .= state  = '. $state .';
$sql1 .= state  = '. $state .';
if($state !=  || $type !=  || $county !=  || $price != ){
$sql .=  $cond ; 
$sql1 .=  $cond ; 
} }
if($type != ){  
$sql .= type = '. $type .';
$sql1 .= type = '. $type .'; 
if($state !=  || $type !=  || $county !=  || $price != ) {
$sql .=  $cond ; 
$sql1 .=  $cond ; 
} }
if($county != ){ 
$sql .= county = '. $county .';
$sql1 .= county = '. $county .'; 
if($state !=  || $type !=  || $county !=  || $price != ){
$sql .=  $cond ;
$sql1 .=  $cond ;
 } }
if($Pricerange != ){
if($Pricerange==range1){
$Price1=0;
$Price2=10;
$simbale==;
$sql .= price = '. $Price2.'; 
$sql1 .= price = '. $Price2.'; 
}
if($Pricerange==range2){
$Price1=10;
$Price2=15;
$sql .= (price  '. $Price1.' OR price = '. $Price2.'); 
$sql1 .= (price  '. $Price1.' OR price = '. $Price2.');
}
if($Pricerange==range3){
$Price1=15;
$Price2=20;
$sql .= (price  '. $Price1.' OR price = '. $Price2.');
$sql1 .= (price  '. $Price1.' OR price = '. $Price2.'); 
}
if($Pricerange==range4)
{$Price1=20;
 $Price2=25;
$sql .= (price  '. $Price1.' OR price = '. $Price2.');  
$sql1 .= (price  '. $Price1.' OR price = '. $Price2.');
}
if($Pricerange==range5)
{$Price1=25;
$Price2=30;
$sql .= (price  '. $Price1.' OR price = '. $Price2.'); 
$sql1 .= (price  '. $Price1.' OR price = '. $Price2.');
}
if($Pricerange==range6)
{$Price1=30;
$Price2=;
$sql .= price = '. $Price1.'; 
$sql1 .= price = '. $Price1.';
}}
$sql .=  LIMIT  . $from . , . $max_results; 
}


$result=safe_query($sql);
while ($row = mysql_fetch_array($result)){
extract($row);
?


div align=center
  table border=0 width=631 height=1 cellpadding=0 cellspacing=0
tr
  td width=81 height=1 bgcolor=#60A0F8font color=#FFspan 
class=contentsmallListing/spanspan class=contentbold
#? echo$listingId?/span/fontimg hspace=0 
src=images/user_photos/thumb_5000_1.jpg border=0 width=83 height=50br
  /td
  center
  td width=401 height=1textarea cols=45 rows=6? 
echo$descr1?/textarea br
a href=more_results.php?listingId=? 
echo$listingId?searchlistingid=yes
more info.../a/td
  td width=127 height=1span class=contentbold$? 
echo$price?/spanbr
   ?if ($type==) {}?
?if ($type==BUS) {echo 'Business Opportunities';}?
?if ($type==COM) {echo 'Commercial';}?
?if ($type==CON) {echo 'Condo/Townhouse';}?
?if ($type==DUP) {echo 'Duplex';}?
?if ($type==FAR) {echo 'Farms amp; Ranches';}?
?if ($type==INC) {echo 'Income Properties';}?
?if ($type==LAK) {echo 'Lake Properties/Waterfront';}?
?if ($type==MOB) {echo 'Mobile Home';}?
?if ($type==RES) {echo 'Residential';}?
?if ($type==TIM) {echo 'Time Share';}?
?if ($type==VAC) {echo 'Vacant Land';}? br
? echo$bedrooms? BR / ? echo$bathrooms? BAbr
? echo$city?, ? echo$state?/td
  /tr
/table

 ?}
$total_results = mysql_result(mysql_query($sql1),0); 
// Figure out the total number of pages. Always round up using ceil() 
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks 
echo centerSelect a Pagebr /; 

// Build Previous Link 
if($page  1){ 
$prev = ($page - 1); 
echo a href=\.$PHP_SELF.?page=$prev\Previous/anbsp;; 
} 

for($i = 1; $i = $total_pages; $i++){ 
if(($page) == $i){ 
echo $inbsp;; 
} else { 
echo a href=\.$PHP_SELF.?page=$i\$i/anbsp;; 
} 
} 

// Build Next Link 
if($page  $total_pages){ 
$next = ($page + 1); 
echo a href=\.$PHP_SELF.?page=$next\Next/a; 
} 
echo /center; 


include($config[template_path]/user_bottom.html);
?


  

-- 
Best regards,
 Richard  mailto:[EMAIL PROTECTED]

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



[PHP] Problem with a while loop

2004-10-07 Thread Richard Kurth
I am having a problem with a while loop
if I put in a number with 0's in front of it it converts the number
two the first whole number. such as 1 would be 1 02200 would be
2200. Then it starts the count down starting with that number.

How can I make it not remove the 0's in front of the number these are
needed to search a certain database .

The following script would look like this when run
1
2
3
4
I needed it to look like this
1
2
3

?php
$startnumber=1;
$stopnumber=02200;

$i = $startnumber;
echo $i;

while ($i = $stopnumber):
echo br ;
echo $i;

++$i;
endwhile;
? 

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



Re[2]: [PHP] Problem with a while loop

2004-10-07 Thread Richard Kurth
Hello djoseph,

Thursday, October 7, 2004, 11:34:22 AM, you wrote:


 The following script would look like this when run
 1
 2
 3
 4
 I needed it to look like this
 1
 2
 3

dtrc You're going to want to use printf or sprintf to format the numbers.

dtrc example: printf( %05d, $i ); 

dtrc this would print out your number, then left fill it will the zeros you want.

dtrc -Dan Joseph

 This is the actual script I need it to work in.
 I still am not sure how I would use printf or sprintf I don't want
 to pad the numbers I need the loop to leave the number alone.
 The startnumber and stopnumber will always change. some times they
 will start with a whole number and sometimes they will start with
 just one 0. As you can see with this range of number it starts with
 1 it needs to add 1 to that number to make it 2 when it gets
 into the 100 it needs to look like this 00100.


$startnumber=1;
$stopnumber=02200;

while ($i = $stopnumber):
echo $i;
echo div align='center'strong$i/strong/div;
echo br;
flush();
// get a web page into an array and print it out
$fcontents = file (http://sos.state.nv.us/corp_nme.asp?corpnum=X$year; . $i . 0);
while (list ($line_num, $line) = each ($fcontents)) {
if ($line_num==40){
$f=strip_tags($line);
echo $f;



..other code


++$i;
endwhile;


-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



[PHP] compiling php with mysql ver3 or 4

2004-05-31 Thread Richard Kurth
Hello ,

  How can I compile PHP so that it does not mater what version of
  mysql is installed.
  If I compile it for mysql 3.X and then upgrade mysql to ver 4
  PHP will not install.
  I get error while loading shared libraries: libmysqlclient.so.12: cannot open shared 
object file

  this is how I am compiling php  It is being compiled into Apache not
  as a DSO

./configure --prefix=/usr/php --with-mysql=/usr/
--with-config-file-path=/usr/conf
 --with-exec-dir=/usr/apache/bin --disable-debug --enable-safe-mode
 --enable-magic-quotes --enable-debugger --enable-track-vars --with-ftp 
--enable-sockets
 --enable-ftp --with-apache=../apache
make
make install  

-- 
Best regards,
 Richard  mailto:[EMAIL PROTECTED]

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



[PHP] Pulling unique data from database into an array

2004-02-02 Thread Richard Kurth
I am pulling data from a database that list the Language a person
  speaks and the id number. It is in a format like this.
  
 user_idfield_value
 6English||Spanish
 2English
 8English||Portuguese||Finnish
 5English||Japanese||German
 3English
 1English
 9German

 each time it looks at a new record it list all the languages that that
 person speaks with a double pipe in between each language.

 What I need to do is find all the unique languages so I can generate a
 list of languages that do not have any repeats in it with each users
 id number that speaks that language. so the
 list above
 would be
 6,2,8,5,3,1 English
 8 Portuguese
 8 Finnish
 5 Japanese
 5,9 German
 6 Spanish

 Using the script below (I am using ADODB for a database layer) I am
 able to pull the data into an array of both fields so it gives me an
 array that looks like this
 Array ( [6] = English||Portuguese||Finnish [2] = English||Portuguese||German [8] = 
English [7] = English )  )

 But I can not figure out how to split it up so there is a list like I
 have above.
 I know I need to use explode, array_merge and array_unique but I am
 not sure how to set it up so it will work correctly
 
 $sql = SELECT * FROM default_UserDBElements WHERE field_name = 'Languages';
  $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 
  $recordSet = $conn-Execute($sql); 
if (!$recordSet)
print $conn-ErrorMsg();
else
while (!$recordSet-EOF) {
$array[$recordSet-fields['user_id']] = $recordSet-fields['field_value'];
$recordSet-MoveNext();
}

print_r($array);

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



Re[2]: [PHP] Pulling unique data from database into an array

2004-02-02 Thread Richard Kurth
Hello Jochem,
I tried what you suggested and it work just perfect as long as i made
the array by hand. But when I try to generate the array using the
database I can not get it to work. How would I create the array $arrX
from the mysql database.
I have tried this but it does not work properly
while (!$recordSet-EOF) {
$arrX = $recordSet-fields['user_id'] = $recordSet-fields['field_value'];
$recordSet-MoveNext();

$arrX = array(
6 = English||Spanish,
8 = English||Portuguese||Finnish,
2 = English
);
// define a new array  loop thru $arrX like so:
$arrTmp = array();
foreach ($arrX as $langs) {
$arrTmp = array_merge($arrTmp, explode('||',$langs));
}
// now loop thru the $arrTmp array (and for each item loop the original 
//$arrX array) as follows:
foreach ($arrTmp as $Tmp) {
$arrFinal[$Tmp] = array();
foreach($arrX as $uid = $langs) {
// is the lang in this users lang list
if (stristr($langs, $Tmp)) {
// yes it is! add the user to this lang
$arrFinal[$Tmp][] = $uid;
}
}
}
// now dump the results to the screen:
echo (userslang\n);
foreach ($arrFinal as $lang = $users) {
echo implode(',',$users).  $lang\n;
}

Monday, February 2, 2004, 12:47:25 PM, you wrote:

JM // given an array in the form:

JM $arrX = array(
'' = 'English||Spanish'
'8' = 'English||Portuguese||Finnish'
JM // ...etc...
JM );

JM // define a new array  loop thru $arrX like so:

JM $arrTmp = array()
JM foreach ($arrX as $langs) {
JM $arrTmp = array_merge($arrTmp, explode('||',$langs));
JM }

JM // now loop thru the $arrTmp array (and for each item loop the original
JM $arrX array) as follows:

JM foreach ($arrTmp as $Tmp) {
JM $arrFinal[$Tmp] = array();
JM foreach($arrX as $uid = $langs) {
JM // is the lang in this users lang list
JM if (stristr($langs, $Tmp)) {
JM // yes it is! add the user to this lang
JM $arrFinal[$Tmp][] = $uid;
JM }
JM }
JM }

JM // now dump the results to the screen:

JM echo (userslang\n);
JM foreach ($arrFinal as $lang = $users) {
JM echo implode(',',$users).  $lang\n;
JM }

JM ---

JM that was off the top of my head; there is probably a better way of doing
JM it but hopefully it points you in the right direction.

JM if you don't understand this code I suggest testing it out (there may be
JM typos!!) - these are basic manipulations and a developing proper 
JM understanding of them is very important to being able to write good code
JM - I speak from experience when I say the only real way to understand it
JM is to play with it.

JM have fun.

JM Richard Kurth wrote:

 I am pulling data from a database that list the Language a person
   speaks and the id number. It is in a format like this.
   
  user_idfield_value
  6English||Spanish
  2English
  8English||Portuguese||Finnish
  5English||Japanese||German
  3English
  1English
  9German
 
  each time it looks at a new record it list all the languages that that
  person speaks with a double pipe in between each language.
 
  What I need to do is find all the unique languages so I can generate a
  list of languages that do not have any repeats in it with each users
  id number that speaks that language. so the
  list above
  would be
  6,2,8,5,3,1 English
  8 Portuguese
  8 Finnish
  5 Japanese
  5,9 German
  6 Spanish
 
  Using the script below (I am using ADODB for a database layer) I am
  able to pull the data into an array of both fields so it gives me an
  array that looks like this
  Array ( [6] = English||Portuguese||Finnish [2] =
 English||Portuguese||German [8] = English [7] = English )  )
 
  But I can not figure out how to split it up so there is a list like I
  have above.
  I know I need to use explode, array_merge and array_unique but I am
  not sure how to set it up so it will work correctly
  
  $sql = SELECT * FROM default_UserDBElements WHERE field_name = 'Languages';
   $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 
   $recordSet = $conn-Execute($sql); 
 if (!$recordSet)
 print $conn-ErrorMsg();
 else
 while (!$recordSet-EOF) {
 $array[$recordSet-fields['user_id']] =
 $recordSet-fields['field_value'];
 $recordSet-MoveNext();
 }
 
 print_r($array);
 




-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



[PHP] Pulling unique data from database

2004-02-01 Thread Richard Kurth
 I am pulling data from a database that list the Language a person
 speaks. It is in a format like this.

English||Spanish
English
English||Portuguese||Finnish
English||Japanese||German
English
English
German

each time it looks at a new record it list all the languages that that
person speaks with a double pipe in between each language.

What I need to do is find all the unique languages so I can generate a
list of languages that do not have any repeats in it. so the list above
would be   English,Portuguese,Finnish,Japanese,German,Spanish in any
order

How would I go about this. I can not change the format of the database
and there are over 200 people listed in the database.

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



[PHP] Pulling two field from mysql table into an array

2004-02-01 Thread Richard Kurth

What is the best way to pull two fields from a mysql database and add
the two fields to an array for each record in the table
field_name  user_id

I need it so iI can access the array with $key and $value

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



[PHP] Problem with while loop

2004-01-07 Thread Richard Kurth
 I can't seam to get this while loop to work properly. It should
 create a message that has the first two lines and then it will list
 all the domain that meat the criteria.


$lines = The following are web sites that are at 95% usage or more of there web 
space\n;
$lines = Site Name Used(MB)   Free(MB)   Allowed(MB)  \n;
$result=mysql_query(SELECT * FROM domplans);
while($row = mysql_fetch_array($result)){
  $dom=$row[domname];
  $total=$row[quota];
  $result1=mysql_query(SELECT * FROM datasubused where domname = '$dom');
  $proccess = mysql_fetch_array($result1);
  $totalused=$proccess[quotaused];
  $totalfree=$total - $totalused;
  $percent = ceil(100*$totalused/$total);
If($percent=95){
  $lines = $dom $totalused   $totalfree   $total  \n;
for( $i=0;$icount($lines);$i++) {
$message .=$lines[$i];
}
}
  echo $message;
}

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



[PHP] Problem with using php at the command line with mysql

2004-01-05 Thread Richard Kurth

I am using PHP to do some command line work on a Linux box. I keep
getting this error and can not figure out way. Is there something I am
missing because this should work. There is a copy of the code at the
bottom of this message.

Warning: mysql_fetch_array(): supplied argument is not a valid
MySQL result resource in /usr/.autoserv/html/auto/updatequota.php on line 8

I am using the CLI version of php at the command line as you can see
by the php -v output below
PHP 4.3.3 (cli) (built: Sep 18 2003 14:15:53)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
with Zend Optimizer v2.1.0, Copyright (c) 1998-2003, by Zend Technologies

I also no that I have mysql installed with this version here is a list
of all compiled in Modules

[PHP Modules]
Zend Optimizer
bcmath
calendar
ctype
dba
ftp
gd
gettext
imap
ldap
mbstring
mcrypt
mhash
mysql
overload
pcre
posix
readline
session
sockets
standard
tokenizer
xml
zip
zlib
[Zend Modules]
Zend Optimizer


#!/usr/.autoserv/php/bin/php
?
include(location.inc);
Global $roothostname,$rootusername,$rootpassword,$dbName;
dbconnect($dbName,$rootusername,$rootpassword,$roothostname);
$query = SELECT * FROM domhosted;
$result=safe_query($query);
while($row = mysql_fetch_row($result)){
$dom=$row[domname];
$total=getguota($dom);
$result = safe_query(update datasubused set quotaused ='$total' where domname = 
'$dom');
}
?

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



  1   2   3   >