php-general Digest 9 Nov 2003 03:31:35 -0000 Issue 2404
Topics (messages 168958 through 168973):
Re: Problem Understanding Code in 2nd edition Welling/Thomson PHP?MySQL Web
Development Book
168958 by: Duncan
168960 by: Tom Rogers
Re: DW Php update form where one field is menu from another table
168959 by: zerof
Re: How to get the server information
168961 by: Burhan Khalid
Re: the function of the "@" symbol?
168962 by: Burhan Khalid
Re: MX lookup email verification on Windows
168963 by: Manuel Lemos
finding location of document
168964 by: rogue
168965 by: Rainer Bendig aka \"mindz\"
168971 by: Chris Shiflett
Re: Japanese character validation
168966 by: Eugene Lee
Re: {so far OT it boggles} BTML 2.0 released!!!
168967 by: John Nichel
PHP session won't die!
168968 by: rob.ecomnow.com
168969 by: DvDmanDT
Re: BTML 2.0 released!!!
168970 by: John Nichel
168973 by: Javier Muniz
Help With Recursion && Multi-Dimensional Arrays
168972 by: Navid Yar
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 ---
Hi,
from what I see the problem is that you add the authentification passwords to the
database via password('password')
but then your script checks for entries in the database where username= username &
password = password
which cannot work.
You have to make it
where username = username & password = password('password')
exactly:
"
// query the database to see if there is a record which matches
$query = "select count(*) from auth where
name = '$name' and
pass = password('$password')";
"
Regards,
Hendrik
Stephen Tiano wrote:
Sorry for the long post--and the cross-posting to a MySQL list, for those of you
seeing this a second time--but I'm using with difficulty the 2nd edition of
Welling/Thomson's PHP and MySQL Web Development as a textbook for self-teaching (and
I'm at the end of my rope).
After being pleased to work my way thru to Chapter 14, not memorizing the earlier
material, but having some success basically understanding it--I get to the first
"meaty" topic that I was really looking forward to getting into: the business of
authentication.
So I went into MySQL and created the database auth and the table auth, using the
following script:
create database auth;
use auth;
create table auth (
name varchar(10) not null,
pass varchar(30) not null,
primary key (name)
);
insert into auth values
('user', 'pass');
insert into auth values
( 'testuser', password('test123') );
grant select, insert, update, delete
on auth.*
to [EMAIL PROTECTED]
identified by 'rivet';
I used my username that I log into the computer I'm working on--an offline
Powerbook--at the bottom, 'stevet', as well as the password that belongs to that
username, 'rivet'. Since I'm using the test server 'localhost' on the Powerbook, I
used that in the code, as well. These have worked when called for in previous
PHP/MySQL exercises, so it's not something new I invented just for this batch of
tutorials.
Next I opened listing 14.2, secretdb.php--placed properly at the root level for
accessing in my test server--in my browser. Here's secretdb.php:
<?php
if(!isset($_POST['name'])&&!isset($_POST['password']))
{
//Visitor needs to enter a name and password
?>
<h1>Please Log In</h1>
This page is secret.
<form method="post" action="secretdb.php">
<table border="1">
<tr>
<th> Username </th>
<td> <input type="text" name="name"> </td>
</tr>
<tr>
<th> Password </th>
<td> <input type="password" name="password"> </td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Log In">
</td>
</tr>
</table>
</form>
<?php
}
else
{
// connect to mysql
$mysql = mysql_connect( 'localhost', 'stevet', 'rivet' );
if(!$mysql)
{
echo 'Cannot connect to database.';
exit;
}
// select the appropriate database
$mysql = mysql_select_db( 'auth' );
if(!$mysql)
{
echo 'Cannot select database.';
exit;
}
// query the database to see if there is a record which matches
$query = "select count(*) from auth where
name = '$name' and
pass = '$password'";
$result = mysql_query( $query );
if(!$result)
{
echo 'Cannot run query.';
exit;
}
$count = mysql_result( $result, 0, 0 );
if ( $count > 0 )
{
// visitor's name and password combination are correct
echo '<h1>Here it is!</h1>';
echo 'I bet you are glad you can see this secret page.';
}
else
{
// visitor's name and password combination are not correct
echo '<h1>Go Away!</h1>';
echo 'You are not authorized to view this resource.';
}
}
?>
I was greeted by the Please Log In screen. I used 'user' as username and 'pass' as
the password, as that was one of the two combinations the first bit of code above
inserted into the table auth. After submitting, I got the customized error message:
"Go Away! You are not authorized to view this resource."
Just to make certain, I substituted 'root' and my root password in both pieces of
code for 'stevet' and 'rivet', and got the same error screen.
I don't understand why either of those username/password combinations don't work. I
mean, they're in the authorization table. And I'm obviously connecting to the
database, as I'm getting past that stage of the code. Can anyone tell me what I'm too
dense to see?
Thanks very much.
Steve Tiano
--- End Message ---
--- Begin Message ---
Hi,
Sunday, November 9, 2003, 12:48:17 AM, you wrote:
ST> Sorry for the long post--and the cross-posting to a MySQL list, for
ST> those of you seeing this a second time--but I'm using with difficulty
ST> the 2nd edition of Welling/Thomson's PHP and MySQL Web Development as a
ST> textbook for self-teaching (and I'm at the end of my rope).
ST> After being pleased to work my way thru to Chapter 14, not memorizing
ST> the earlier material, but having some success basically understanding
ST> it--I get to the first "meaty" topic that I was really looking forward
ST> to getting into: the business of authentication.
ST> So I went into MySQL and created the database auth and the table auth,
ST> using the following script:
ST> create database auth;
ST> use auth;
ST> create table auth (
ST> name varchar(10) not null,
ST> pass varchar(30) not null,
ST> primary key (name)
ST> );
ST> insert into auth values
ST> ('user', 'pass');
ST> insert into auth values
ST> ( 'testuser', password('test123') );
ST> grant select, insert, update, delete
ST> on auth.*
ST> to [EMAIL PROTECTED]
ST> identified by 'rivet';
ST> I used my username that I log into the computer I'm working on--an
ST> offline Powerbook--at the bottom, 'stevet', as well as the password that
ST> belongs to that username, 'rivet'. Since I'm using the test server
ST> 'localhost' on the Powerbook, I used that in the code, as well. These
ST> have worked when called for in previous PHP/MySQL exercises, so it's not
ST> something new I invented just for this batch of tutorials.
ST> Next I opened listing 14.2, secretdb.php--placed properly at the root
ST> level for accessing in my test server--in my browser. Here's secretdb.php:
ST> <?php
ST> if(!isset($_POST['name'])&&!isset($_POST['password']))
ST> {
ST> //Visitor needs to enter a name and password
?>>
ST> <h1>Please Log In</h1>
ST> This page is secret.
ST> <form method="post" action="secretdb.php">
ST> <table border="1">
ST> <tr>
ST> <th> Username </th>
ST> <td> <input type="text" name="name"> </td>
ST> </tr>
ST> <tr>
ST> <th> Password </th>
ST> <td> <input type="password" name="password"> </td>
ST> </tr>
ST> <tr>
ST> <td colspan="2" align="center">
ST> <input type="submit" value="Log In">
ST> </td>
ST> </tr>
ST> </table>
ST> </form>
ST> <?php
ST> }
ST> else
ST> {
ST> // connect to mysql
ST> $mysql = mysql_connect( 'localhost', 'stevet', 'rivet' );
ST> if(!$mysql)
ST> {
ST> echo 'Cannot connect to database.';
ST> exit;
ST> }
ST> // select the appropriate database
ST> $mysql = mysql_select_db( 'auth' );
ST> if(!$mysql)
ST> {
ST> echo 'Cannot select database.';
ST> exit;
ST> }
ST> // query the database to see if there is a record which matches
ST> $query = "select count(*) from auth where
ST> name = '$name' and
ST> pass = '$password'";
ST> $result = mysql_query( $query );
ST> if(!$result)
ST> {
ST> echo 'Cannot run query.';
ST> exit;
ST> }
ST> $count = mysql_result( $result, 0, 0 );
ST> if ( $count > 0 )
ST> {
ST> // visitor's name and password combination are correct
ST> echo '<h1>Here it is!</h1>';
ST> echo 'I bet you are glad you can see this secret page.';
ST> }
ST> else
ST> {
ST> // visitor's name and password combination are not correct
ST> echo '<h1>Go Away!</h1>';
ST> echo 'You are not authorized to view this resource.';
ST> }
ST> }
?>>
ST> I was greeted by the Please Log In screen. I used 'user' as username and
ST> 'pass' as the password, as that was one of the two combinations the
ST> first bit of code above inserted into the table auth. After submitting,
ST> I got the customized error message: "Go Away! You are not authorized to
ST> view this resource."
ST> Just to make certain, I substituted 'root' and my root password in both
ST> pieces of code for 'stevet' and 'rivet', and got the same error screen.
ST> I don't understand why either of those username/password combinations
ST> don't work. I mean, they're in the authorization table. And I'm
ST> obviously connecting to the database, as I'm getting past that stage of
ST> the code. Can anyone tell me what I'm too dense to see?
ST> Thanks very much.
ST> Steve Tiano
looks like you need to use $_POST['name'] and $_POST['pass'] in the query or
assign those values to $name and $pass first.
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Try: news://forums.macromedia.com
macromedia.dreamweaver.
----------------------
zerof
----
"Robb Kerr" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> I'm using Dreamweaver's "Update Record" form wizard to create a record
> update page. Most of the fields are "text", one is "file" and I want one of
> them to be a "menu". The "menu" field should be populated with the fields
> of another table.
----------------
--- End Message ---
--- Begin Message ---
K. Praveen Kumar wrote:
Dear All,
How can I get the Server Information which operating system the
server is running? Using PHP. please let me know
Read this www.catb.org/~esr/faqs/smart-questions.html
Then RTFM or STFA or STFW where you will find
http://www.php.net/reserved.variables
:|
--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
-----------------------
"Documentation is like sex: when it is good,
it is very, very good; and when it is bad,
it is better than nothing."
--- End Message ---
--- Begin Message ---
Wouter van Vliet wrote:
To me .. This looks more like a line of perl code. I am familiar with the @
sign to kindly ask a function not to give any errors to a function. But can
it really be used like this on vars? What would it suppress, the "notice:
undefined variable $first on line 44" notification?
Probably
Funny..
Not really, considering those kinds of notices are what can prevent some
hour-long headscratching trying to figure out why a piece of code isn't
working when $name was typed as $names.
--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
-----------------------
"Documentation is like sex: when it is good,
it is very, very good; and when it is bad,
it is better than nothing."
--- End Message ---
--- Begin Message ---
Hello,
On 11/07/2003 05:39 PM, Matt Palermo wrote:
Does anyone know of a way to perform an MX lookup on a Windows server to
perform an email verification? Any help on this would be great, since I can
only find code for this that will work on *nix servers. Please let me know
if you can help.
These classes can be used in conjunction to do exactly what you need:
Class: E-mail address validation class
http://www.phpclasses.org/emailvalidation
Class: DNSResolver
http://www.phpclasses.org/phpresolver
--
Regards,
Manuel Lemos
Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Hi there,
I am trying to figure this out and can't find the right combination to
get what I want in a certain situation.
Suppose I am running a script from an URL like:
http://127.0.0.1/~myname/foo/bar.php
on this page I want to redirect to another page and send a full http
string like:
$redirect = "http://" . $_SERVER['HTTP_HOST'] . "/foo/hello.php";
In this case, $_SERVER['HTTP_HOST'] is 127.0.0.1
How can I get the ~/myname/
Thanks
rogue
BTW. Please copy me directly on any replies as I am on the digest.
--- End Message ---
--- Begin Message ---
Have a look on http://us2.php.net/manual/en/function.parse-url.php
So long
Rainer Bendig
crossx.net | wbbreference.de
-----Original Message-----
From: rogue [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 09, 2003 12:06 AM
To: [EMAIL PROTECTED]
Subject: [PHP] finding location of document
Hi there,
I am trying to figure this out and can't find the right combination to
get what I want in a certain situation.
Suppose I am running a script from an URL like:
http://127.0.0.1/~myname/foo/bar.php
on this page I want to redirect to another page and send a full http
string like:
$redirect = "http://" . $_SERVER['HTTP_HOST'] . "/foo/hello.php";
In this case, $_SERVER['HTTP_HOST'] is 127.0.0.1
How can I get the ~/myname/
Thanks
rogue
BTW. Please copy me directly on any replies as I am on the digest.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
--- rogue <[EMAIL PROTECTED]> wrote:
> Suppose I am running a script from an URL like:
>
> http://127.0.0.1/~myname/foo/bar.php
>
> on this page I want to redirect to another page and send a full http
> string like:
>
> $redirect = "http://" . $_SERVER['HTTP_HOST'] . "/foo/hello.php";
>
> In this case, $_SERVER['HTTP_HOST'] is 127.0.0.1
> How can I get the ~/myname/
The complete relative URL requested is avialable to you as:
$_SERVER["REQUEST_URI"]
Hope that helps.
Chris
=====
My Blog
http://shiflett.org/
HTTP Developer's Handbook
http://httphandbook.org/
RAMP Training Courses
http://www.nyphp.org/ramp
--- End Message ---
--- Begin Message ---
On Sat, Nov 08, 2003 at 11:20:27PM +0900, - Edwin - wrote:
:
: On 2003.11.8, at 20:32 Asia/Tokyo, Eugene Lee wrote:
:
: >On Sat, Nov 08, 2003 at 06:26:39PM +0900, - Edwin - wrote:
: >:
: >: Well, I'm sure there's a very good reason why the dictionary
: >: I quoted called it "simplified kanji".
: >
: >I disagree with the term "simplified kanji".
: >
[...]
: >
: > The kana may have been
: >derived from kanji and evolved over the centuries, but they are no
: >longer kanji in the sense that they carry any intrinsic meaning by
: >themselves.
:
: ?? Who said that they are kanji?
Edwin, you quoted the American Heritage Dictionary:
> kana: (quoted from the American Heritage Dictionary)
> "1. Japanese syllabic writing. The characters are simplified kanji
http://www.phparch.com/mailinglists/msg.php?a=729121&s=japanese+character&p=&g=
I am simply explaning that part of the dictionary definition is incorrect.
The statement above, "The characters are simplified kanji", is equal to
the statement, "kana are simplified kanji". The ISA relationship between
kana and kanji is false and does not exist.
However, I do agree without question that kana evolved from kanji.
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
OK, I've decided to be sucked back in for one more response...
If something as trivial as this is where you want to make your big stand
in life, please do it offlist. This went from bas' off topic
introduction of his crap, to the current flaming about posting crap.
You're in the minority here, and your soapbox has fallen apart, so let's
get back to php.
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--- End Message ---
--- Begin Message ---
I cannot, for the love of Job, get a login session to die! I am defining my sessions
using the $_SESSION superglobal, register_globals is off, and I have tried about 15
combinations of unset(), session_unregister(), session_destroy(), session_unset(),
$_SESSION = array(), and even setcookie using a time in the past. As soon as a user
gets back to a pagePlease, if you can offer me any information on how a page with a
session_start call, everything is magically restored as though I never touched the
sessions. Please, if you have any idea what the DEFINATIVE way to absolutely and
completely kill this session is OR if you know where I should post this question, I
would be forever in debt!
Thanks for your time.
Rob.
--- End Message ---
--- Begin Message ---
setcookie(session_name(),"",0,"/");
session_unset();
session_destroy();
or something like that...
--
// DvDmanDT
MSN: dvdmandt€hotmail.com
Mail: dvdmandt€telia.com
##########################
Please, if you are using windows, you may be infected by Swen. Please go
here to find out more:
http://us.mcafee.com/virusInfo/default.asp?id=helpCenter&hcName=swen
http://securityresponse.symantec.com/avcenter/venc/data/[EMAIL PROTECTED]
##########################
<[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
I cannot, for the love of Job, get a login session to die! I am defining
my sessions using the $_SESSION superglobal, register_globals is off, and I
have tried about 15 combinations of unset(), session_unregister(),
session_destroy(), session_unset(), $_SESSION = array(), and even setcookie
using a time in the past. As soon as a user gets back to a pagePlease, if
you can offer me any information on how a page with a session_start call,
everything is magically restored as though I never touched the sessions.
Please, if you have any idea what the DEFINATIVE way to absolutely and
completely kill this session is OR if you know where I should post this
question, I would be forever in debt!
Thanks for your time.
Rob.
--- End Message ---
--- Begin Message ---
Ryan A wrote:
Guys,
I dont mean to get into your very heartfelt flaming / arguement but can you
take this offlist please?
Cheers,
-Ryan
I suggested the same thing...albeit not as nice as you ;) and got a,
"Kiss my ass" response.
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--- End Message ---
--- Begin Message ---
Agreed, and the flexibility of smarty allows for quite a bit more
functionality for the template developer... Anyone seriously considering
template engines should take a hard look at Smarty.
Just my $0.02.
Oh, and if you don't like top-posting, ignore this msg, as I will
undoubtedly ignore your response (actually I won't even have the chance, I
have at this point configured my anti-spam software to automatically delete
msgs with "top post" or "bottom post" in them, and suggest that other users
of this list do the same).
-Javier
-----Original Message-----
From: Chris Hubbard [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 06, 2003 3:13 PM
To: Bas; [EMAIL PROTECTED]
Subject: RE: [PHP] BTML 2.0 released!!!
Bas,
Looks interesting. But why would I use bhtml when I've got Smarty and
10,000 other templating systems to choose from? I'm not interested in the
vauge promises of speed. I'm only interested in systems that make it easier
for me to code. Smarty makes it easier for me to code. How does bhtml help
me?
And ditto on the comments about posting code. Please find a way to make it
readable. Chris
-----Original Message-----
From: Bas [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 06, 2003 7:21 AM
To: [EMAIL PROTECTED]
Subject: [PHP] BTML 2.0 released!!!
Okay, i am happy that BTML 2.0 is released(finally)
It is also known as BTML Template Edition.
The 3 files(the parser, a simple template and a test BTML-file)
btmltpl.php
---
<?php
function tpl2html($title, $images, $text, $tplfile = "simple.tpl", $links =
"") {
$tpldata = file_get_contents($tplfile);
$trans = array('<%title%>' => $title, '<%text%>' => $text, '<%images%>' =>
$images, '<%links%>' => $links);
$html = strtr($tpldata, $trans);
return $html;
}
function parseTags($file) {
/* readfile... here */
$filedata = file_get_contents($file);
$tag_match =("!<bttag=(\w*)>\s*(.*?)\s*</bttag>!is");
preg_match_all($tag_match, $filedata, $matches);
for ($i=0; $i< count($matches[0]); $i++) {
$tagname = $matches[1][$i];
$tag['tagname'] = $tagname;
$tag['value'] = $matches[2][$i];
$tags[] = $tag;
}
return $tags;
}
include_once "template.php";
$filename = $_GET['name'];
$bttags = parseTags($filename);
// echo "<HTML><HEAD>";
foreach($bttags as $tag) {
switch($tag['tagname']) {
case 'title':
$title = $tag['value'];
// echo "<TITLE>" . $tag['value'] . "</TITLE></HEAD><BODY>";
// echo "<H1>" . $tag['value'] . "</h1><br>";
break;
case 'heading':
$completetext .= "<h1>" . $tag['value'] . "</h1><br>";
// echo "<H1>" . $tag['value'] . "</h1><br>";
break;
case 'image':
if (!empty($tag['value'])) {
// echo "<IMG SRC=\"" . $tag['value'] . "\">";
$images .= "<IMG SRC=\"" . $tag['value'] . "\"><br>";
}
break;
case 'text':
// echo nl2br($tag['value']);
$completetext .= nl2br($tag['value']);
break;
case 'nl':
// echo "<br>\n";
$completetext .= "<br>";
break;
case 'template':
$templatefile = $tag['value'];
break;
case 'link':
$links .= "<a href=" . $tag['value'] . ">" . $tag['value'] . "</a><br>"
}
}
// echo "</body></html>";
if (empty($templatefile)) {
echo tpl2html($title, $images, $completetext);
} else {
echo tpl2html($title, $images, $completetext, $templatefile);
}
?>
---
simple.tpl
---
<HTML>
<HEAD><TITLE><%title%></TITLE></HEAD>
<BODY>
<center><h1><%title%></h1></center><br>
<hr>
<%text%><br><br>
Images: <br>
<%images%>
</BODY>
</HTML>
---
And test.btm
---
<bttag=title>
Welcome to BTML page v1!
</bttag>
<bttag=text>
Welcome to my BTML page!!! This is an experimentally version of HTML!!!
<br>Bye!!!
</bttag>
<bttag=nl>
</bttag>
<bttag=heading>
Bye!!!!
</bttag>
---
Hope that you like it and please tell me wat you think of it,
Bas
--
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 ---
Hello Guys,
I need a little bit of help with recursion. I've searched our PHP website
and Google, but none helped me understand my problem. There is a code below
this message in order to help you understand what I am trying to achieve.
Here is an explaination:
What I'm trying to do is list a typical category/subcategory system with
parents and children associated with those parents. My database table
(categories) lists all the parents and children together, each with a
parent_id field
(with root being a value of 0). What I want to do is, if a user clicked on
one of the parent categories, only one level of that category will show (or
only the direct children of that specific category will show). I want the
depth to be endless because I want to control the depth some other way. I
know that using a recursive theory would cost a lot as far as speed goes,
but I'm willing to risk it for now.
Here is the problem: The problem is that the recursive method yields several
arrays, instead of one long array. I tried to use an array_push() function,
but that doesn't seem to work well with multi-dimentional arrays. I tried
the straight way, i.e. $menu_array[$count]['name'] = $name_of_category or
$menu_array['name'][$count] = $name_of_category, but that yields several
arrays instead of one long array or category names. The depth of the
categories can be determined by the $_GET string passed, $_GET['some_path'],
which is in the format: parent1_child1_grandchild1_grandchild2,
etc.($some_path = 1_4_6_8), where all of these are related to each other.
These, of course, are split using the underscore delimeter: $path['0'] = 1,
$path['1'] = 4, and so on.
And finally, here is my question: How do I get all these categories, parents
and children, listed into one array and then returned. I want to be able to
list them on the web page using one array. I will also include id,
parent_id, and other info with each array, but first I want to get the name
listings of the categories to work. Also, if anyone has any suggestions
about a more speedier way to do this, please let me know.
Sorry for the long explaination, I just wanted to make sure you guys
understood my goals. Thanks in advance to anyone that responds, I appreciate
it very much. Here is the code I promised:
-----------------------------------------
function menu_tree($parent_id = '0', $cPath = '', $menu_array = '') {
if (!is_array($menu_array)) {
$menu_array = array();
$cPath = $this->separatePath($_GET['cPath']); // separates $_GET
string into array of category ids
} else {
reset($cPath);
array_shift($cPath);
}
if (sizeof($cPath) >= 0) {
$db = new base_db();
$query = "select cid, name, parent_id from categories where
parent_id = '" . $parent_id . "' order by sort_order, name;";
$categories = $db->fetch_results($query);
//echo sizeof($cPath)."<br />";
//echo $query."<br />";
for ($i = 0, $count = 0; $i < count($categories); $i++, $count++) {
// The following are the methods I tied, but failed to work
//$menu_array['name'][$count] = $categories[$i]['name'];
//$menu_array[]['name'] = $categories[$i]['name'];
//$menu_array['name'][] = $categories[$i]['name'];
//array_push($menu_array, $categories[$i]['name']); // This one works,
but
does not yeild a multi-dimensional array, which is what I need if I were to
add more information to the output of this array, like id and parent_id
//array_push($menu_array[$count]['name'],
$categories[$i]['name']); // This does not work, gives error saying the
first parameter of array_push must be an array
if (($this->get_children($categories[$i]['cid'])) &&
in_array($categories[$i]['cid'],$cPath)) {
$this->menu_tree($categories[$i]['cid'], $cPath,
$menu_array);
}
}
}
print_r($menu_array);
}
-----------------------------------------
Here is what it returns using the print_r() function on $menu_array
Array ( [name] => Array
(
[0] => Cars
[1] => Honda
[2] => Accord
[3] => 1996
[4] => 1997
[5] => 1998
[6] => 1999
[7] => 2000
[8] => 2001
[9] => 2002
)
)
Array ( [name] => Array
(
[0] => Cars
[1] => Honda
[2] => Accord
[3] => Civic
)
)
Array
(
[name] => Array
(
[0] => Cars
[1] => Honda
[2] => Toyota
)
)
Array
(
[name] => Array
(
[0] => Cars
[1] => Suvs
[2] => Trucks
)
)
--- End Message ---