Re: [PHP] date conversion/extraction issues

2012-05-03 Thread Terry Ally (Gmail)
Haluk,

After you retrieve the date from the database you still have to convert it
from a string to time and then to a date. Try:




Terry

On 2 May 2012 22:36, Haluk Karamete  wrote:

> This is my code and the output is right after that...
>
> $PDate = $row['PDate'];
> //row is tapping into ms-sql date field.
> //and the ms-sql data field has a value like this for the PDate;
> //07/12/2001
> $PDate = $PDate->date;
> echo "[", $PDate , "]";
> echo "[", var_dump($row['PDate']) , "]";
> echo "[", serialize($row['PDate']) , "]";
> the output is as follows. And my question is embedded in the output.
>
> []  ??? WHY IS THIS BLANK? WHY IS THIS NOT 2001-12-07 00:00:00?
>
> [object(DateTime)#3 (3) { ["date"]=> string(19) "2001-12-07 00:00:00"
> ["timezone_type"]=> int(3) ["timezone"]=> string(19)
> "America/Los_Angeles" } ]
>
> [O:8:"DateTime":3:{s:4:"date";s:19:"2001-12-07
>
> 00:00:00";s:13:"timezone_type";i:3;s:8:"timezone";s:19:"America/Los_Angeles";}]
>
> if I were to directly insert the $row['date']  ms-sql value into mysq,
> I get this error;
> Catchable fatal error: Object of class DateTime could not be converted
> to string in sql.php on line 379
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
*Terry Ally*
Twitter.com/terryally
Facebook.com/terryally
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
To print or not to print this email is the environmentally-searching
question!
Which has the highest ecological cost? A sheet of paper or constantly
switching on your computer and connecting to the Internet to read your
email?


Re: [PHP] Retrieve pages from an ASP driven site

2012-05-03 Thread Terry Ally (Gmail)
Tom,

Here is how you would paginate in PHP.

//
// Number of records to show per page:
$display = 4;
// Determine how many records there are.
if (isset($_GET['np'])) {
$num_pages = $_GET['np'];
} else {
$query = "SELECT * FROM mytable";
$query_result = mysql_query ($query) or die (mysql_error());
$num_records = @mysql_num_rows ($query_result);
 if ($num_records > $display) {
$num_pages = ceil ($num_records/$display);
} else {
$num_pages = 1;
}
}
 // Determine where in the database to start returning results.
if (isset($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}


// Number of records to show per page:
$display = 4;
// Determine how many records there are.
if (isset($_GET['np'])) {
$num_pages = $_GET['np'];
} else {
$query3 = "SELECT * FROM mytable";
$query_result = mysql_query ($query3) or die (mysql_error());
$num_records = @mysql_num_rows ($query_result);
 if ($num_records > $display) {
$num_pages = ceil ($num_records/$display);
} else {
$num_pages = 1;
}
}
 // Determine where in the database to start returning results.
if (isset($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
//




On 3 May 2012 05:37, EPA WC  wrote:

> Hi List,
>
> I am trying to write a crawler to go through web pages at
> http://www.freebookspot.es/CompactDefault.aspx?Keyword=. But I am not
> quite familiar with how asp uses _doPostBack function with the "next"
> button below the book list to advance to the next page. I hope someone
> who knows ASP well can help out here. I need to know how to retrieve
> next page with PHP code.
>
> Kind regards,
> Tom
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
*Terry Ally*
Twitter.com/terryally
Facebook.com/terryally
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
To print or not to print this email is the environmentally-searching
question!
Which has the highest ecological cost? A sheet of paper or constantly
switching on your computer and connecting to the Internet to read your
email?


Re: [PHP] Retrieve pages from an ASP driven site

2012-05-03 Thread Lester Caine

Terry Ally (Gmail) wrote:

Here is how you would paginate in PHP.


Terry - Tom is not trying to create this in PHP, but read existing ASP pages.

Tom - I don't think that it's simply a matter of the ASP code here, but rather 
how they have constructed the set of information they are sending back. That is 
done in javascript, but the navigation buttons are simple form submit. BNext is 
submitted for 'next'.


Interestingly, the sales side seems to be .php ;)

--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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



[PHP] Why might fclose() block?

2012-05-03 Thread Andy Theuninck
I'm currently seeing this in 5.3.10, although it's an intermittent
problem I've seen earlier versions too. Occasionally I get a "maximum
execution time" error when calling fclose() on a parallel port file
descriptor. Code looks like this:

$fp = fopen('/dev/lp0','w');
if ($fp){
   fwrite($fp,$LongStringOfData);
   fclose($fp);
}

The printer attached to the parallel port does print the data sent in
the fwrite line and the execution time error identifies the fclose
line. It does not appear to be OS dependent. I've seen the error in
both CentOS and Ubuntu as well as Windows (with LPT1: instead of
/dev/lp0).

What could cause fclose() to block rather than fail and return False?
Is there anything vaguely equivalent to socket_select that I can use
to wait for a blocking file descriptor with a specified timeout?

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



Re: [PHP] Retrieve pages from an ASP driven site

2012-05-03 Thread EPA WC
Thanks Lester.

On Thu, May 3, 2012 at 3:49 AM, Lester Caine  wrote:
> Terry Ally (Gmail) wrote:
>>
>> Here is how you would paginate in PHP.
>
>
> Terry - Tom is not trying to create this in PHP, but read existing ASP
> pages.
>
> Tom - I don't think that it's simply a matter of the ASP code here, but
> rather how they have constructed the set of information they are sending
> back. That is done in javascript, but the navigation buttons are simple form
> submit. BNext is submitted for 'next'.
>
> Interestingly, the sales side seems to be .php ;)
>
> --
> Lester Caine - G8HFL
> -
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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



Re: [PHP] PHP Mailto() - Google now displaying HTML as Plain Text

2012-05-03 Thread Gerardo Benitez
Do you know if the mailto script allow set headers?

Probably you must set a html header, something like this
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";


Regards,
Gerardo.

On Tue, May 1, 2012 at 5:14 PM, Marco Behnke  wrote:

>
>
> Am 29.04.2012 22:31, schrieb Terry Ally (Gmail):
>
>> Hi all,
>>
>> I have been using a mailto() script for the last three years and from
>> April
>> 25, 2012 incoming HTML email in Goggle mail is displaying as Plain Text.
>>  Something clearly changed with Google. Perhaps there is some change I
>> need
>> to make with my script??
>>
>> $message .= "Message:<**blockquote>  ".$m."";
>>
>>
> As far as I can see your main html tags are missing?
>
> $message = '' . $message . '';
>
>
> --
> Marco Behnke
> Dipl. Informatiker (FH), SAE Audio Engineer
> Zend Certified Engineer PHP 5.3
>
> Tel.: 0174 / 9722336
> e-Mail: ma...@behnke.biz
>
> Softwaretechnik Behnke
> Heinrich-Heine-Str. 7D
> 21218 Seevetal
>
> http://www.behnke.biz
>
>
>


-- 
Gerardo Benitez
-
Programador Web Freelance


Re: [PHP] PHP Mailto() - Google now displaying HTML as Plain Text

2012-05-03 Thread Terry Ally (Gmail)
Hi all,

This question is now closed.

There is nothing wrong with my script.

It was an error by Google when they switched over to the new-look email and
have since rectified the issue and all is back to normal.

Thanks to all who have responded.

Terry



On 3 May 2012 21:05, Gerardo Benitez  wrote:

> Do you know if the mailto script allow set headers?
>
> Probably you must set a html header, something like this
> $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
>
>
> Regards,
> Gerardo.
>
> On Tue, May 1, 2012 at 5:14 PM, Marco Behnke  wrote:
>
> >
> >
> > Am 29.04.2012 22:31, schrieb Terry Ally (Gmail):
> >
> >> Hi all,
> >>
> >> I have been using a mailto() script for the last three years and from
> >> April
> >> 25, 2012 incoming HTML email in Goggle mail is displaying as Plain Text.
> >>  Something clearly changed with Google. Perhaps there is some change I
> >> need
> >> to make with my script??
> >>
> >> $message .= "Message:<**blockquote>  ".$m."";
> >>
> >>
> > As far as I can see your main html tags are missing?
> >
> > $message = '' . $message . '';
> >
> >
> > --
> > Marco Behnke
> > Dipl. Informatiker (FH), SAE Audio Engineer
> > Zend Certified Engineer PHP 5.3
> >
> > Tel.: 0174 / 9722336
> > e-Mail: ma...@behnke.biz
> >
> > Softwaretechnik Behnke
> > Heinrich-Heine-Str. 7D
> > 21218 Seevetal
> >
> > http://www.behnke.biz
> >
> >
> >
>
>
> --
> Gerardo Benitez
> -
> Programador Web Freelance
>



-- 
*Terry Ally*
Twitter.com/terryally
Facebook.com/terryally
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
To print or not to print this email is the environmentally-searching
question!
Which has the highest ecological cost? A sheet of paper or constantly
switching on your computer and connecting to the Internet to read your
email?


Re: [PHP] PHP & Database Problems -- Code Snippets

2012-05-03 Thread Ethan Rosenberg

At 06:47 PM 5/2/2012, Matijn Woudt wrote:
On Wed, May 2, 2012 at 11:43 PM, Ethan Rosenberg 
 wrote: > Dear list - > > 
Sorry for the attachment. Â Here are code 
snippets --- Ethan, I don't want to sound rude, 
but it appears to me you don't have any 
understanding of what you're doing. It might 
help if you understand what the code is doing... 
Let me explain. > > GET THE DATA FROM 
INTAKE3: > > Â  Â function handle_data() > Â  Â 
{ > Â  Â  Â  global $cxn; > Â  Â  Â  $query = 
"select * from Intake3 where  1"; > > > > 
      if(isset($_Request['Sex'])&& 
trim($_POST['Sex']) != '' ) $_Request does not 
exists, you're looking for $_REQUEST. And why 
are you mixing $_REQUEST and $_POST here? > 
      { >            if 
($_REQUEST['Sex'] === "0") > Â  Â  Â  Â  Â  Â 
{ > Â  Â  Â  Â  Â  Â  Â  $sex = 'Male'; > 
           } >            else > 
           { >               $sex = 
'Female'; > Â  Â  Â  Â  Â  Â } > Â  Â  Â  } > > 
   } What is the point of the handle_data 
function above? It doesn't do anything. > Â  Â 
$allowed_fields = array > Â  Â  Â  ( Â 'Site' 
=>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 
'Fname' => > $_POST['Fname'], 'Lname' => 
$_POST['Lname'] , > Â  Â  Â  Â  Â  Â  'Phone' => 
$_POST['Phone'] , 'Sex' => $_POST['Sex'] Â , 
'Height' > => $_POST['Height'] Â ); > > Â  Â 
if(empty($allowed_fields)) > Â  Â { > 
         echo "ouch"; >    } > >    
$query = "select * from Intake3  where  1 
"; > > Â  Â foreach ( $allowed_fields as $key => 
$val ) > Â  Â { > Â  Â  Â  if ( (($val != '')) 
) > >    { >       $query .= " AND ($key  
= '$val') "; > Â  Â } > Â  Â  Â  $result1 = 
mysqli_query($cxn, $query); > Â  Â } First, this 
will allow SQL injections, because you insert 
the values directly from the browser. Second, 
you should move the last line ($result1=...), 
outside of the foreach loop, now you're 
executing the query multiple times. Third, you 
should check if $result1 === FALSE, in case the 
query fails > > Â  Â $num = 
mysqli_num_rows($result1); > Â  Â if(($num = 
mysqli_num_rows($result1)) == 0) Doing the same 
thing twice? > Â  Â { > ?> > Â  Â />No Records > Retrieved 
#1 >  Â  Â 
exit(); > Â  Â } > > DISPLAY THE INPUT3 
DATA: >  THIS SEEMS TO BE THE ROUTINE THAT 
IS FAILING <<< > > Â  Â Search 
Results > > Â  Â 
cellspacing="55" Â rules="all" > Â 
frame="box"> > Â  Â  > 
   Site >    Medical 
Record > Â  Â First Name > Â  Â 
Last Name > Â  Â Phone > Â  Â 
Height > Â  Â Sex > Â  Â 
History > Â  Â  > >  > 
      while ($row1 = 
mysqli_fetch_array($result1, MYSQLI_BOTH)) > 
      { >            print_r($_POST); 
Doesn't really make sense to print $_POST 
here.. > Â  Â  Â  Â  Â  Â  Â  global 
$MDRcheck; > Â  Â  Â  Â  Â  Â  Â  $n1++; > 
              echo "n1 ";echo 
$n1; > Â  Â  Â  Â  Â  Â { > 
              if (($n1 > 2) && ($MDRcheck 
== $row1[1])) > Â  Â  Â  Â  Â  Â  Â  { > 
                   echo ">2==  "; > 
                   echo $MDRcheck; > 
                   echo " $row1[0] 
\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
" $row1[1] \n"; > 
                   echo " $row1[2] 
\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
" $row1[3] \n"; > 
                   echo " $row1[4] 
\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
" $row1[5] \n"; > 
                   echo " $row1[6] 
\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
" $row1[7] \n"; > 
                   echo "\n"; > 
              } > 
              elseif (($n1 > 2) && 
($MDRcheck != $row1[1])) > 
              { > 
                   echo ">2!=  "; > > 
                   echo 
$MDRcheck; > > > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â 
continue; continue doesn't do anything here. > 
              } > 
              elseif ($n1 == 2) > 
              { > > 
                   define( "MDR" ,  
$row1[1]); > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
"row1 ";echo $row1[1]; > 
                   echo "\n"; > > 
                   $_GLOBALS['mdr']= 
$row1[1]; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â 
$_POST['MedRec'] = $row1[1]; You're not supposed 
to set variables in $_POST... > 
                   $MDRold = 
$_GLOBALS['mdr']; It appears you want the old 
value of mdr, if so, then you should do this 
before you set it again 2 lines above.. > 
                   echo " $row1[0] 
\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
" $row1[1] \n"; > 
                   echo " $row1[2] 
\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
" $row1[3] \n"; > 
                   echo " $row1[4] 
\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
" $row1[5] \n"; > 
                   echo " $row1[6] 
\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo 
" $row1[7] \n"; > 
                   echo "\n"; > 
              } > >            } > 
      } > > ?> You say this routine is 
probably the one

[PHP] PDF Form Field

2012-05-03 Thread Dan Joseph
Hi,

I've spent hours researching this with no luck.  I have a PDF with a form
field that I want to populate and output the PDF.  Can someone point me in
the right direction?  Can FPDF do this natively, or I need something else?
 My host doesn't have PDFLib installed, so that's not an option.  Thanks.

-- 
-Dan Joseph

http://www.danjoseph.me


Re: [PHP] PDF Form Field

2012-05-03 Thread David OBrien
On May 3, 2012 9:08 PM, "David OBrien"  wrote:
>
>
> On May 3, 2012 8:53 PM, "Dan Joseph"  wrote:
> >
> > Hi,
> >
> > I've spent hours researching this with no luck.  I have a PDF with a
form
> > field that I want to populate and output the PDF.  Can someone point me
in
> > the right direction?  Can FPDF do this natively, or I need something
else?
> >  My host doesn't have PDFLib installed, so that's not an option.
 Thanks.
> >
> > --
> > -Dan Joseph
> >
> > http://www.danjoseph.me
>
> Yeah you can load the pdf and overlay the text on top of it with fpdf
there should be an example of that on the fpdf site

I just found fpdfi using Google. It looks like what you need


Re: [PHP] PDF Form Field

2012-05-03 Thread David OBrien
On May 3, 2012 8:53 PM, "Dan Joseph"  wrote:
>
> Hi,
>
> I've spent hours researching this with no luck.  I have a PDF with a form
> field that I want to populate and output the PDF.  Can someone point me in
> the right direction?  Can FPDF do this natively, or I need something else?
>  My host doesn't have PDFLib installed, so that's not an option.  Thanks.
>
> --
> -Dan Joseph
>
> http://www.danjoseph.me

Yeah you can load the pdf and overlay the text on top of it with fpdf there
should be an example of that on the fpdf site


Re: [PHP] PDF Form Field

2012-05-03 Thread Dan Joseph
On Thu, May 3, 2012 at 9:13 PM, David OBrien  wrote:

> I just found fpdfi using Google. It looks like what you need
>

Wow, you said the key phrase in your last e-mail, 'text on top'.  I didn't
think of that.  fpdi/fpdf does that like a charm, thanks!

-- 
-Dan Joseph

http://www.danjoseph.me


[PHP] function

2012-05-03 Thread Ron Piggott
I need to access a FUNCTION I programmed within a different FUNCTION.  Are 
these able to be passed like a variable?  Or are they able to become like a 
$_SESSION variable in nature?  How am I able to do this?  

I am essentially programming:

===
function name( $flag1, $flag2 ) {

# some PHP

echo name_of_a_different_function( $flag1 , $flag2 );

}
===

The error I am receiving is “Call to undefined function 
name_of_a_different_function”

Thanks, Ron

Ron Piggott


www.TheVerseOfTheDay.info 


Re: [PHP] function

2012-05-03 Thread Dan Joseph
On Thu, May 3, 2012 at 10:12 PM, Ron Piggott  wrote:

> I need to access a FUNCTION I programmed within a different FUNCTION.  Are
> these able to be passed like a variable?  Or are they able to become like a
> $_SESSION variable in nature?  How am I able to do this?
>
> I am essentially programming:
>
> ===
> function name( $flag1, $flag2 ) {
>
> # some PHP
>
> echo name_of_a_different_function( $flag1 , $flag2 );
>
> }
> ===
>
> The error I am receiving is “Call to undefined function
> name_of_a_different_function”
>
>
Are these inside classes or anything?  If they're just functions, they
should work fine together, example of 2 working functions together:



This results in "hi 1" being echoed to the screen.

-- 
-Dan Joseph

http://www.danjoseph.me


Re: [PHP] function

2012-05-03 Thread Simon Schick
On Fri, May 4, 2012 at 4:29 AM, Dan Joseph  wrote:
>
> Are these inside classes or anything?  If they're just functions, they
> should work fine together, example of 2 working functions together:
>
> 
> hellotwo();
>
> function helloone()
> {
>        echo "hi 1";
> }
>
> function hellotwo()
> {
>        helloone();
> }
>
> ?>
>
> This results in "hi 1" being echoed to the screen.
>
> --
> -Dan Joseph
>
> http://www.danjoseph.me

Hi, Ron

Another hint:
Maybe the other function (you want to call inside your first function)
is not defined at that time but in a file that's included later on ...

Bye
Simon

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