php-general Digest 4 Mar 2006 00:39:56 -0000 Issue 3996

Topics (messages 231400 through 231428):

Re: LDAP confusion
        231400 by: jblanchard.pocket.com

Re: DOMElement::setAttribute() manual example question
        231401 by: Rob
        231406 by: Gustav Wiberg
        231409 by: Rob
        231412 by: Gustav Wiberg

Re: help with nl2br
        231402 by: Max Schwanekamp
        231403 by: canobit canobit
        231407 by: canobit canobit

Re: Only 4 of 5...
        231404 by: Gustav Wiberg

Coding Practice: Use global $var or pass in by refernce
        231405 by: Mark Steudel
        231408 by: Gustav Wiberg
        231411 by: Andreas Korthaus
        231413 by: Luis Magaña
        231414 by: Gustav Wiberg
        231415 by: Jens Kleikamp
        231418 by: Robert Cummings
        231420 by: tedd
        231423 by: Rafael

Re: APC and PHP 5.1.2
        231410 by: steve
        231416 by: Jens Kleikamp
        231421 by: steve
        231428 by: Jens Kleikamp

Swedish sourgeforge for php-prg
        231417 by: Gustav Wiberg

Help with Acrostix
        231419 by: Jay Contonio

Re: Beware of OS X PHP security update...
        231422 by: Geoff Martin

Prepared statements
        231424 by: Julius Hacker
        231427 by: Anthony Ettinger

Mysql Rows
        231425 by: benifactor
        231426 by: Anthony Ettinger

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 ---
[snip] I vaguely recall you couldn't do an anonymous bind to an active 
directory system - you had to properly authenticate before you could do 
a search.

You didn't include the bind stuff so I can't tell if that's the problem
:)
[/snip]

I thought that I was not doing an anonymous bind, until I changed the
username to something that I know did not exist. The bind occurred (or
appeared to) anyhow.

if(!$ds=ldap_connect("foo")){
        echo "did not connect";
}else {
        echo "connection successful";
}
$un = "user";
$upw = "pass";
echo "connect result is " . $ds . "<br />";
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);

