php-general Digest 12 Dec 2005 05:57:38 -0000 Issue 3845

Topics (messages 227305 through 227323):

Re: OO XML Parser
        227305 by: Norbert Wenzel

Re: href links not working in XP
        227306 by: Marlin Unruh
        227307 by: John Hinton
        227310 by: Marlin Unruh

Re: Variable $_POST vars?
        227308 by: The.Rock
        227309 by: The.Rock
        227311 by: Curt Zirzow

Re: broken code....
        227312 by: Mark Steudel

Re: Moving code from a specific file to a generic one
        227313 by: Miles Thompson
        227314 by: Zareef Ahmed

Value (not) being retuned by a function
        227315 by: MARG
        227316 by: Robert Cummings
        227317 by: MARG

Questions from a ColdFusion Developer
        227318 by: Christopher Jordan
        227320 by: Derek Williams

Stream lib vs Socket lib
        227319 by: will.25sucks.com

pdf_open_memory_image - call to undefined function
        227321 by: Holografix

Re: what is better for performance?
        227322 by: Martin Nicholls

Date Function Questions
        227323 by: benc11.gmail.com

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Robert Cummings wrote:
On Sat, 2005-12-10 at 11:25, mail wrote:

xml_set_element_handler($parser, "xml_start_element", "xml_stop_element"); 
//can't find function


use array notation for object method handlers:

xml_set_element_handler
(
    $parser,
    array( $this, 'xml_start_element' ),
    array( $this, 'xml_stop_element' )
);

Cheers,
Rob.

Thanks,

Norbert

