Current location: Hot Scripts Forums » Programming Languages » PHP » Someone Help, This Is Getting Aggravating


Someone Help, This Is Getting Aggravating

Reply
  #1 (permalink)  
Old 01-30-04, 03:25 PM
Ice_Metal Ice_Metal is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Ontario, Canada
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Someone Help, This Is Getting Aggravating

Hey, Im trying to get this code to work but i keep getting unexpected $end errors. I had to take my message board down today because im trying to add categories and since i tryed to do so... its stoped working. this is my code

PHP Code:

if ($id == "idx"){

    
$file file("./forum/cat.toc.php");
    
array_shift($file);
    foreach (
$file as $element){
    list (
$blank$cat_name$cat_des$cid) = explode ('|<|'$element);
    echo <<<html
        <table width="600" border="0">
              <tr> 
                <td width="6%">
$read</td>
                <td width="58%"><strong>
$cat_name</strong></td>
                <td width="18%">Topics: </td>
                <td width="18%">Posts: </td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
                <td colspan="3">
$cat_des</td>
              </tr>
        </table>
    html;
    }
}
elseif (
$id == "showforum"){
    
$cid = $HTTP_GET_VARS[cid];
    
$file = file("./forum/cat.$cid.php");
    array_shift(
$file);
    foreach (
$file as $element){
    list (
$blank$title$poster$date$mid) = explode ('|<|', $element);
    echo <<<html
    <table width="600" border="0">
          <tr> 
            <td width="7%">
$read</td>
          <td width="51%"><strong>
$title</strong></td>
          <td width="24%">Posted By:
$poster</td>
             <td width="18%">
$date</td>
      </tr>
    </table>
    html;
    }
}
elseif (
$id == "viewmessage"){
    
$mid = $HTTP_GET_VARS[mid];
    
$file = file("./forum/message/$mid.php");
    array_shift(
$file);
    foreach(
$file as $element){
    list (
$blank$title$poster$date$message) = explode ('|<|', $element);
    echo <<html
    the code for viewing the message here
    html;
}
?> 
thats jsut a snip of it. but its the gest of it. So if someone can help, it would be appreciated. thanks
Reply With Quote
  #2 (permalink)  
Old 01-30-04, 04:02 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
when ever you see this error message again you should double check the braces!
you forgot to close the last block of elseif statment with the brace of foreach..
all you need to do is add a } at the end of this code
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 01-30-04, 05:59 PM
Ice_Metal Ice_Metal is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Ontario, Canada
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
lolthis is the first time i came back to the forum since i posted this topic and well.... i got it working already now my admin section to add a categorie dosnt work.

PHP Code:

elseif ($id == "enter_cat"){

<form method=post action=?id=create_cat>
Cat Name<input name=catname type=text id=catname><br>
Cat Description<input name=catdes type=text id=catdes><br>
<input name=submit type=submit value=submit>
}
elseif ($id == "create_cat"){
$file = file("./forum/cat.toc.php");
array_shift($file);
$cid = 1;
foreach ($file as $element){
list ($blank, $cat_name, $cat_des, $cid) = explode ('|<|', $element);
$cid ++;
}
$fp = fopen ("./forum/cat.toc.php", "a");
fputs ($fp, "|<|$_POST[cat_name]|<|$_POST[cat_des]|<|$cid\n");
fclose ($fp);
$fp = fopen ("./forum/cat.$cid.php", "x");
fputs ($fp, "<?php die('cannot access file'); ?>\n");
fclose ($fp);
}
Any Clue Why It Wont Work ?? Thanks
~Lance
Reply With Quote
  #4 (permalink)  
Old 01-30-04, 10:37 PM
Ice_Metal Ice_Metal is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Ontario, Canada
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Um..... this is a big one. Im getting the $end error again
PHP Code:

elseif ($id == "post"){

    if (
$mode == "topic"){
    
$cid $HTTP_POST_VARS[cid];
    echo <<<html
    <form method=post action=post&action=post>
    <input name="cid" type="hidden" id="cid" value="cid">
    <input name="topic" type="hidden" id="topic" value="topic">
    Title:<input name=title type=text id=title><br>
    Message:<input name=message type=text id=message><br>
    <input name=submit type=submit id=submit value=post>
    html;
    }
    elseif (
$mode == "reply"){
    
$mid = $HTTP_POST_VARS[mid];
    echo <<<html
    <form method=post action=post&action=post>
    <input name="mid" type="hidden" id="mid" value="mid">
    <input name="reply" type="hidden" id="reply" value="reply">
    Title:<input name=title type=text id=title><br>
    Message:<input name=message type=text id=message><br>
    <input name=submit type=submit id=submit value=post>
    html;
    }
        if (
$action == "post"){
            //Needed Vars
            
$topic = $HTTP_POST_VARS[topic];
            
$reply = $HTTP_POST_VARS[reply];
            
$cid = $HTTP_POST_VARS[cid];
            
$mid = $HTTP_POST_VARS[mid];
            
$date = date(D M, d / h:i);
    
            //Getting Message ID
            
$file = file("./forum/toc.php")
            array_shift(
$file);
            
$mid2 = 1;
            foreach(
$file as $element){
            list (
$blank$title$user) = explode ('|<|', $element);
            
$mid2 ++;
            }
    
        if ( 
$topic = "topic"){
            //Add to Cat TOC
            
$fp = fopen("./forum/cat.$cid.php", "a");
            fputs (
$fp, "|<|$read|<|$_POST[title]|<|$ext_user|<|$date|<|$mid2\n");
            fclose (
$fp);
            //Add To Main TOC
            
$fp = fopen("./forum/toc.php", "a");
            fputs (
$fp, "|<|$_POST[title]|<|$ext_user\n");
            fclose (
$fp);
            //Create message File
            
$fp = fopen("./forum/message/$mid2.php", "x");
            fputs (
$fp, "|<|$_POST[title]|<|$ext_user|<|$date|<|$ext_icon|<|$ext_sig|<|$ext_lvl\n");
            fclose (
$fp);
            //Create Reply File
            
$fp = fopen("./forum/reply/reply.$mid2.php", "a");
            fputs (
$fp, "|<|$_POST[title]|<|$ext_user|<|$date|<|$ext_icon|<|$ext_sig|<|$ext_lvl\n");
            fclose (
$fp);
        }
        if (
$reply = "reply"){
            
$fp = fopen("./forum/reply/reply.$mid.php", "a");
            fputs (
$fp, "|<|$_POST[title]|<|$ext_user|<|$date|<|$ext_icon|<|$ext_sig|<|$ext_lvl\n");
            fclose (
$fp);
        }
    }

That code is ALL for 1) Posting a New Topic 2)Posting a reply 3) Handeling the info to post the new topic 4) Handeling the info to post a new reply.

id prefer to keep it all in that jumble of code But ive been working on this one for a few hours and nnnnnooooo luck. Please Help, thanks.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 08:10 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.