if ($ds) { 
   echo "Binding ..."; 
   if(!$r=ldap_bind($ds, $un, $upd)){
        echo "unable to verify</br>";
   }else{
        echo "verified<br>";
   }    

The result is always "verified".

This should be a really simple operation.

1. user enters name and password
2. if bind is successful redirect them properly
3. else give them a message about incorrect login.

I really do not need to search the AD or any of that (I may want to
install phpldapadmin at some point though).

I feel as if I am missing something very simple, I have always been able
to connect to everything with PHP. Can anyone help me with this please?

--- End Message ---
--- Begin Message ---
Andreas Korthaus wrote:
Hi!

I've a question regarding the example in DOMElement::setAttribute() chapter of the PHP manual: http://de3.php.net/dom-domelement-setattribute

There, an attribute is added to an element this way:

<?php
$doc = new DOMDocument("1.0");
$node = $doc->createElement("root");
$newnode = $doc->appendChild($node);
$newnode->setAttribute("align", "left");
echo $doc->saveXML();
?>

$doc->createElement() returns the created DOMElement, $doc->appendChild() returns the appended DOMNode. Isn't this the same object? Is it a reference?

I'm asking, because the following works too:

<?php
$doc = new DOMDocument("1.0");
$node = $doc->createElement("root");
$node->setAttribute("align", "left");
$doc->appendChild($node);
echo $doc->saveXML();
?>


I like the 2nd example more, because first you create an object (DOMElement), add some attributes to the object and after that append it somewhere to the DOM tree. The 1st example creates a new DOMElement object, appends it to the DOM tree, and adds the attributes not to the created object, but to another object (the DOMNode appended to the tree), which seems to be a reference to the original object.

Why does the manual prefer the (IMO less intuitive) 1st way? Is there a problem with the 2nd way?

Both ways are perfectly valid. $node and $newnode refer to the same object. It was written the 1st way to demonstrate the return value of appendChild(), because in many cases people create the element differently.

i.e.

$newnode = $doc->appendChild($doc->createElement("root"));
or
$newnode = $doc->appendChild(new DOMElement("root"));

Also, in the event $node is created using the new DOMElement syntax:

$node = new DOMElement("root");

the node is read only and must be appended into the tree before it can be modified, so the example just tries to be neutral here regarding the syntax used.

Rob

--- End Message ---
--- Begin Message --- ----- Original Message ----- From: "Rob" <[EMAIL PROTECTED]>
To: "Andreas Korthaus" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Friday, March 03, 2006 4:43 PM
Subject: [PHP] Re: DOMElement::setAttribute() manual example question


Andreas Korthaus wrote:
Hi!

I've a question regarding the example in DOMElement::setAttribute() chapter of the PHP manual: http://de3.php.net/dom-domelement-setattribute

There, an attribute is added to an element this way:

<?php
$doc = new DOMDocument("1.0");
$node = $doc->createElement("root");
$newnode = $doc->appendChild($node);
$newnode->setAttribute("align", "left");
echo $doc->saveXML();
?>

$doc->createElement() returns the created DOMElement, $doc->appendChild() returns the appended DOMNode. Isn't this the same object? Is it a reference?

Check out:
http://de3.php.net/manual/en/function.dom-domdocument-createelement.php
( This function creates a new instance of class DOMElement. This node will not show up in the document unless it is inserted with e.g. DOMNode->appendChild().)

I really don't understand WHY your next example is working...

/G







I'm asking, because the following works too:

<?php
$doc = new DOMDocument("1.0");
$node = $doc->createElement("root");
$node->setAttribute("align", "left");
$doc->appendChild($node);
echo $doc->saveXML();
?>


I like the 2nd example more, because first you create an object (DOMElement), add some attributes to the object and after that append it somewhere to the DOM tree. The 1st example creates a new DOMElement object, appends it to the DOM tree, and adds the attributes not to the created object, but to another object (the DOMNode appended to the tree), which seems to be a reference to the original object.

Why does the manual prefer the (IMO less intuitive) 1st way? Is there a problem with the 2nd way?

Both ways are perfectly valid. $node and $newnode refer to the same object. It was written the 1st way to demonstrate the return value of appendChild(), because in many cases people create the element differently.

i.e.

$newnode = $doc->appendChild($doc->createElement("root"));
or
$newnode = $doc->appendChild(new DOMElement("root"));

Also, in the event $node is created using the new DOMElement syntax:

$node = new DOMElement("root");

the node is read only and must be appended into the tree before it can be modified, so the example just tries to be neutral here regarding the syntax used.

Rob

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


--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:

Check out:
http://de3.php.net/manual/en/function.dom-domdocument-createelement.php
( This function creates a new instance of class DOMElement. This node will not show up in the document unless it is inserted with e.g. DOMNode->appendChild().)

I really don't understand WHY your next example is working...

Every example so far has called appendChild(). The only difference has been when at which point it is called to append the element and how the element to append has been created.

Rob

--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Rob" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Cc: "Andreas Korthaus" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Friday, March 03, 2006 8:04 PM
Subject: Re: [PHP] Re: DOMElement::setAttribute() manual example question


Gustav Wiberg wrote:

Check out:
http://de3.php.net/manual/en/function.dom-domdocument-createelement.php
( This function creates a new instance of class DOMElement. This node will not show up in the document unless it is inserted with e.g. DOMNode->appendChild().)

I really don't understand WHY your next example is working...

Every example so far has called appendChild(). The only difference has been when at which point it is called to append the element and how the element to append has been created.

Rob

Maybe it is so that the objects propertys is created in a certain order undependet of the script order?

/G

--- End Message ---
--- Begin Message ---
canobit canobit wrote:
I have cobbled the following code that when it retrieves the data from
Mysql, the data is displayed with no line breaks which results in one large
paragraph. I have been trying for quite awhile ....without sucess to get
nl2br working with this code. The original data is entered by the user via a
textarea form.
<snip /><snip />
 while($row = mysql_fetch_row($result)) {
echo "<tr><font color=blue size =4>";
echo ".$row[1]</b>";
echo "<tr><font color=black size = 3>";
echo ".$row[2]";
echo " <br> \n";
echo " <br> \n";  <snip />

There is no nl2br in your code sample, so I'm assuming you want to put $row[2] through it? It's about as simple as nl2br($row[2]). If that doesn't work, then perhaps you should post sample code that is failing, and the output you get, along with the output you're expecting.

All that said, you might want to invest some time in learning a DB abstraction layer such as ADODb or PEAR::DB (there are lots of others). You'll commonly find convenience functions to do things like output query results into an HTML table. Why waste time debugging the wheel?

--
Max Schwanekamp
http://www.neptunewebworks.com/

--- End Message ---
--- Begin Message ---
Thanks Pablo, that did the trick with one minor change, I had to remove the
. in the quotations as it is was leading the first line of text with a .

echo "" . nl2br($row[2]) . "</b>";

TD.


On 3/3/06, Pablo M. Rivas <[EMAIL PROTECTED]> wrote:
>
> Hello canobit:
>
> Did you try echo "." . nl2br($row[1]) . "</b>"; ??
>
>
> On 3/2/06, canobit canobit < [EMAIL PROTECTED]> wrote:
> >
> > I have cobbled the following code that when it retrieves the data from
> > Mysql, the data is displayed with no line breaks which results in one
> > large
> > paragraph. I have been trying for quite awhile ....without sucess to get
> > nl2br working with this code. The original data is entered by the user
> > via a
> > textarea form.
> >
> > Any help would be much apreciated...I am still fairly new at programming
> > and
> > it probably shows...
> >
> > Thanks
> > TD.
> >
> >
> > <?php
> >
> > // set database server access variables:
> > $host = "localhost";
> > $user = "develop";
> > $pass = "********";
> > $db = "bio";
> >
> > // open connection
> > $connection = mysql_connect($host, $user, $pass) or die ("Unable to
> > connect!");
> >
> > // select database
> > mysql_select_db($db) or die ("Unable to select database!");
> >
> > // create query
> > $query = "SELECT * FROM main";
> >
> > // execute query
> > $result = mysql_query($query) or die ("Error in query: $query.
> > ".mysql_error());
> >
> > // see if any rows were returned
> > if (mysql_num_rows($result) > 0) {
> >      // yes
> >      // print them one after another
> >     echo "<table cellpadding=0 width = 100% border=0>";
> >
> > while($row = mysql_fetch_row($result)) {
> >
> > echo "<tr><font color=blue size =4>";
> > echo ".$row[1]</b>";
> > echo "<tr><font color=black size = 3>";
> > echo ".$row[2]";
> > echo " <br> \n";
> > echo " <br> \n";
> >
> > }
> >
> > }
> > else {
> > // no
> > // print status message
> > echo "No rows found!";
> > }
> >
> > // free result set memory
> > mysql_free_result($result);
> >
> > // close connection
> > mysql_close($connection);
> >
> >
> > ?>
> >
> >
>
>
> --
> Pablo M. Rivas. http://www.r3soft.com.ar http://www.tres-erres.com.ar
> -----------------------------------------------------------
>

--- End Message ---
--- Begin Message ---
>
> <snip>
> All that said, you might want to invest some time in learning a DB
> abstraction layer such as ADODb or PEAR::DB (there are lots of others).
>   You'll commonly find convenience functions to do things like output
> query results into an HTML table.  Why waste time debugging the wheel?
> --
> Max Schwanekamp
> http://www.neptunewebworks.com/
>



Thanks Max, I will further look into look into this. PEAR::DB looks
interesting!
TD

--- End Message ---
--- Begin Message --- ----- Original Message ----- From: "John Nichel" <[EMAIL PROTECTED]>
To: "PHP General" <[email protected]>
Sent: Friday, March 03, 2006 2:30 AM
Subject: Re: [PHP] Only 4 of 5...


Gustav Wiberg wrote:
Hi there!

What's wrong here??

<?php
...
open db...


$sql = "SELECT IDPic, picNameSmall FROM tbpics";

$querys = mysql_query($sql);
$dbArray = mysql_fetch_array($querys);

You're pulling the first row here

if (intval($frmIDModel)>0) {

?>
<b>Visa telefonbilder för <?php echo $dbModelName;?>:</b><br>
<?php
}
else if (intval($frmIDManufacturer)>0) {

   $dbNameManufacturer = $dbArray["nameManufacturer"];

 ?>
 <b>Visa telefonbilder för <?php echo $dbNameManufacturer;?>:</b><br>
 <?php
}
else {
?>
<b>Alla telefonbilder i arkivet:</b><br>
<?php


So now there are only 4 rows left when you loop thru them here.

   while ($dbArray = mysql_fetch_array($querys)) {
     $dbIDPic = $dbArray["IDPic"];
     $dbPicNameSmall = $dbArray["picNameSmall"];
     ?>
<img src="phonepics/<?php echo $idModel;?>_<?php echo $dbPicNameSmall;?>" alt="testbild från mobil" border="1" width="120" height="130">
     <?php

   }

}
   ?>

I have 5 posts in the table, but the images shown are only four! Why?

/G



--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

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

Thanx, I got feedback on this one yesterday! :) Thanx anyway!

/G

--- End Message ---
--- Begin Message ---
I was wondering what the general rule on using the global driective versus
passing in a variable by reference, why you should or shouldn't, etc.
 
e.g.
 
function ()
{
    global $db;
 
    $res =& $db->query( "SQL");
}
 
or
 
function ( &$db )
{
 
    $res =& $db->query( "SQL");
}

--- End Message ---
--- Begin Message --- ----- Original Message ----- From: "Mark Steudel" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, March 03, 2006 7:46 PM
Subject: [PHP] Coding Practice: Use global $var or pass in by refernce


I was wondering what the general rule on using the global driective versus
passing in a variable by reference, why you should or shouldn't, etc.

e.g.

function ()
{
   global $db;

   $res =& $db->query( "SQL");
}

or

function ( &$db )
{

   $res =& $db->query( "SQL");
}

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

Hi!

My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it!

/G

--- End Message ---
--- Begin Message ---
Hi Gustav!

Gustav Wiberg wrote:

My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it!

Ok, so what's your recommendation to solve the problem with using a DB class in many other objects/methodes? Think of a DB class:

class DB {...}

And a lot of classes which want to use the DB class:

class Foo {
  function saveChangesInDb() {...}
}

class Bar {
  function saveChangesInDb() {...}
}

- You can use a global "$db = new DB..." and pass it to every class/methode,

- you can make $db "global" in each methode,

- you can create a new instance ("new DB") in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or

- use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?).


So what's the way you'd recommend and why?


best regards
Andreas

--- End Message ---
--- Begin Message ---
I would go for:

- you can create a new instance ("new DB") in every methode (but you
  usually only want a single DB-connection per script, and where do you
  pass config-data to access the DB?) or

This way the code keeps well organized and about the use of only one connection I wouldn't worry too much since usually one thread/process is created per script called, so if this is a multiuser application you end up with several connections anyway, besides I think PHP reuses the connections when possible so the performance of your application does not seem affected at all.

I use it, works perfectly with big databases and several users.

Regards.

Andreas Korthaus wrote:
Hi Gustav!

Gustav Wiberg wrote:

My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it!

Ok, so what's your recommendation to solve the problem with using a DB class in many other objects/methodes? Think of a DB class:

class DB {...}

And a lot of classes which want to use the DB class:

class Foo {
  function saveChangesInDb() {...}
}

class Bar {
  function saveChangesInDb() {...}
}

- You can use a global "$db = new DB..." and pass it to every class/methode,

- you can make $db "global" in each methode,

- you can create a new instance ("new DB") in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or

- use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?).


So what's the way you'd recommend and why?


best regards
Andreas


--- End Message ---
--- Begin Message ---

----- Original Message ----- From: "Andreas Korthaus" <[EMAIL PROTECTED]>
To: <[email protected]>; "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Friday, March 03, 2006 8:53 PM
Subject: Re: [PHP] Coding Practice: Use global $var or pass in by refernce


Hi Gustav!

Gustav Wiberg wrote:

My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it!

Ok, so what's your recommendation to solve the problem with using a DB class in many other objects/methodes? Think of a DB class:

class DB {...}

And a lot of classes which want to use the DB class:

class Foo {
  function saveChangesInDb() {...}
}

class Bar {
  function saveChangesInDb() {...}
}

- You can use a global "$db = new DB..." and pass it to every class/methode,

- you can make $db "global" in each methode,

- you can create a new instance ("new DB") in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or

- use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?).


