GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 26-May-2004, 12:47
Bohsocks Bohsocks is offline
New Member
 
Join Date: May 2004
Posts: 2
Bohsocks is on a distinguished road

problem including something


I have an array

$fanfic with a part called jblack named after someone
with another part named zelda1 after a story
that has a part called path
which equals the path to a file......

so when I call up $fanfic['jblack']['zelda1']['path'] what command or function should i use to make the FILE listed in the path come up and not the path itself to get printed
  #2  
Old 27-May-2004, 04:47
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello Bohsocks,

I don't understand the question... try sharing some sample data in your reply. Then explain what you expect off that sample data.

On the other hand this looks like a very simple question; which usually means it's not ... I'd guess you're looking for array_keys()?
  #3  
Old 27-May-2004, 13:15
Bohsocks Bohsocks is offline
New Member
 
Join Date: May 2004
Posts: 2
Bohsocks is on a distinguished road
yeah i was looking for uh the PHP code include thing tag but i can't find it.. but anyway
PHP Code:

<?php
$fanfic = array(
        "jblack" => array('email' => 'jackblack@zeldaphoenix.com',
                     'name' => 'Jack Black',
                     $author => array('title' => 'Zelda: Beckoning of the Wind',
                                    'desc' => 'The best story that has ever been written, ever.',
                                    'date' => 'May 4th, 2004',
                                    'genre' => 'Action',
                                    'length' => '150',
                                    'path' => '/sections/fanfiction/beyondgrey'),)
);
?>
<html>
<head>
<title><?=$fanfic[$author][$author]['title']?> by <?=$fanfic[$author]['name']?></title>
</head>
<body bgcolor=#006699 text=#000000 topmargin=25 leftmargin=25 rightmargin=25 bottommargin=25>
<table width=700 align=center bgcolor=#FFFFFF border=1 bordercolor=#000000 cellspacing=15 cellpadding=15>
<tr><td width=300 align=left><font size=1 face="Verdana"><b>Title:</b> <?=$fanfic[$author][$author]['title']?><br>
                <b>Author:</b> <a href=mailto:<?=$fanfic[$author]['email']?>><?=$fanfic[$author]['name']?></a><br>
                <b>Description:</b> <?=$fanfic['jblack'][$author]['desc']?><br></td>
<td width=300 align=left><font size=1 face="Verdana"><b>Date:</b> <?=$fanfic[$author][$author]['date']?><br>
                <b>Genre:</b> <?=$fanfic[$author][$author]['genre']?><br>
                <b>Length:</b> <?=$fanfic[$author]['length']?> Words<br></td></tr>
</table>
<p></p>
<p></p>
<table width=700 align=center bgcolor=#FFFFFF border=1 bordercolor=#000000 cellspacing=15 cellpadding=15>
<tr><td width=700 align=left>
<font size=1 face="Verdana">
<?php
require_once($fanfic[$author][$author]['path']);
?>
</font>
</td></tr>
</table>
</body>
</html>
Last edited by JdS : 28-May-2004 at 04:25. Reason: Please enclose PHP code in [php] & [/php] for syntax highlighting
  #4  
Old 28-May-2004, 04:46
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
It's clear to me now...

PHP Code:

<?php
/* I don't know why you have a variable ($author) for a array keyname here?  So I'll assume it's a typo (otherwise, it'll just be clearer for someone else reading this thread in the future)... and change that to a more descriptive key name like: 'info'
$fanfic = array(
    "jblack" => array('email' => 'jackblack@zeldaphoenix.com',
             'name' => 'Jack Black',
             $author => array('title' => 'Zelda: Beckoning of the Wind',
                  'desc' => 'The best story that has ever been written, ever.',
                  'date' => 'May 4th, 2004',
                  'genre' => 'Action',
                  'length' => '150',
                  'path' => '/sections/fanfiction/beyondgrey'),)
);*/

$fanfic = array(
    "jblack" => array('email' => 'jackblack@zeldaphoenix.com',
             'name' => 'Jack Black',
             'info' => array('title' => 'Zelda: Beckoning of the Wind',
                  'desc' => 'The best story that has ever been written, ever.',
                  'date' => 'May 4th, 2004',
                  'genre' => 'Action',
                  'length' => '150',
                  'path' => '/sections/fanfiction/beyondgrey'),)
);
?>


Now having made that change, to get the path to the include file right, you simply just have to insert a dot (to start looking in this directory) or include the path to your home folder, e.g.

PHP Code:

<?php
// ...
// this will work
require_once( '.'.$fanfic[$author]['info']['path'] );
// or even this...
require_once( '/home/bohsocks/public_html'.$fanfic[$author]['info']['path'] );

?>


Ultimately you should not include the first slash in the path, so the variable $fanfic[$author]['info']['path'] should ideally be 'sections/fanfiction/beyondgrey', this way you can just use the variable like you did in your first attempt (and considering some details are set up right)
 
 

Recent GIDBlogToyota - 2008 July Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C I/O problem kelly80 C Programming Language 4 27-Apr-2004 20:15
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 07:53
problem with php5 cgi installation fab13 Apache Web Server Forum 3 19-Nov-2003 09:11
unwanted scrollbar problem kelly001 Web Design Forum 3 24-Oct-2003 10:44
Geforce FX 5600 Ultra problem jenovasbirth Computer Hardware Forum 1 04-Oct-2003 17:00

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:59.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.