php-general Digest 12 Mar 2008 08:28:07 -0000 Issue 5343
Topics (messages 271313 through 271332):
Re: link with database
271313 by: Shawn McKenzie
271314 by: Shawn McKenzie
Know a JS list serve
271315 by: Skip Evans
271318 by: Greg Donald
Re: Whats faster? simplexml_load_string or simplexml_load_file?
271316 by: Lamonte H
Re: save image in database vs folder
271317 by: Børge Holen
Curl Javascript
271319 by: William Piper
271321 by: Nathan Nobbe
271324 by: chetan rane
Setting a variable inside a function and making it global inside an inner
function doesn't work?
271320 by: Lamonte H
271322 by: Shawn McKenzie
271323 by: Shawn McKenzie
271326 by: Shawn McKenzie
271327 by: Lamonte H
271330 by: Shawn McKenzie
271331 by: Lamonte H
PHP & Ajax progress bar
271325 by: Shelley
271328 by: Wolf
271329 by: Wolf
271332 by: Thijs Lensselink
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 ---
Sofia Jacob (CA) wrote:
> Hi,
>
> I want to create a link that get the name and the link from the database.
>
> The problem is that I get the bullets created with <li> but not the link,
> here is my code and the result:
>
>
>
> <?php
> function do_html_URL($url, $name)
> {
> // output URL as link and br
> ?>
> <a href="<?=$url?>"><?=$name?></a><br>
> <?php
> }
>
> ?>
>
> function display_categories($cat_array)
> {
> if (!is_array($cat_array))
> {
> echo "No hay categorías actualmente disponibles<br>";
> return;
> }
> echo "<ul>";
> foreach ($cat_array as $row)
> {
> $url = "show_cat.php?Categorie_ID=".($row["Categorie_ID"]);
> $title = $row["Catname"];
> echo "<li>";
> do_html_URL($url, $title);
> }
> echo "</ul>";
> echo "<hr>";
> }
>
> function get_categories()
> {
> // Petición a la base de datos de una lista de categorías
> $conn = db_connect();
> $query = "SELECT Categorie_ID, Catname
> FROM categories";
> $result = @mysql_query($query);
> if (!$result)
> return false;
> $num_cats = @mysql_num_rows($result);
> if ($num_cats ==0)
> return false;
> $result = db_result_to_array($result); //db_fns.php
> return $result;
> }
>
>
> $cat_array = get_categories();
> display_categories($cat_array);
>
>
>
>
Shorts tags are not enabled maybe?
use <?php and ?> not <?=.
-Shawn
--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
> Sofia Jacob (CA) wrote:
>> Hi,
>>
>> I want to create a link that get the name and the link from the database.
>>
>> The problem is that I get the bullets created with <li> but not the link,
>> here is my code and the result:
>>
>>
>>
>> <?php
>> function do_html_URL($url, $name)
>> {
>> // output URL as link and br
>> ?>
>> <a href="<?=$url?>"><?=$name?></a><br>
>> <?php
>> }
>>
>> ?>
>>
>> function display_categories($cat_array)
>> {
>> if (!is_array($cat_array))
>> {
>> echo "No hay categorías actualmente disponibles<br>";
>> return;
>> }
>> echo "<ul>";
>> foreach ($cat_array as $row)
>> {
>> $url = "show_cat.php?Categorie_ID=".($row["Categorie_ID"]);
>> $title = $row["Catname"];
>> echo "<li>";
>> do_html_URL($url, $title);
>> }
>> echo "</ul>";
>> echo "<hr>";
>> }
>>
>> function get_categories()
>> {
>> // Petición a la base de datos de una lista de categorías
>> $conn = db_connect();
>> $query = "SELECT Categorie_ID, Catname
>> FROM categories";
>> $result = @mysql_query($query);
>> if (!$result)
>> return false;
>> $num_cats = @mysql_num_rows($result);
>> if ($num_cats ==0)
>> return false;
>> $result = db_result_to_array($result); //db_fns.php
>> return $result;
>> }
>>
>>
>> $cat_array = get_categories();
>> display_categories($cat_array);
>>
>>
>>
>>
> Shorts tags are not enabled maybe?
>
> use <?php and ?> not <?=.
>
> -Shawn
Also, you need to close your <li> with </li> after. That should be
fixed, but you can confirm by looking at your page source. If you see:
<li><a href=""></a><br>
Then short tags are not enabled.
-Shawn
--- End Message ---
--- Begin Message ---
Hey all,
I've been Googling trying to find a JavaScript
list serve to post a question to, but have been,
embarrassingly, unable to find one.
Anyone on one they'd recommend or know of one?
Thanks
*sigh*
--
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison, WI 53703
608-250-2720
http://bigskypenguin.com
=-=-=-=-=-=-=-=-=-=
Check out PHPenguin, a lightweight and versatile
PHP/MySQL, AJAX & DHTML development framework.
http://phpenguin.bigskypenguin.com/
--- End Message ---
--- Begin Message ---
On 3/11/08, Skip Evans <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> I've been Googling trying to find a JavaScript
> list serve to post a question to, but have been,
> embarrassingly, unable to find one.
>
> Anyone on one they'd recommend or know of one?
Not a list, but the peeps in #javascript on irc.freenode.net have
never once failed me when I was stumped.
--
Greg Donald
http://destiney.com/
--- End Message ---
--- Begin Message ---
Daniel Brown <parasane <at> gmail.com> writes:
> snipped
It worked like a charm, thanks. Made it a bit faster.
--- End Message ---
--- Begin Message ---
On Tuesday 11 March 2008 21:24:45 you wrote:
> I've been coding PHP for some time now in combination with MySQL, but I
> have never heard of the possibility of storing images in a database..?
>
> I didn't even know this was possible.
they are stored as binary objects.
for a strategic search directly at the info:
http://www.google.no/search?hl=no&q=mysql+blob&btnG=Google-s%C3%B8k&meta=
for a more learning experience do:
http://www.google.no/search?hl=no&q=storing+images+in+mysql&btnG=S%C3%B8k&meta=
>
> My question now is, where can I find documentation on this? and where are
> these "Archives" you are all talking about?
see these archives is not much to brag about, hard to follow and hard to
search.
Use google. Google is expert in finding weird information regarding stuff you
put in the search field.
I would also follow up on the read on filesystem handling on php.net if you
feel shorthanded regarding comparisons.
> (I've subscribed to the mailing-list yesterday, had no idea such a thing
> existed!)
oh, theres plenty of books written on subjects you know nothing about ;D
>
>
> Thanks.
> - Rick
>
> 2008/3/11, Børge Holen <[EMAIL PROTECTED]>:
> > On Tuesday 11 March 2008 18:30:13 you wrote:
> > > On Tue, Mar 11, 2008 at 11:24 AM, Børge Holen <[EMAIL PROTECTED]> wrote:
> > > > 'n here we go againfff
> > >
> > > Børge, the F's are silent. ;-P
> >
> > =D
> >
> >
> >
> > --
> > ---
> > Børge Holen
> > http://www.arivene.net
> >
> > --
> >
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
--
---
Børge Holen
http://www.arivene.net
--- End Message ---
--- Begin Message ---
I have been using php's curl for quite a while now and it has never
allowed to run javascript... bummer! I read on an article
http://blogs.zdnet.com/Stewart/?p=627 that the new curl v6 allows this.
There are a few ajax sites that I would like to scrape, but they are a
pain to read through all of the functions to figure out how everything
is displayed. I'm hoping that with this addition to the curl library,
this could be more easily done.
Does anyone know when or if the javascript addition will be implemented
to php's curl?
Thanks,
bp
--- End Message ---
--- Begin Message ---
On Tue, Mar 11, 2008 at 6:10 PM, William Piper <[EMAIL PROTECTED]> wrote:
> I have been using php's curl for quite a while now and it has never
> allowed to run javascript... bummer! I read on an article
> http://blogs.zdnet.com/Stewart/?p=627 that the new curl v6 allows this.
>
> There are a few ajax sites that I would like to scrape, but they are a
> pain to read through all of the functions to figure out how everything
> is displayed. I'm hoping that with this addition to the curl library,
> this could be more easily done.
>
> Does anyone know when or if the javascript addition will be implemented
> to php's curl?
me thinks you have curl, http://www.curl.com confused w/ curl,
http://curl.haxx.se/ ;)
check the manual, http://us3.php.net/manual/en/ref.curl.php
-nathan
--- End Message ---
--- Begin Message ---
HI
i think it is a bit difficult. CURL can actually help you get Response on a
cross Domain platform. Javascript dosenot.
Espesially Ajax is not cross domain for security reasons.
On Wed, Mar 12, 2008 at 3:40 AM, William Piper <[EMAIL PROTECTED]> wrote:
> I have been using php's curl for quite a while now and it has never
> allowed to run javascript... bummer! I read on an article
> http://blogs.zdnet.com/Stewart/?p=627 that the new curl v6 allows this.
>
> There are a few ajax sites that I would like to scrape, but they are a
> pain to read through all of the functions to figure out how everything
> is displayed. I'm hoping that with this addition to the curl library,
> this could be more easily done.
>
> Does anyone know when or if the javascript addition will be implemented
> to php's curl?
>
> Thanks,
> bp
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Have A pleasant Day
Chetan. D. Rane
Location: India
Contact: +91-9986057255
other ID: [EMAIL PROTECTED]
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Setting a variable inside a function and making it global inside an
inner function doesn't work?
Right well I have created this function:
[code]
function getForumChildrenTree( $id )
{
$id = intval( $id );
$treeResult = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
applyForumChildrenTree( $id );
}
[/code]
What this function does: Basically this function is set to an id of a
forum id, then theres a variable that stores an array. Then theres a
recursive function called "applyForumChildrenTree" to update the
"treeResult" variable, but it's not exactly working. For some reason
when I did print_r inside the "applyForumChildrenTree" the array is as
applied:
[quote]
Array
(
[forums] => Array
(
[0] => 3
[1] => 8
[2] => 5
)
[topics] => Array
(
[0] => 5
)
[posts] => Array
(
[0] => 5
)
)
[/quote]
Then inside the actual function "getForumChildrenTree" I tried
outputting the "treeResult" array using "print_r" after the recursive
function "applyForumChildrenTree" as follows:
[code]
function getForumChildrenTree( $id )
{
$id = intval( $id );
$treeResult = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
applyForumChildrenTree( $id );
print_r($treeResult);
}
[/code]
and it showed me a blank array, (default array I created) as follows:
[quote]
Array
(
[topics] => Array
(
)
[posts] => Array
(
)
[forums] => Array
(
)
)
[/quote]
Is this a bug? I'm using PHP 5.2.4
--- End Message ---
--- Begin Message ---
Lamonte wrote:
> Setting a variable inside a function and making it global inside an
> inner function doesn't work?
>
> Right well I have created this function:
>
> [code]
> function getForumChildrenTree( $id )
> {
> $id = intval( $id );
> $treeResult = array(
> 'topics' => array(),
> 'posts' => array(),
> 'forums' => array(),
> );
> applyForumChildrenTree( $id );
> }
> [/code]
>
> What this function does: Basically this function is set to an id of a
> forum id, then theres a variable that stores an array. Then theres a
> recursive function called "applyForumChildrenTree" to update the
> "treeResult" variable, but it's not exactly working. For some reason
> when I did print_r inside the "applyForumChildrenTree" the array is as
> applied:
>
> [quote]
> Array
> (
> [forums] => Array
> (
> [0] => 3
> [1] => 8
> [2] => 5
> )
>
> [topics] => Array
> (
> [0] => 5
> )
>
> [posts] => Array
> (
> [0] => 5
> )
>
> )
> [/quote]
>
> Then inside the actual function "getForumChildrenTree" I tried
> outputting the "treeResult" array using "print_r" after the recursive
> function "applyForumChildrenTree" as follows:
>
> [code]
> function getForumChildrenTree( $id )
> {
> $id = intval( $id );
> $treeResult = array(
> 'topics' => array(),
> 'posts' => array(),
> 'forums' => array(),
> );
> applyForumChildrenTree( $id );
> print_r($treeResult);
> }
> [/code]
>
> and it showed me a blank array, (default array I created) as follows:
>
> [quote]
> Array
> (
> [topics] => Array
> (
> )
>
> [posts] => Array
> (
> )
>
> [forums] => Array
> (
> )
>
> )
> [/quote]
>
> Is this a bug? I'm using PHP 5.2.4
Well you haven't defined anything global in your code, unless you did
inapplyForumChildrenTree(), in which case it needs to be global
everywhere that you want to use it as global.
Easiest way would just be to use it like this everywhere:
$GLOBALS['treeResult'] = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
-Shawn
--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
> Lamonte wrote:
>> Setting a variable inside a function and making it global inside an
>> inner function doesn't work?
>>
>> Right well I have created this function:
>>
>> [code]
>> function getForumChildrenTree( $id )
>> {
>> $id = intval( $id );
>> $treeResult = array(
>> 'topics' => array(),
>> 'posts' => array(),
>> 'forums' => array(),
>> );
>> applyForumChildrenTree( $id );
>> }
>> [/code]
>>
>> What this function does: Basically this function is set to an id of a
>> forum id, then theres a variable that stores an array. Then theres a
>> recursive function called "applyForumChildrenTree" to update the
>> "treeResult" variable, but it's not exactly working. For some reason
>> when I did print_r inside the "applyForumChildrenTree" the array is as
>> applied:
>>
>> [quote]
>> Array
>> (
>> [forums] => Array
>> (
>> [0] => 3
>> [1] => 8
>> [2] => 5
>> )
>>
>> [topics] => Array
>> (
>> [0] => 5
>> )
>>
>> [posts] => Array
>> (
>> [0] => 5
>> )
>>
>> )
>> [/quote]
>>
>> Then inside the actual function "getForumChildrenTree" I tried
>> outputting the "treeResult" array using "print_r" after the recursive
>> function "applyForumChildrenTree" as follows:
>>
>> [code]
>> function getForumChildrenTree( $id )
>> {
>> $id = intval( $id );
>> $treeResult = array(
>> 'topics' => array(),
>> 'posts' => array(),
>> 'forums' => array(),
>> );
>> applyForumChildrenTree( $id );
>> print_r($treeResult);
>> }
>> [/code]
>>
>> and it showed me a blank array, (default array I created) as follows:
>>
>> [quote]
>> Array
>> (
>> [topics] => Array
>> (
>> )
>>
>> [posts] => Array
>> (
>> )
>>
>> [forums] => Array
>> (
>> )
>>
>> )
>> [/quote]
>>
>> Is this a bug? I'm using PHP 5.2.4
>
> Well you haven't defined anything global in your code, unless you did
> inapplyForumChildrenTree(), in which case it needs to be global
> everywhere that you want to use it as global.
>
> Easiest way would just be to use it like this everywhere:
>
> $GLOBALS['treeResult'] = array(
> 'topics' => array(),
> 'posts' => array(),
> 'forums' => array(),
> );
>
> -Shawn
After a second look, probably a better alternate would be to have
applyForumChildrenTree() return the array, then use $treeResult =
applyForumChildrenTree( $id );
-Shawn
--- End Message ---
--- Begin Message ---
Lamonte wrote:
> Shawn McKenzie wrote:
>> Shawn McKenzie wrote:
>>
>>> Lamonte wrote:
>>>
>>>> Setting a variable inside a function and making it global inside an
>>>> inner function doesn't work?
>>>>
>>>> Right well I have created this function:
>>>>
>>>> [code]
>>>> function getForumChildrenTree( $id )
>>>> {
>>>> $id = intval( $id );
>>>> $treeResult = array(
>>>> 'topics' => array(),
>>>> 'posts' => array(),
>>>> 'forums' => array(),
>>>> );
>>>> applyForumChildrenTree( $id );
>>>> }
>>>> [/code]
>>>>
>>>> What this function does: Basically this function is set to an id of a
>>>> forum id, then theres a variable that stores an array. Then theres a
>>>> recursive function called "applyForumChildrenTree" to update the
>>>> "treeResult" variable, but it's not exactly working. For some reason
>>>> when I did print_r inside the "applyForumChildrenTree" the array is as
>>>> applied:
>>>>
>>>> [quote]
>>>> Array
>>>> (
>>>> [forums] => Array
>>>> (
>>>> [0] => 3
>>>> [1] => 8
>>>> [2] => 5
>>>> )
>>>>
>>>> [topics] => Array
>>>> (
>>>> [0] => 5
>>>> )
>>>>
>>>> [posts] => Array
>>>> (
>>>> [0] => 5
>>>> )
>>>>
>>>> )
>>>> [/quote]
>>>>
>>>> Then inside the actual function "getForumChildrenTree" I tried
>>>> outputting the "treeResult" array using "print_r" after the recursive
>>>> function "applyForumChildrenTree" as follows:
>>>>
>>>> [code]
>>>> function getForumChildrenTree( $id )
>>>> {
>>>> $id = intval( $id );
>>>> $treeResult = array(
>>>> 'topics' => array(),
>>>> 'posts' => array(),
>>>> 'forums' => array(),
>>>> );
>>>> applyForumChildrenTree( $id );
>>>> print_r($treeResult);
>>>> }
>>>> [/code]
>>>>
>>>> and it showed me a blank array, (default array I created) as follows:
>>>>
>>>> [quote]
>>>> Array
>>>> (
>>>> [topics] => Array
>>>> (
>>>> )
>>>>
>>>> [posts] => Array
>>>> (
>>>> )
>>>>
>>>> [forums] => Array
>>>> (
>>>> )
>>>>
>>>> )
>>>> [/quote]
>>>>
>>>> Is this a bug? I'm using PHP 5.2.4
>>>>
>>> Well you haven't defined anything global in your code, unless you did
>>> inapplyForumChildrenTree(), in which case it needs to be global
>>> everywhere that you want to use it as global.
>>>
>>> Easiest way would just be to use it like this everywhere:
>>>
>>> $GLOBALS['treeResult'] = array(
>>> 'topics' => array(),
>>> 'posts' => array(),
>>> 'forums' => array(),
>>> );
>>>
>>> -Shawn
>>>
>>
>> After a second look, probably a better alternate would be to have
>> applyForumChildrenTree() return the array, then use $treeResult =
>> applyForumChildrenTree( $id );
>>
>> -Shawn
>>
>>
> As I said in my first reply, its a "Recursive function".so I couldn't
> return the array.
>
Please reply to the list.
Sure, your function can return an array if it's recursive. It returns
it to itself and uses whatever logic you need to add to the current
array or merge or remove or whatever. Regardless, I explained why you
aren't seeing the vars as global and a better way to do it using the
$GLOBALS array. I may be off but we would need to see the
applyForumChildrenTree() to know.
-Shawn
--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
Lamonte wrote:
Shawn McKenzie wrote:
Shawn McKenzie wrote:
Lamonte wrote:
Setting a variable inside a function and making it global inside an
inner function doesn't work?
Right well I have created this function:
[code]
function getForumChildrenTree( $id )
{
$id = intval( $id );
$treeResult = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
applyForumChildrenTree( $id );
}
[/code]
What this function does: Basically this function is set to an id of a
forum id, then theres a variable that stores an array. Then theres a
recursive function called "applyForumChildrenTree" to update the
"treeResult" variable, but it's not exactly working. For some reason
when I did print_r inside the "applyForumChildrenTree" the array is as
applied:
[quote]
Array
(
[forums] => Array
(
[0] => 3
[1] => 8
[2] => 5
)
[topics] => Array
(
[0] => 5
)
[posts] => Array
(
[0] => 5
)
)
[/quote]
Then inside the actual function "getForumChildrenTree" I tried
outputting the "treeResult" array using "print_r" after the recursive
function "applyForumChildrenTree" as follows:
[code]
function getForumChildrenTree( $id )
{
$id = intval( $id );
$treeResult = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
applyForumChildrenTree( $id );
print_r($treeResult);
}
[/code]
and it showed me a blank array, (default array I created) as follows:
[quote]
Array
(
[topics] => Array
(
)
[posts] => Array
(
)
[forums] => Array
(
)
)
[/quote]
Is this a bug? I'm using PHP 5.2.4
Well you haven't defined anything global in your code, unless you did
inapplyForumChildrenTree(), in which case it needs to be global
everywhere that you want to use it as global.
Easiest way would just be to use it like this everywhere:
$GLOBALS['treeResult'] = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
-Shawn
After a second look, probably a better alternate would be to have
applyForumChildrenTree() return the array, then use $treeResult =
applyForumChildrenTree( $id );
-Shawn
As I said in my first reply, its a "Recursive function".so I couldn't
return the array.
Please reply to the list.
Sure, your function can return an array if it's recursive. It returns
it to itself and uses whatever logic you need to add to the current
array or merge or remove or whatever. Regardless, I explained why you
aren't seeing the vars as global and a better way to do it using the
$GLOBALS array. I may be off but we would need to see the
applyForumChildrenTree() to know.
-Shawn
Yep I'm using globals, thanks :).
function getForumChildrenTree( $id )
{
$id = intval( $id );
$GLOBALS['treeResult'] = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
applyForumChildrenTree( $id );
$treeResult = $GLOBALS['treeResult'];
unset($GLOBALS['treeResult']);
return $treeResult;
}
--- End Message ---
--- Begin Message ---
Lamonte wrote:
> Shawn McKenzie wrote:
>> Lamonte wrote:
>>
>>> Shawn McKenzie wrote:
>>>
>>>> Shawn McKenzie wrote:
>>>>
>>>>
>>>>> Lamonte wrote:
>>>>>
>>>>>> Setting a variable inside a function and making it global inside an
>>>>>> inner function doesn't work?
>>>>>>
>>>>>> Right well I have created this function:
>>>>>>
>>>>>> [code]
>>>>>> function getForumChildrenTree( $id )
>>>>>> {
>>>>>> $id = intval( $id );
>>>>>> $treeResult = array(
>>>>>> 'topics' => array(),
>>>>>> 'posts' => array(),
>>>>>> 'forums' => array(),
>>>>>> );
>>>>>> applyForumChildrenTree( $id );
>>>>>> }
>>>>>> [/code]
>>>>>>
>>>>>> What this function does: Basically this function is set to an id of a
>>>>>> forum id, then theres a variable that stores an array. Then theres a
>>>>>> recursive function called "applyForumChildrenTree" to update the
>>>>>> "treeResult" variable, but it's not exactly working. For some reason
>>>>>> when I did print_r inside the "applyForumChildrenTree" the array
>>>>>> is as
>>>>>> applied:
>>>>>>
>>>>>> [quote]
>>>>>> Array
>>>>>> (
>>>>>> [forums] => Array
>>>>>> (
>>>>>> [0] => 3
>>>>>> [1] => 8
>>>>>> [2] => 5
>>>>>> )
>>>>>>
>>>>>> [topics] => Array
>>>>>> (
>>>>>> [0] => 5
>>>>>> )
>>>>>>
>>>>>> [posts] => Array
>>>>>> (
>>>>>> [0] => 5
>>>>>> )
>>>>>>
>>>>>> )
>>>>>> [/quote]
>>>>>>
>>>>>> Then inside the actual function "getForumChildrenTree" I tried
>>>>>> outputting the "treeResult" array using "print_r" after the recursive
>>>>>> function "applyForumChildrenTree" as follows:
>>>>>>
>>>>>> [code]
>>>>>> function getForumChildrenTree( $id )
>>>>>> {
>>>>>> $id = intval( $id );
>>>>>> $treeResult = array(
>>>>>> 'topics' => array(),
>>>>>> 'posts' => array(),
>>>>>> 'forums' => array(),
>>>>>> );
>>>>>> applyForumChildrenTree( $id );
>>>>>> print_r($treeResult);
>>>>>> }
>>>>>> [/code]
>>>>>>
>>>>>> and it showed me a blank array, (default array I created) as follows:
>>>>>>
>>>>>> [quote]
>>>>>> Array
>>>>>> (
>>>>>> [topics] => Array
>>>>>> (
>>>>>> )
>>>>>>
>>>>>> [posts] => Array
>>>>>> (
>>>>>> )
>>>>>>
>>>>>> [forums] => Array
>>>>>> (
>>>>>> )
>>>>>>
>>>>>> )
>>>>>> [/quote]
>>>>>>
>>>>>> Is this a bug? I'm using PHP 5.2.4
>>>>>>
>>>>> Well you haven't defined anything global in your code, unless you did
>>>>> inapplyForumChildrenTree(), in which case it needs to be global
>>>>> everywhere that you want to use it as global.
>>>>>
>>>>> Easiest way would just be to use it like this everywhere:
>>>>>
>>>>> $GLOBALS['treeResult'] = array(
>>>>> 'topics' => array(),
>>>>> 'posts' => array(),
>>>>> 'forums' => array(),
>>>>> );
>>>>>
>>>>> -Shawn
>>>>>
>>>> After a second look, probably a better alternate would be to have
>>>> applyForumChildrenTree() return the array, then use $treeResult =
>>>> applyForumChildrenTree( $id );
>>>>
>>>> -Shawn
>>>>
>>>>
>>> As I said in my first reply, its a "Recursive function".so I couldn't
>>> return the array.
>>>
>>>
>>
>> Please reply to the list.
>>
>> Sure, your function can return an array if it's recursive. It returns
>> it to itself and uses whatever logic you need to add to the current
>> array or merge or remove or whatever. Regardless, I explained why you
>> aren't seeing the vars as global and a better way to do it using the
>> $GLOBALS array. I may be off but we would need to see the
>> applyForumChildrenTree() to know.
>>
>> -Shawn
>>
>>
> Yep I'm using globals, thanks :).
>
> function getForumChildrenTree( $id )
> {
> $id = intval( $id );
> $GLOBALS['treeResult'] = array(
> 'topics' => array(),
> 'posts' => array(),
> 'forums' => array(),
> );
> applyForumChildrenTree( $id );
> $treeResult = $GLOBALS['treeResult'];
> unset($GLOBALS['treeResult']);
> return $treeResult;
> }
Good job.
Actually, if you used $GLOBALS['treeResult'] in applyForumChildrenTree()
then you could skip the:
$treeResult = $GLOBALS['treeResult'];
unset($GLOBALS['treeResult']);
return $treeResult;
and just:
return $GLOBALS['treeResult'];
or use $GLOBALS['treeResult']; somewhere later instead of returning it.
Also, I would be curious to see applyForumChildrenTree() because chances
are great that you can return an array and not use globals at all unless
it is "really" needed somewhere else in the app.
-Shawn
--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
Lamonte wrote:
Shawn McKenzie wrote:
Lamonte wrote:
Shawn McKenzie wrote:
Shawn McKenzie wrote:
Lamonte wrote:
Setting a variable inside a function and making it global inside an
inner function doesn't work?
Right well I have created this function:
[code]
function getForumChildrenTree( $id )
{
$id = intval( $id );
$treeResult = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
applyForumChildrenTree( $id );
}
[/code]
What this function does: Basically this function is set to an id of a
forum id, then theres a variable that stores an array. Then theres a
recursive function called "applyForumChildrenTree" to update the
"treeResult" variable, but it's not exactly working. For some reason
when I did print_r inside the "applyForumChildrenTree" the array
is as
applied:
[quote]
Array
(
[forums] => Array
(
[0] => 3
[1] => 8
[2] => 5
)
[topics] => Array
(
[0] => 5
)
[posts] => Array
(
[0] => 5
)
)
[/quote]
Then inside the actual function "getForumChildrenTree" I tried
outputting the "treeResult" array using "print_r" after the recursive
function "applyForumChildrenTree" as follows:
[code]
function getForumChildrenTree( $id )
{
$id = intval( $id );
$treeResult = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
applyForumChildrenTree( $id );
print_r($treeResult);
}
[/code]
and it showed me a blank array, (default array I created) as follows:
[quote]
Array
(
[topics] => Array
(
)
[posts] => Array
(
)
[forums] => Array
(
)
)
[/quote]
Is this a bug? I'm using PHP 5.2.4
Well you haven't defined anything global in your code, unless you did
inapplyForumChildrenTree(), in which case it needs to be global
everywhere that you want to use it as global.
Easiest way would just be to use it like this everywhere:
$GLOBALS['treeResult'] = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
-Shawn
After a second look, probably a better alternate would be to have
applyForumChildrenTree() return the array, then use $treeResult =
applyForumChildrenTree( $id );
-Shawn
As I said in my first reply, its a "Recursive function".so I couldn't
return the array.
Please reply to the list.
Sure, your function can return an array if it's recursive. It returns
it to itself and uses whatever logic you need to add to the current
array or merge or remove or whatever. Regardless, I explained why you
aren't seeing the vars as global and a better way to do it using the
$GLOBALS array. I may be off but we would need to see the
applyForumChildrenTree() to know.
-Shawn
Yep I'm using globals, thanks :).
function getForumChildrenTree( $id )
{
$id = intval( $id );
$GLOBALS['treeResult'] = array(
'topics' => array(),
'posts' => array(),
'forums' => array(),
);
applyForumChildrenTree( $id );
$treeResult = $GLOBALS['treeResult'];
unset($GLOBALS['treeResult']);
return $treeResult;
}
Good job.
Actually, if you used $GLOBALS['treeResult'] in applyForumChildrenTree()
then you could skip the:
$treeResult = $GLOBALS['treeResult'];
unset($GLOBALS['treeResult']);
return $treeResult;
and just:
return $GLOBALS['treeResult'];
or use $GLOBALS['treeResult']; somewhere later instead of returning it.
Also, I would be curious to see applyForumChildrenTree() because chances
are great that you can return an array and not use globals at all unless
it is "really" needed somewhere else in the app.
-Shawn
True, I could, actually I was trying something and my code is exactly
like that. :)
--- End Message ---
--- Begin Message ---
Hi all,
I'm searching some file upload progress bar code.
But no good result was found. :(
So is there anybody please be kind enough to show some code here?
Great thanks.
--
Regard,
Shelley (http://phparch.cn)
--- End Message ---
--- Begin Message ---
Shelley,
What code have you tried and what were your results?
What about searches on google or the archives here?
Wolf
Shelley wrote:
Hi all,
I'm searching some file upload progress bar code.
But no good result was found. :(
So is there anybody please be kind enough to show some code here?
Great thanks.
--
Regard,
Shelley (http://phparch.cn)
--- End Message ---
--- Begin Message ---
As a qualified PHP Engineer , I'm certain you have written some code
that is failing and you need a little help massaging, by all means post
it and we'll gladly take a look and see if we can help facilitate its use.
Wolf
Shelley wrote:
Hi all,
I'm searching some file upload progress bar code.
But no good result was found. :(
So is there anybody please be kind enough to show some code here?
Great thanks.
--
Regard,
Shelley (http://phparch.cn)
--- End Message ---
--- Begin Message ---
Quoting Shelley <[EMAIL PROTECTED]>:
Hi all,
I'm searching some file upload progress bar code.
But no good result was found. :(
So is there anybody please be kind enough to show some code here?
Great thanks.
--
Regard,
Shelley (http://phparch.cn)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
You can try searching the archives. Rasmus had an example a long time ago.
Although it requires APC to be installed. Maybe it's interesting.
Found it:
Example : http://progphp.com/upload.php
Source : http://progphp.com/upload.phps
--- End Message ---