So what's the way you'd recommend and why?


best regards
Andreas

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

Hi Andreas!

I don't have that much experience with classes, but wouldn't it work to:

1. make a connection to the db like $db = <open db>, and then pass around this variable?

2. Extend the DB - class, so the saveChangesInDb() - function in the Foo-class would be an extension from the DB-class
? (I think this works to extend a class in PHP right?)

3 . Use already existing classes for db...http://www.phpclasses.org/ PHP Scripts / Databases

I hope this'll help!

/G

--- End Message ---
--- Begin Message ---
Mark Steudel wrote:
I was wondering what the general rule on using the global driective versus
passing in a variable by reference, why you should or shouldn't, etc.
e.g. function ()
{
    global $db;
$res =& $db->query( "SQL");
}
or function ( &$db )
{
$res =& $db->query( "SQL");
}


or

function foo ()
{
    $db = & $GLOBALS['database'];
    $res = & $db->query();
}

or

function foo ()
{
    $res = & $GLOBALS['database']->query();
}

Just some more possibilities...


cheers
Jens

--- End Message ---
--- Begin Message ---
On Fri, 2006-03-03 at 14:53, Andreas Korthaus wrote:
>
> - use a factory/singleton, which is not so much better than a global 
> variable (and again, what about config-data?).

I use a global configuration to register database connection params.
InterJinn uses something like the following:

