Re: [PHP] trouble with function openssl_csr_new()
On Wed, March 21, 2007 5:05 am, Albert Kopka wrote: > > Hi ... > > I want to generate certificate for smardcard login (MS Win-XP) > and for do that the subject of certificate should contain same key > (in key:value of $dn) multiple times for example ... > > cert generated by ca suplied with W-2003 server for smartcard login > contains: > Subject: DC = local, DC = foo, CN = Users, CN = bar > > but $dn is an array ... so if I define array as: > > $dn = array ( "DC" => "local", "DC" => "foo" ); > > I've got array with one key:value pair "DC" => "foo" ... > > Is there any other way to pass the $dn to function ... > (using other structure ... or formated string ... ) > or mayby I can use other function whitch supports repeated keys ? WILD GUESS!!! If the person who wrote openssl_csr_new() thinks like I do, maybe: $dn = array("DC"=>array("local","foo"), "CN"=>"Users"); -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] trouble with function
Thanks for all your help :) Justin on 26/08/02 1:55 AM, Michael Sims ([EMAIL PROTECTED]) wrote: > On Sun, 25 Aug 2002 10:49:00 -0500, you wrote: > >> static $myrow; >> if($myrow = mysql_fetch_array($result)) { > [...] > > Oops. We want to remember the position of the result set, so it's > $result that should be static, not $myrow. In addition, you'll have > to put a check at the top of the function to see if $result is still > valid, and to have it not re-run the query if it is. Otherwise you'll > get the first row back every time. Come to thing of it, it's probably > just easier to get all the songs back at once and then do a foreach. > :-) > > -- > 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] trouble with function
On Sun, 25 Aug 2002 10:49:00 -0500, you wrote: >static $myrow; >if($myrow = mysql_fetch_array($result)) { [...] Oops. We want to remember the position of the result set, so it's $result that should be static, not $myrow. In addition, you'll have to put a check at the top of the function to see if $result is still valid, and to have it not re-run the query if it is. Otherwise you'll get the first row back every time. Come to thing of it, it's probably just easier to get all the songs back at once and then do a foreach. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] trouble with function
On Mon, 26 Aug 2002 01:12:56 +1000, you wrote: >However, I was hoping to use it in a similar way that I use mysql in the >above code... something like: >while($song = getSongByArtist(4)) >{ >echo song['title']; >echo song['writers']; >echo song['video']; >echo song['artist_id']; >} >?> > >But it's just running through an infinite loop. Perhaps mysql_fetch_array() >is doing something magic??? Perhaps I need to return something different in >my function? Your function (which I've snipped for space considerations) is populating a multidimensional array with an entire result set. So if your artist as 4 songs, you'll get a 2 dimensional array where the first dimension has 4 elements. (For that reason, your function really needs to be caled getsongSbyartist, since it gets all the songs an artist has.) In the code above you want to treat your function as if it's returning a one dimensional array containing only one row from the result set. You're right, you could get the return value from your function, then use: $songs = getSongByArtist(4); foreach($songs as $id => $song) { echo song['title']; ... } But if you really want to use it in a similar fashion to the way mysql_fetch_array() works, you're going to have to change what your function returns. You can use a static variable to store the state of the result set inside your function, and only return one row at a time. For example: static $myrow; if($myrow = mysql_fetch_array($result)) { foreach($myrow as $k => $v) { $$k = $v; } $song = array ( 'title' => ...); return $song; } else { return false; } That way your function remembers the position of the result set between calls, and returns one song at a time, until there are no more left, and then it returns false. I haven't tested the above, but it should behave the way you expect. HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] trouble with function
Everytime you call the function, it re-runs the sql, and gives you the same list. The only time it wouldn't do that was if the id wasn't found. You could probably change the function to a class, where the constuctor ran the sql, and then you had another method to get the next entry. - Original Message - From: "Justin French" <[EMAIL PROTECTED]> To: "php" <[EMAIL PROTECTED]> Sent: Sunday, August 25, 2002 11:12 AM Subject: [PHP] trouble with function > Hi, > > This is the first time I've REALLY tackled multi-dimensional arrays, in > conjunctions with functions. > > I like the way this code works: > > $sql = "select from"; > $result = mysql_result($sql); > while($myrow = mysql_fetch_array($result)) > { > echo $myrow['colname']; > } > ?> > > So I built a function which returns a multi-dimensional array: > > function getSongByArtist($artist_id,$order='title ASC') > { > > $sql = " > SELECT * > FROM songs > WHERE artist_id='{$artist_id}' > ORDER BY {$order} > "; > $result = mysql_query($sql); > if(!$result) > { > return 0; > } > else > { > while($myrow = mysql_fetch_array($result)) > { > foreach($myrow as $k => $v) > { $$k = $v; } > > $songs["$id"] = array( > 'title' => "$title", > 'writers' => "$writers", > 'video' => "$video", > 'artist_id' => "$artist_id" > ); > } > return $songs; > } > } > ?> > > I can then do: > $songs = getSongByArtist(4); > print_r($song); > ?> > ... and it prints the results I'm expecting. All good. > > > However, I was hoping to use it in a similar way that I use mysql in the > above code... something like: > while($song = getSongByArtist(4)) > { > echo song['title']; > echo song['writers']; > echo song['video']; > echo song['artist_id']; > } > ?> > > But it's just running through an infinite loop. Perhaps mysql_fetch_array() > is doing something magic??? Perhaps I need to return something different in > my function? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php