--- End Message ---
--- Begin Message ---
M wrote:
Marlin Unruh wrote:
Sure, here is the main function and the function that sends the files/links to the browser. This works fine on two w2k machines, but not on our XP machine. If I place the mouse pointer over the link on the web page it shows correct in the IE status bar. Example:( file:///c:/suncosys/act/2d/file_name.vc6 )


Does it work if you copy&paste the link? It might be a security feature.

If I right click on the link and select [copy shortcut], then paste it in the address bar the application loads as it should. If I select [print target] it also loads as it should but the print dialog also opens. If I right click and select [open] nothing happens, same as if I left click.

Regards,
--
"There are 10 kinds of people in the world, those who understand binary and those who don't."
--- End Message ---
--- Begin Message ---
Marlin Unruh wrote:

M wrote:

Marlin Unruh wrote:

Sure, here is the main function and the function that sends the files/links to the browser. This works fine on two w2k machines, but not on our XP machine. If I place the mouse pointer over the link on the web page it shows correct in the IE status bar. Example:( file:///c:/suncosys/act/2d/file_name.vc6 )


Does it work if you copy&paste the link? It might be a security feature.

If I right click on the link and select [copy shortcut], then paste it in the address bar the application loads as it should. If I select [print target] it also loads as it should but the print dialog also opens. If I right click and select [open] nothing happens, same as if I left click.

Regards,

What is a .vc6 filetype? I bet you have a security setting in the browser that doesn't allow opening that filetype on click... but you are able to force the issue with direct input... but then again, I could just be all wet behind the ears.

John Hinton

--- End Message ---
--- Begin Message ---
John Hinton wrote:
Marlin Unruh wrote:

M wrote:

Marlin Unruh wrote:

Sure, here is the main function and the function that sends the files/links to the browser. This works fine on two w2k machines, but not on our XP machine. If I place the mouse pointer over the link on the web page it shows correct in the IE status bar. Example:( file:///c:/suncosys/act/2d/file_name.vc6 )


Does it work if you copy&paste the link? It might be a security feature.

If I right click on the link and select [copy shortcut], then paste it in the address bar the application loads as it should. If I select [print target] it also loads as it should but the print dialog also opens. If I right click and select [open] nothing happens, same as if I left click.

Regards,

What is a .vc6 filetype? I bet you have a security setting in the browser that doesn't allow opening that filetype on click... but you are able to force the issue with direct input... but then again, I could just be all wet behind the ears.

John Hinton

The .vc6 is the extention for the CAD drawing program we use. Ashlar-Vellum.

--
Marlin

--- End Message ---
--- Begin Message ---
Rob, I thought I had tried everything, except...the following:

$item = $_POST["item$i"]; //Where $i increments and loops thru my POST
vars...WOHOO!

This actually works. Why it works, I'll never know. but it does!


"Robert Cummings" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Sun, 2005-12-11 at 00:41, Robert Cummings wrote:
>> On Sun, 2005-12-11 at 00:27, The.Rock wrote:
>> > Here is an example of one of the fields:
>> > <input name="item{number}" size=60 class="formdata" value="{item}">
>> >
>> > I'm looping thru this form several times, so each time the name gets
>> > incremented. Do you have an example of what your talking about?
>
> Ooops, forgot to update my $i. Updated below and thus avoiding the
> infinte loop *lol*.
>
> <?php
>
> $i = 0; // presuming 0 offset.
> while( isset( $_POST['item'.$i] ) )
> {
>    $currItem = $_POST['item'.$i++];
>
>    //
>    // Do something with $currItem.
>    //
> }
>
> ?>
>
> Cheers,
> Rob.
> -- 
> .------------------------------------------------------------.
> | InterJinn Application Framework - http://www.interjinn.com |
> :------------------------------------------------------------:
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for       |
> | creating re-usable components quickly and easily.          |
> `------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
But when I tried your idea, it errors out with a PHP parse error.

I agree with you about it being semantically the same, however it doesn't 
work. go figure

"Robert Cummings" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Sun, 2005-12-11 at 02:03, The.Rock wrote:
>> Rob, I thought I had tried everything, except...the following:
>>
>> $item = $_POST["item$i"]; //Where $i increments and loops thru my POST
>> vars...WOHOO!
>>
>> This actually works. Why it works, I'll never know. but it does!
>
> *lol* It's semantically the same as what I posted for you :)
>
> Cheers,
> Rob.
> -- 
> .------------------------------------------------------------.
> | InterJinn Application Framework - http://www.interjinn.com |
> :------------------------------------------------------------:
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for       |
> | creating re-usable components quickly and easily.          |
> `------------------------------------------------------------' 

--- End Message ---
--- Begin Message ---
On Sun, Dec 11, 2005 at 12:10:22AM -0600, The.Rock wrote:
> Stephen,
> 
> I'm using a template and so:
>     <input name="item{number}" size=60 class="formdata" value="{item}">
> becomes:
>     <input name="item1" size=60 class="formdata" value="{item}">
> 
> ....and so on.

You seemed to miss the point Stephen was suggesting, to use your
template syntax:

   <input name="items[{number}]" size=60 class="formdata" value="{item}">

Then in your php code:

  $item = $_POST['items'];
  foreach($items as $i => $value) {
    echo "$i: $value<br>";
  }

Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
What did you do to fix it? 

-----Original Message-----
From: Eternity Records Webmaster [mailto:[EMAIL PROTECTED] 
Sent: Saturday, December 10, 2005 7:10 PM
To: [email protected]
Subject: RE: [PHP] broken code....

Got it fixed now... tnx...



-----Original Message-----
From: Ben Blay [mailto:[EMAIL PROTECTED]
Sent: Friday, December 09, 2005 9:46 AM
To: Mark Steudel
Cc: [email protected]
Subject: Re: [PHP] broken code....


I believe the difference between using =& and = is that the former passes
the value by reference, though I've never been clear about the benefits of
using one over the other when it comes to PEAR:DB (the PEAR:DB documentation
uses =& extensively, so presumably it is the better method).

Ben



On 12/8/05, Mark Steudel <[EMAIL PROTECTED]> wrote:
> Good catch:
>
> So I normally do
>
> $results =& $db->query ( "SELECT * FROM table" );
>
> What is the difference between using the & and not using the &.
>
> -----Original Message-----
> From: Ben Blay [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 08, 2005 10:27 AM
> To: [email protected]
> Subject: Re: [PHP] broken code....
>
> > $results->query('select * from eternityrecords.journal');
>
> Should this not be:
> $results = $db->query('select * from eternityrecords.journal');
>
> See:
> http://pear.php.net/manual/en/package.database.db.db-result.fetchinto.
> php
>
> Ben
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>

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

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

--- End Message ---
--- Begin Message ---
At 10:31 AM 12/11/2005, MARG wrote:
Hi,

I have this source code in this randomImage.php file (see source):
http://www.tuxdoit.com/randomImage.phps

This generates a random image for form validation.
Now, as you can see, i call the picture from
http://www.tuxdoit.com/newslwetter.php
as
<img src="randomImage.php">
and that works just fine.

But... i'd like to include the source code of randomImage.php in a
generic functions.php file along with others.

My problem is i'm not being able to do that.

If i move the code to functions.php, what modifications must be made to
the image generation code and how do i call it from newsletter.php ?

I've already tried to make it a function, of course, but no good :(
I'm driving nuts with this :(

Any help would be apreciated.

Warm Regards,
MARG

"not able to do that" - what happens? What error messages do you get? Or does nothing happen?

What is the scope of $image? Have you recognized it as a global within the function, and declared it external to the function?

Have you deconstructed randomImage and built it up incrementally within function.php?

Could it be that if you try and include it in functions.php there is output somewhere sent to the browser before the header() and session_start() functions are called?

Finally, what's wrong with calling it as you do at present? Flash programmers are forced into that model for every class they create. It must be an independent .as file, with the same name as the function, and contain code only for properties and methods of that function.

HTH - Miles Thompson
--- End Message ---
--- Begin Message ---
Hi MARG,

It will be better if you can provide the code here and what error you are
getting.

BTW  header function is the key here.

Zareef Ahmed



----- Original Message ----- 
From: "Miles Thompson" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, December 11, 2005 12:33 PM
Subject: Re: [PHP] Moving code from a specific file to a generic one


> At 10:31 AM 12/11/2005, MARG wrote:
> >Hi,
> >
> >I have this source code in this randomImage.php file (see source):
> >http://www.tuxdoit.com/randomImage.phps
> >
> >This generates a random image for form validation.
> >Now, as you can see, i call the picture from
> >http://www.tuxdoit.com/newslwetter.php
> >as
> ><img src="randomImage.php">
> >and that works just fine.
> >
> >But... i'd like to include the source code of randomImage.php in a
> >generic functions.php file along with others.
> >
> >My problem is i'm not being able to do that.
> >
> >If i move the code to functions.php, what modifications must be made to
> >the image generation code and how do i call it from newsletter.php ?
> >
> >I've already tried to make it a function, of course, but no good :(
> >I'm driving nuts with this :(
> >
> >Any help would be apreciated.
> >
> >Warm Regards,
> >MARG
>
> "not able to do that" - what happens? What error messages do you get? Or
> does nothing happen?
>
> What is  the scope of $image? Have you recognized it as a global within
the
> function, and declared it external to the function?
>
> Have you deconstructed randomImage and built it up incrementally within
> function.php?
>
> Could it be that if you try and include it in functions.php there is
output
> somewhere sent to the browser before the header() and session_start()
> functions are called?
>
> Finally, what's wrong with calling it as you do at present? Flash
> programmers are forced into that model for every class they create. It
must
> be an independent .as file, with the same name as the function, and contai
n
> code only for properties and methods of that function.
>
> HTH - Miles Thompson
>
> -- 


====================================================
PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : [EMAIL PROTECTED]
>

--- End Message ---
--- Begin Message ---
Hi,

I have this form:
http://www.tuxdoit.com/newsletter.php

If you care to check it, you'll see that
http://www.tuxdoit.com/formsResult.php

never returns the function value:

formsResult.php:
-------------------------------------
<?php
  include('functions.php');
  ini_set("display_errors","On");

  $email = $_REQUEST['email'];

  $emailResult = isEmailOk($email);

  print($emailResult);

  if ($emailResult == 1)
   print('Email Ok');
  else
   print('Email is not Ok');

?>
--------------------------------

functions.php:
--------------------------------
<?php

function isEmailOk($email) {
print($email);
 if (!eregi
("^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~^?])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~^?]+\\.)+[a-zA-Z]{2,6}\$",
$email))
  return 1;

 } // is EmailOk

?>
-------------------------------

Why is that happening ?

Any help would be apreciated.

Warm regards,
MARG

--- End Message ---
--- Begin Message ---
On Sun, 2005-12-11 at 14:55, MARG wrote:
> Hi,
> 
> I have this form:
> http://www.tuxdoit.com/newsletter.php
> 
> If you care to check it, you'll see that
> http://www.tuxdoit.com/formsResult.php
> 
> never returns the function value:
> 
> formsResult.php:
> -------------------------------------
> <?php
>   include('functions.php');
>   ini_set("display_errors","On");
> 
>   $email = $_REQUEST['email'];
> 
>   $emailResult = isEmailOk($email);
> 
>   print($emailResult);
> 
>   if ($emailResult == 1)
>    print('Email Ok');
>   else
>    print('Email is not Ok');
> 
> ?>
> --------------------------------
> 
> functions.php:
> --------------------------------
> <?php
> 
> function isEmailOk($email) {
> print($email);
>  if (!eregi
> ("^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~^?])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~^?]+\\.)+[a-zA-Z]{2,6}\$",
> $email))
>   return 1;
> 
>  } // is EmailOk
> 
> ?>
> -------------------------------
> 
> Why is that happening ?

I would wager because there's a ! operator preceding the ereg() call.
Also you have very dirty code, your isEmailOk() function doesn't return
a value in the case that the if expression fails, it assumes PHP will
return something useful (PHP returns null, but relying on that is asking
for trouble, and I doubt you knew so in the first place).

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Hi Robert,

> I would wager because there's a ! operator preceding the ereg() call.
> Also you have very dirty code, your isEmailOk() function doesn't return
> a value in the case that the if expression fails, it assumes PHP will
> return something useful (PHP returns null, but relying on that is asking
> for trouble, and I doubt you knew so in the first place).
> 
> Cheers,
> Rob.
Yes, i knew that.
The code was like ot was for the sake of simplicity.

Warm Regards,
MARG

--- End Message ---
--- Begin Message ---
Hi folks,
  
 I'm a ColdFusion  developer,  but I'm branching out into  PHP because alot of  
my smaller clients don't want to pay for CF.
  
  Anyway, a bit of background:
  
  I've got a page that does a search on one of my tables. I'm using  Justin 
Vincent's ezSQL (http://php.justinvincent.com) to fetch the  result set into an 
object that can be referenced nicely. Here's what  his example code looks like:
  
          // Select multiple records from the database and print them out..
          $users = $db->get_results("SELECT name, email FROM users");
          foreach ( $users as $user ){
                       //  Access data using object syntax
                      echo $user->name;
                      echo $user->email;
          }
  
  So far so good. So I've got an iframe on the page which (I hope) will  
eventually display the results of the search. The user will then click  on the 
search result for which they want to view the details, and the  information 
from that row will be populated inside the main page (the  one that houses the 
iframe).
  
  Hope that makes sense. 
  
  Okay, so my trouble is that I don't know how to enable the page inside  the 
iframe to have access to the result object created by Justin  Vincent's nifty 
little class. In CF I can just say:
  
     session.oResults = queryname
  
  CF automatically returns any query as an object with the name of the  query 
as the object name (i.e. queryname.MyIdField, or  queryname.EmployeeNumber, 
etc.) Using a line like the one above  (assigning the query object to a session 
variable) all of my subsequent  requests would have access to that result set 
simply by using the  object.
  
  I'm *sure* there's a way to do this in PHP. I'm just falling short of finding 
the answer. I've tried:
  
      $_SESSION["SearchResult"] = $db->get_results($query);
  
  But it doesn't seem to work. I may have some other problem using the object. 
I just re-read my error and it says:
  
  Fatal error: Call to a member function get_results() on a non-object in 
inventorymanager.php on line   93
  
  hmm... I sure would appreciate a little guidence here. Even if my  problem is 
with the way I'm using the object, is the idea of assigning  that object to the 
session scope the right way to do this or is there a  better approach. To that 
end, I suppose I'm looking for an idea of the  best practice.
  
  Thanks!
  Christopher Jordan
  Planet Access
  Arlington, TX
  

                        
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 

--- End Message ---
--- Begin Message --- Not sure if I can give a good answer, but try doing a var_dump on $_SESSION["Search Result"] and see what you get. I suspect that it is null. If that's the case then track down where it is getting assigned. It should look something like $_SESSION["SearchResult"] = $users.

Christopher Jordan wrote:
Hi folks,
I'm a ColdFusion developer, but I'm branching out into PHP because alot of my smaller clients don't want to pay for CF. Anyway, a bit of background: I've got a page that does a search on one of my tables. I'm using Justin Vincent's ezSQL (http://php.justinvincent.com) to fetch the result set into an object that can be referenced nicely. Here's what his example code looks like: // Select multiple records from the database and print them out..
          $users = $db->get_results("SELECT name, email FROM users");
          foreach ( $users as $user ){
                       //  Access data using object syntax
                      echo $user->name;
                      echo $user->email;
          }
So far so good. So I've got an iframe on the page which (I hope) will eventually display the results of the search. The user will then click on the search result for which they want to view the details, and the information from that row will be populated inside the main page (the one that houses the iframe). Hope that makes sense. Okay, so my trouble is that I don't know how to enable the page inside the iframe to have access to the result object created by Justin Vincent's nifty little class. In CF I can just say: session.oResults = queryname CF automatically returns any query as an object with the name of the query as the object name (i.e. queryname.MyIdField, or queryname.EmployeeNumber, etc.) Using a line like the one above (assigning the query object to a session variable) all of my subsequent requests would have access to that result set simply by using the object. I'm *sure* there's a way to do this in PHP. I'm just falling short of finding the answer. I've tried: $_SESSION["SearchResult"] = $db->get_results($query); But it doesn't seem to work. I may have some other problem using the object. I just re-read my error and it says: Fatal error: Call to a member function get_results() on a non-object in inventorymanager.php on line 93 hmm... I sure would appreciate a little guidence here. Even if my problem is with the way I'm using the object, is the idea of assigning that object to the session scope the right way to do this or is there a better approach. To that end, I suppose I'm looking for an idea of the best practice. Thanks!
  Christopher Jordan
  Planet Access
  Arlington, TX
                        
---------------------------------
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping

--- End Message ---
--- Begin Message ---
I've been working with php's socket library and I've run accross the
stream_socket_ library. 
I'm wondering whether I should be using that library instead?

Is there anything that makes the stream_socket library superior to the
traditional socket library for writing
TCP/IP socket clients and servers?

Also,  Is there any way to add the functionality of the
stream_socket_enable_crypto() 
to a program written using traditional socket library (any available
classes or extensions that would help
add that functionality?).

thanks alot!
will


--- End Message ---
--- Begin Message ---
Hi
I have php_pdf.dll enabled in php.ini.
I've downloaded this extension from pecl4win.php.net - php 5.1.1 (I'm using 
php-5.1.2-dev snapshot)
The extension is loaded. phpinfo() reports it:

      PDF Support  enabled
      PDFlib GmbH Version  5.0.3
      PECL Version  2.0.5
      Revision  $Revision: 1.144 $


I have also tried libpdf_php.dll from pdflib.com but I get the same error.
This is the code:
$pdf = pdf_new();
pdf_open_file($pdf, "");

$pimg = pdf_open_memory_image($pdf, $im);   <== LINE 52
pdf_begin_page($pdf, 595, 842);
pdf_add_outline($pdf, "Page 1");
pdf_place_image($pdf, $pimg, 0, 500, 1);
pdf_close_image($pdf, $pimg);
pdf_end_page($pdf);
pdf_close($pdf);
$buf = pdf_get_buffer($pdf);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=jpimage.pdf");
echo $buf;
pdf_delete($pdf);

$im is created with jpgraph and displays fine in the browser,

[12-Dec-2005 01:10:04] PHP Fatal error:  Call to undefined function 
pdf_open_memory_image() in C:\www\home\tests\image5g.php on line 52

What's the problem here ?

Best regards
holo

--- End Message ---
--- Begin Message --- The question is null and void, the real question is which do you need to use, just because objects in php behave like arrays, that does not mean the are interchangeable in all cases. You don't create an object just for the sheer hell of it.
--- End Message ---
--- Begin Message ---
This maybe a dumb questions, but in php where is the information taken from
for the date() function?  Is it pulled through Apache or the hardware or in
the php.ini file?  I am having an issue to where the time arbitraly changed
one day from PST to CST.

--- End Message ---

Reply via email to