$GLOBALS['interJinn']['databases'] = array
(
    'carnageWeb' => array
    (
        'type'     => 'mysql',
        'host'     => 'wocmud.org',
        'user'     => 'me',
        'password' => 'noyou',
        'db'       => 'carnage_web'
    ),

    'carnage' => array
    (
        'host'     => 'wocmud.org',
        'user'     => 'me',
        'password' => 'notyouagain',
        'db'       => 'carnage'
    ),

    'carnageForum' => array
    (
        'host'     => 'wocmud.org',
        'user'     => 'me',
        'password' => 'notyouyetagain',
        'db'       => 'carnage_forum'
    ),

    'default'   => 'carnageWeb',
);

This is consumed by the database manager which is a singleton/factory
that uses connection pooling.

<?php
    $mDb = &$this->getServiceRef( 'dbManager' );

    $db = &$mDb->getConnectionRef();
    $db->query( 'blah blah blah' );

    $db2 = &$mDb->getConnectionRef();
    $db2->query( 'bleh bleh bleh' );

    $db3 = &$mDb->getConnectionRef( 'carnageForum' );
    $db3->query( 'bleh bleh bleh' );

    $db->free();
    $db2->free();
    $db3->free();
?>

In this way all database connections are named such that if something
changes in the future, whether it be the name of the database, the type
of database server, the port, whatever, my code shouldn't need to change
-- only the configuration. Additionally since I retrieve from a pool, I
only ever use as many connections as I need at a time. Be that 1 or 3 or
5. Additionally I know that when I retrieve a second database instance
it's not going to clobber the query from the first request.

