Re: [PHP] Re: Can this be done?

2009-05-05 Thread Maarten Schalekamp

can try the foreach, put all the urls in one array

something like this might work:

?php
include(inc/dbconn_open.php);
include(inc/dom.php);
error_reporting(E_ALL);
$TESTING = TRUE;
$targets[] = http://www.greenecountymo.org/sheriff/warrants.php;;
$targets[] = http://www.greenecountymo.org/sheriff/page2.php;;
$targets[] = http://www.greenecountymo.org/sheriff/page3.php;;
foreach ($targets as $target_url){
 $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
 $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
 curl_setopt($ch, CURLOPT_URL,$target_url);
 curl_setopt($ch, CURLOPT_FAILONERROR, true);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 curl_setopt($ch, CURLOPT_AUTOREFERER, true);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
 curl_setopt($ch, CURLOPT_TIMEOUT, 300);
 $html = curl_exec($ch); if (!$html) {
  echo br /cURL error number: .curl_errno($ch);
  echo br /cURL error: . curl_error($ch);
  exit;
 } // Create DOM from URL or file
 $html = 
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C'); 
// Find table

 foreach($html-find('table') as $table) {
  foreach($table-find('tr') as $tr){ // Grab 
children

   $cells = $tr-children();
   if($cells[0]-plaintext != Name) {
for ($i = 0; $i  count($cells); $i++) {
 switch ($i){
  case 0: // Name
   $name = $cells[$i]-plaintext;
   echo $cells[$i]-plaintext;
   break;
  case 1: // Age
   $age = $cells[$i]-plaintext;
   break;
  case 2: // Warrant type
   $warrant = $cells[$i]-plaintext;
   break;
  case 3: // Bond amount
   $bond = $cells[$i]-plaintext;
   break;
  case 4: // Warrant number
   $wnumber = $cells[$i]-plaintext;
   break;
  case 5: // Offence description
   $crime = $cells[$i]-plaintext;
   break;
  Default:
   echo Uh-ohbr /;
   }   }
   }

   // Build your INSERT statement here
   $query = INSERT into warrants (wid, name, age, warrant, bond, wnumber, 
crime) VALUES (;
   $query .=  '$wid', '$name', '$age', '$warrant', '$bond', '$wnumber', 
'$crime' );

   //$wid = mysql_insert_id();
   echo $query;
   // run query
   mysql_query($query) or die (mysql_error());
  }
 }
}
?


Miller, Terion tmil...@springfi.gannett.com wrote in message 
news:c625aae1.e9b%kmille...@springfi.gannett.com...




On 5/5/09 8:31 AM, php news feed maarte...@scullix.co.za wrote:

post the script, and example of data

Miller, Terion tmil...@springfi.gannett.com wrote in message
news:c6259e7b.e91%kmille...@springfi.gannett.com...
Ok I have a script that grabs data from a page and puts it in a db, I need
to run this script 26 times on 26 different pages on the same site, is there
a way to do this without making 26 different scripts load? Should I post the
script?

Thanks,
T.Miller


__ Information from ESET Smart Security, version of virus signature
database 4053 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




__ Information from ESET Smart Security, version of virus signature 
database 4053 (20090505) __


The message was checked by ESET Smart Security.

http://www.eset.com




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

Here is the script:
?php include(inc/dbconn_open.php); include(inc/dom.php); 
error_reporting(E_ALL); $TESTING = TRUE; $target_url = 
http://www.greenecountymo.org/sheriff/warrants.php;; $userAgent = 
'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); 
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, 
CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, 
CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) 
{echo br /cURL error number: .curl_errno($ch);echo br /cURL 
error: . curl_error($ch);exit; } // Create DOM from URL or file $html = 
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C'); 
// Find table foreach($html-find('table') as $table) { 
foreach($table-find('tr') as $tr){ // Grab children 
$cells = $tr-children();  if($cells[0]-plaintext != 
Name){for ($i = 0; $i  count($cells); $i++) 
{  switch ($i){ case 0: // 
Name $name = $cells[$i]-plaintext; 
echo $cells[$i]-plaintext; break; case 
1: // Age $age = $cells[$i]-plaintext; 
break; case 2: // Warrant type $warrant 
= $cells[$i]-plaintext; break; case 3: 
// Bond amount 

[PHP] Re: Newbie - Setting Up Some Basic Sendmail Scripts

2009-05-05 Thread Maarten Schalekamp

i think you will need to make use of a pear package to be able to do this.
pear package: http://pear.php.net/package/Mail
examples: http://blog.thekimsfamily.com/archives/3
docs: http://pear.php.net/manual/en/package.mail.mail.factory.php
   http://pear.php.net/manual/en/package.mail.mail.send.php

i dont think the built in php mail function can do authentication.
you can only change the settings avaliable in the php.ini


[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = y...@yourdomain

; For Unix only.  You may supply arguments as well (default: 
sendmail -t -i).

;sendmail_path =

; Force the addition of the specified parameters to be passed as extra 
parameters

; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =


working for the first time with pear packages can sometimes be tricky to get 
going, but once all is set you wont have any probs.


i think this will push you in the right direction

revDAVE c...@hosting4days.com wrote in message 
news:c625c359.397af%c...@hosting4days.com...

[Newbie]

Hi folks,

I'm trying to set up some basic php send mail scripts - and I'm curious of
the best way to go...


I checked these basics out:

http://us.php.net/manual/en/function.mail.php

And got this code below going, but I'll bet I need a bit more - like adding
authentication - smtp - port - sending user / pass etc.

Any hints how to get this to the next level?

Thanks in advance - dave



?php
$to = 'nob...@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmas...@example.com' . \r\n .
'Reply-To: webmas...@example.com' . \r\n;

mail($to, $subject, $message, $headers);
?




--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




__ Information from ESET Smart Security, version of virus signature 
database 4054 (20090505) __


The message was checked by ESET Smart Security.

http://www.eset.com




__ Information from ESET Smart Security, version of virus signature 
database 4054 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




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



[PHP] Re: speaking of control structures...

2009-05-05 Thread Maarten Schalekamp
im not sure if i understand exactly what you want. but from what ive 
gathered, did you try to make use of a FUNCTION?

?php
function add($val1,$val2) {
   return ($val1 + $val2); //returns value from where it was called.
}

function doit(){
   if() {
   bla bla bla;
   }
   else blar;
   etc...
   return; // this just returns, can also be left out.
}

$added = add(1,2);
echo $added;
doit();

?

Tom Worster f...@thefsb.org wrote in message 
news:c625f5f7.a80f%...@thefsb.org...

there's a control structure i wish php had: a simple block that you can
break out of, e.g.

block {

 if ( condition )
   break;

 blah...
 blah...

 if ( another condition )
   break;

 blah...
 blah...

 etc...

}

the block is just like a loop except that it is executed once only.

this would be a handy structure for writing input validation code. the 
blah

blah fragments can be used for opening files, talking to the db,
manipulating strings, processing dates and times, etc., the conditions for
testing if the input is unacceptable.

i'm sure many of the programmers here do this kind of thing routinely and
have their own habits and solutions. i'd be curious what they are. please
let us know!


i guess i ought to go first. it's fugly but it works:

$once = true;
while ( $once ) {
 $once = false;

 stuff using break where needed ...

}

tom



__ Information from ESET Smart Security, version of virus 
signature database 4054 (20090505) __


The message was checked by ESET Smart Security.

http://www.eset.com






__ Information from ESET Smart Security, version of virus signature 
database 4054 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




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