I advocate use of the $GLOBALS array for configuration information that
remains static and only when the purpose is clearly defined and well
named such that you can be very sure that you won't run into naming
conflicts in the near future. This is why I use an interJinn sub array
within the globals to segregate InterJinn specific configuration vars.
I'd advocate using constants but they don't support arrays, or at least
not as far back as I maintain compatibility. Why the PHP guys didn't
foresee constant array values is anyone's guess *lol*.

You'll also notice I retrieve the factory/singleton by means of named
service. This avoids most of that interface/inheritance bullshit that
Java gets mired in (and PHP5 has embraced *hahah*). As long as the
expected methods exist then any class can be dropped in as a replacement
via the service registry, whether it extends, implements, burps, or
farts the original class -- or not :)

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 ---
So what's the way [using Globals] you'd recommend and why?

best regards
Andreas

Andreas:

I have to agree with Gustav on this -- I very seldom use Globals. I might use one for debugging, but not for finished code. Their use simply creates problems in porting code, keeping things modular, and maintenance.

Perhaps I'm fortunate, but I usually find a way around using Globals. And since I've been coding in PHP, I've never been forced to use them.

tedd

--
--------------------------------------------------------------------------------
http://sperling.com

--- End Message ---
--- Begin Message ---
Andreas Korthaus wrote:
Hi Gustav!

Gustav Wiberg wrote:

My oponion is that is insane to use global variables. The main drawback with global variables is that is very easy to mix up variables, and keep track of what variable belongs to what. So an advice: Don't use it!


Ok, so what's your recommendation to solve the problem with using a DB class in many other objects/methodes? Think of a DB class:

class DB {...}

And a lot of classes which want to use the DB class:

class Foo {
  function saveChangesInDb() {...}
}

class Bar {
  function saveChangesInDb() {...}
}

- You can use a global "$db = new DB..." and pass it to every class/methode,

- you can make $db "global" in each methode,

- you can create a new instance ("new DB") in every methode (but you usually only want a single DB-connection per script, and where do you pass config-data to access the DB?) or

- use a factory/singleton, which is not so much better than a global variable (and again, what about config-data?).


So what's the way you'd recommend and why?

IMHO, the only way a global variable would have sense is in an environment where you can be assured there's a "DBClass" $db instance, and that it would never ever be a $db var that's not a DBClass instance nor will $db ever be missing. So, can you guarantee this at the present and to the end of times? :)

I think it would be better to create an instance of $db whatever the script you need it, and pass it to every class-constructor as a byref-parameter; i.e.

  $db =& new DBClass();
  ···
  $class1 =& new Class1($db);
  ···
  $class2 =& new Class2($db);

Now, if you insist on using global vars, then maybe, just maybe, it would be better to let that byref-param be optional, and check in the constructor for a global DBClass instance $db if no DBClass instance was given, but then again the problem would be pretty much the same. Try not to rely on global vars, bear in mind that global vars almost always give too little info and do not reflect themselves on the function prototype --well, if you have a smart IDE/editor that understand PHPDoc comments (or something like that) and you do document their existance, it might not be that bad, but still try to avoid them.
--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
http://www.innox.com.mx

--- End Message ---
--- Begin Message ---
Thanks for that! It meant that I should look in other directions which
helped me figure out the problem. Can you try again with:

apc.optimization=1

I think the optimizer is what dies with php 5.1.x. It works for me now
if I don't have that line. :) Too bad APC can't work with Zend
Optimizer, since I think the fact that ZPS and its successors work
faster (and with a lower load average) is partly because of its
optimizations like loop unrolling, etc.

 Personally I found it odd that Zend made it separate, since it slows
down normal PHP execution, and only shines with the opcode cache (and
it does). I do get that it is an "optimizer" and therefore tries to
fool people into using it in order to get their loader for their
encoder in wide distribution. With PHP 6 looking like it will have an
opcode cache by default, I'd think they would want it to be theirs so
as to make everything more compatible with their other products, but I
bet there is some interal reason why that won't happen.

On 3/2/06, Jens Kleikamp <[EMAIL PROTECTED]> wrote:
> steve wrote:
> > You know not what you ask!! I'm going to have to wait a bit before I
> > do that. Currently using Apache 2, and the config files would need to
> > be different, etc., so I'll have to choose a webserver I can take down
> > for a longer time. :(
> >
> > What I did try was different versions of PHP (All using FastCGI &
> > APC-dev) (if this even helps):
> >
> > 5.1.2 -- Failed
> > 5.1.1 -- Failed
> > 5.0.5 -- Success
> >
> > -steve--
> >
> > On 3/2/06, Rasmus Lerdorf <[EMAIL PROTECTED]> wrote:
> >> It probably does.  I have never tried it against the Fastcgi sapi.  Try
> >> it with the Apache module version to rule this out.
> >>
> >> -Rasmus
> >>
> >
>
> Your script works fine for me on linux, php 5.1.2 FastCGI + apc-dev.
>
> Jens
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
steve wrote:
Thanks for that! It meant that I should look in other directions which
helped me figure out the problem. Can you try again with:

apc.optimization=1



Your script also seems to work on my sytem with optimization=1.

--- End Message ---
--- Begin Message ---
Really? Now I am confused on why I'd be having a problem and you
aren't. I even deleted the php.ini file and made a new one that only
contained this:

extension=apc.so
apc.optimization=1

and it still failed. At least I have it working without the second line.

My phpinfo() has this as the configure line (why the quotes?):

'./configure' '--with-mysqli' '--with-pdo' '--with-cli' '--with-gd'
'--with-dom' '--with-zlib' '--with-xml' '--with-openssl'
'--enable-mbstring=all' '--enable-inline-optimization'
'--enable-memory-limit' '--enable-exif' '--enable-fastcgi'
'--enable-force-cgi-redirect' '--without-pear'

Can you check yours?

Maybe there is a conflict with the modules compiled in and APC's
optimizer (though that sounds really strange). Maybe I'll try removing
all of them and recompile and see what happens...

Thanks Jens!

-steve-


On 3/3/06, Jens Kleikamp <[EMAIL PROTECTED]> wrote:
> steve wrote:
> > Thanks for that! It meant that I should look in other directions which
> > helped me figure out the problem. Can you try again with:
> >
> > apc.optimization=1
> >
>
>
> Your script also seems to work on my sytem with optimization=1.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
steve wrote:
Really? Now I am confused on why I'd be having a problem and you
aren't. I even deleted the php.ini file and made a new one that only
contained this:

extension=apc.so
apc.optimization=1

and it still failed. At least I have it working without the second line.

My phpinfo() has this as the configure line (why the quotes?):

'./configure' '--with-mysqli' '--with-pdo' '--with-cli' '--with-gd'
'--with-dom' '--with-zlib' '--with-xml' '--with-openssl'
'--enable-mbstring=all' '--enable-inline-optimization'
'--enable-memory-limit' '--enable-exif' '--enable-fastcgi'
'--enable-force-cgi-redirect' '--without-pear'

Can you check yours?

Maybe there is a conflict with the modules compiled in and APC's
optimizer (though that sounds really strange). Maybe I'll try removing
all of them and recompile and see what happens...


./configure \
--prefix=/usr/local/php5-fcgi \
--with-config-file-path=/etc/php5-fcgi \
--with-mysql=/usr \
--with-zlib \
--enable-fastcgi \
--enable-memory-limit \
--enable-force-cgi-redirect \
--enable-track-vars \
--without-pear \
--with-imap \
--with-imap-ssl \
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-freetype-dir=/usr \
--enable-pdo \
--enable-pdo_mysql \
--with-pdo_mysql \
--with-gettext \
--with-iconv \
--enable-mbstring=all \
--enable-mbregex \
--with-mime-magic=/usr/share/misc/file/magic.mime \
--with-dom \
--with-mcrypt


hth,
Jens



-steve-

--- End Message ---
--- Begin Message ---
Hi there!

I wonder as a swedish PHP-programmer if there are any sites like sourgeforge.net but in swedish?

/G

--- End Message ---
--- Begin Message ---
I am using acrostix so I can add text and photos to an existing pdf.

So far I have the text working with this,

<?php

require("acrostix.php");

$text = file_get_contents("blah.txt");
$doc = ax_open_pdf_file("todo.pdf");
$style = ax_create_standard_styles("Times-Roman", 16);
$region = ax_create_rectangular_region(1, 1, 7.5, 8);
$lines = ax_lay_out_text($text, $region, $style, AX_FULL_JUSTIFY);
ax_add_page_elements($doc->pages[0], $lines);

$image = ax_load_jpeg_file("dingo.jpg", 1, 1, 72);
ax_add_page_elements($doc->pages[0], $image);

header("Content-type: application/pdf");
ax_output_pdf_file($doc);

?>

But the image doesn't add....and I've tried multiple ways. Can any of
you help? Here's the function list for acrostix,

http://www.conradish.net/acrostix/functions.html

And the site for acrostix,

http://chernyshevsky.blogspot.com/

--
Jay Contonio
http://www.jcontonio.com/

--- End Message ---
--- Begin Message ---

On 03/03/2006, at 11:15 PM, Marcus Bointon wrote:

The OS X security update issued yesterday includes a PHP 'fix', by which they mean that it installs PHP 4.4.1. If you have installed PHP 5 from elsewhere, it will get trashed along with your PEAR setup. PEAR is now completely confused or me and just crashes when I try to do anything.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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


I installed the update successfully, no effect on PHP 5.

Perhaps you need to look elsewhere

Geoff

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

so I need help again:
I want to use prepared statements to insert lots of data in my
MySQL-database.
For that I use foreach because I have an array containing all necessary
information.

Before that foreach, I use mysqli_stmt_init, mysql_stmt_prepare and
mysql_stmt_bind_param.
In the foreach-loop I give the variables, which I bound with bind_param,
their values and want to execute the statement.

But now MySQL returns always an error.
It seems that the values I gave the variables in the loop aren't used
because I used bind_param before that.

In the example for mysql_bind_param they do it like me.
Is the example also wrong or do I have to consider something special?

--
Regards
Julius Hacker

http://www.julius-hacker.de
[EMAIL PROTECTED]

OpenPGP-Key-ID: 0x4B4A486E

--- End Message ---
--- Begin Message ---
are you executing the statement in your loop too?


On 3/3/06, Julius Hacker <[EMAIL PROTECTED]> wrote:
> Hi,
>
> so I need help again:
> I want to use prepared statements to insert lots of data in my
> MySQL-database.
> For that I use foreach because I have an array containing all necessary
> information.
>
> Before that foreach, I use mysqli_stmt_init, mysql_stmt_prepare and
> mysql_stmt_bind_param.
> In the foreach-loop I give the variables, which I bound with bind_param,
> their values and want to execute the statement.
>
> But now MySQL returns always an error.
> It seems that the values I gave the variables in the loop aren't used
> because I used bind_param before that.
>
> In the example for mysql_bind_param they do it like me.
> Is the example also wrong or do I have to consider something special?
>
> --
> Regards
> Julius Hacker
>
> http://www.julius-hacker.de
> [EMAIL PROTECTED]
>
> OpenPGP-Key-ID: 0x4B4A486E
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

--- End Message ---
--- Begin Message ---
i need to find a way to find out what number of a row is in a database...

for example:

//this is the database
Username: Chuck Password: adsasa
Username: jimmy Password: adsf
Username: stewart Password: dfds

the information i need is what row jimmy resides on..

this is what i tried:

function i_gun ($user) {
global $username;
$gun = mysql_query("select * from users");
while ($d = mysql_fetch_array($gun)) {
while($d[username] != $user) {
$i = $i + 1;
}
}
}

but it always returns 1. can sombody tell me what i am doing wrong or point me 
in the right direction in the manual? plase and thank you

--- End Message ---
--- Begin Message ---
define $1 = 0 outside your loop.

i'm curious why you are relying on row-order in the database?
Typically you'd have a PRIMARY KEY auto_increment for something like
this.


On 3/3/06, benifactor <[EMAIL PROTECTED]> wrote:
> i need to find a way to find out what number of a row is in a database...
>
> for example:
>
> //this is the database
> Username: Chuck Password: adsasa
> Username: jimmy Password: adsf
> Username: stewart Password: dfds
>
> the information i need is what row jimmy resides on..
>
> this is what i tried:
>
> function i_gun ($user) {
> global $username;
> $gun = mysql_query("select * from users");
> while ($d = mysql_fetch_array($gun)) {
> while($d[username] != $user) {
> $i = $i + 1;
> }
> }
> }
>
> but it always returns 1. can sombody tell me what i am doing wrong or point 
> me in the right direction in the manual? plase and thank you
>


--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

--- End Message ---

Reply via email to