Results 1 to 4 of 4
  1. #1

    Question More errors! Grrr

    The error I'm getting is around the br() function area.
    Help!
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    function html() {
    document.form.text.value = document.form.text.value + "<HTML></HTML>";
    }
    function head() {
    document.form.text.value = document.form.text.value + "<HEAD></HEAD>";
    }
    function title() {
    document.form.text.value = document.form.text.value + "<TITLE></TITLE>";
    }
    function body() {
    document.form.text.value = document.form.text.value + "<BODY></BODY>";
    }
    function body() {
    document.form.text.value = document.form.text.value + "<META NAME=\"keywords\" CONTENT=\"games,jokes,stuff\"><META NAME=\"description\" CONTENT= \"Come to my page please!\"> ";
    }
    function css() {
    document.form.text.value = document.form.text.value + "<LINK REL=\"STYLESHEET\" TYPE=\"TEXT/CSS\" HREF=\"style.css\">";
    }
    function table() {
    document.form.text.value = document.form.text.value + "<TABLE BACKGROUND=\"color\" BORDER=\"bordersize\" BORDERCOLOR=\"color\">";
    document.form.text.value = document.form.text.value + "<TR ALIGN=\"left\" VALIGN=\"top\">";
    document.form.text.value = document.form.text.value + "<TD WIDTH=\"10%\">";
    document.form.text.value = document.form.text.value + "</TD>";
    document.form.text.value = document.form.text.value + "</TR>";
    }
    function br() {
    document.form.text.value = document.form.text.value + "<BR>";
    }
    function hr() {
    document.form.text.value = document.form.text.value + "<HR WIDTH=\"30%\">";
    }
    function effect(var effect) {
    document.form.text.value = document.form.text.value + "<";
    document.form.text.value = document.form.text.value + "" + effect;
    document.form.text.value = document.form.text.value + ">Text Here</";
    document.form.text.value = document.form.text.value + "" + effect;
    document.form.text.value = document.form.text.value + ">";
    }
    function h(var h) {
    document.form.text.value = document.form.text.value + "<H";
    document.form.text.value = document.form.text.value + "" + h;
    document.form.text.value = document.form.text.value + ">Text here</";
    document.form.text.value = document.form.text.value + "" + h;
    document.form.text.value = document.form.text.value + ">";
    }
    function fontsize() {
    document.form.text.value = document.form.text.value + "<FONT SIZE=\"number\">Text here</FONT>";
    }
    function fontcolor() {
    document.form.text.value = document.form.text.value + "<FONT COLOR=\"color\">Text here</FONT>";
    }
    function fontfamily() {
    document.form.text.value = document.form.text.value + "<FONT FAMILY=\"name\">Text here</FONT>";
    }
    function fontm(var min) {
    document.form.text.value = document.form.text.value + "<FONT SIZE=\"-";
    document.form.text.value = document.form.text.value + "" + min;
    document.form.text.value = document.form.text.value + "\">Text Here</FONT>";
    }
    function fontp(var add) {
    document.form.text.value = document.form.text.value + "<FONT SIZE=\"+";
    document.form.text.value = document.form.text.value + "" + add;
    document.form.text.value = document.form.text.value + "\">Text Here</FONT>";
    }
    function align(var align) {
    document.form.text.value = document.form.text.value + "<DIV ALIGN=\"+";
    document.form.text.value = document.form.text.value + "" + add;
    document.form.text.value = document.form.text.value + "\">Text Here</DIV>";
    }
    function link(var addy, var text) {
    document.form.text.value = document.form.text.value + "<A HREF=\"";
    document.form.text.value = document.form.text.value + "" + addy;
    document.form.text.value = document.form.text.value + "\">;
    document.form.text.value = document.form.text.value + "" + text;
    document.form.text.value = document.form.text.value + "</A>";
    }
    function image() {
    document.form.text.value+="<IMG SRC=\"http://www.example.com/example.gif\">";
    }
    </SCRIPT>
    <FORM ACTION="<? print $PHP_SELF ?>" METHOD="POST" NAME="form">
    <INPUT TYPE="HIDDEN" NAME="password" VALUE="putzypoo">
    <INPUT TYPE="HIDDEN" NAME="action" VALUE="edit">
    <INPUT TYPE="HIDDEN" NAME="write" VALUE="yes">
    <INPUT TYPE="HIDDEN" NAME="file" VALUE="<? print $file ?>">
    <TEXTAREA NAME="text" ROWS="20" COLS="50"><?php include("$file"); ?></TEXTAREA><BR><BR>
    <OL>ADD TAGS:</OL><BR>
    <A HREF="javascript:html()">HTML</A> - <A HREF="javascript:head()">HEAD</A> - <A HREF="javascript:title()">TITLE</A> - <A HREF="javascript:body()">BODY</A><BR><BR>
    
    <A HREF="javascript:meta()">META</A> - <A HREF="javascript:css()">CSS Include</A> - <A HREF="javascript:table()">TABLE</A> - <A HREF="javascript:br()">Break Line</A> - <A HREF="javascript:hr()">Horizontal Rule</A><BR><BR>
    
    <A HREF="javascript:effect('B')">Bold</A> - <A HREF="javascript:effect('U')">Underline</A> - <A HREF="javascript:effect('I')">Italic</A> - <A HREF="javascript:effect('TT')">Typewriter</A><BR><BR>
    
    <A HREF="javascript:h(1)">Header 1</A> - <A HREF="javascript:h(2)">Header 2</A> - <A HREF="javascript:h(3)">Header 3</A> - <A HREF="javascript:h(4)">Header 4</A> - <A HREF="javascript:h(5)">Header 5</A> - <A HREF="javascript:h(6)">Header 6</A><BR><BR>
    
    <A HREF="javascript:fontsize()">Set Font Size</A> - 
    <A HREF="javascript:fontcolor()">Set Font Color</A> - 
    <A HREF="javascript:fontfamily()">Set Font Family</A> - 
    <A HREF="javascript:fontm(1)">Font Size Minus 1</A> - 
    <A HREF="javascript:fontm(2)">Font Size Minus 2</A> -
    <A HREF="javascript:fontm(3)">Font Size Minus 3</A> -
    <A HREF="javascript:fontm(4)">Font Size Minus 4</A> -
    <A HREF="javascript:fontm(5)">Font Size Minus 5</A> -
    <A HREF="javascript:fontm(6)">Font Size Minus 6</A> -
    <A HREF="javascript:fontp(1)">Font Size Plus 1</A> - 
    <A HREF="javascript:fontp(2)">Font Size Plus 2</A> -
    <A HREF="javascript:fontp(3)">Font Size Plus 3</A> -
    <A HREF="javascript:fontp(4)">Font Size Plus 4</A> -
    <A HREF="javascript:fontp(5)">Font Size Plus 5</A> -
    <A HREF="javascript:fontp(6)">Font Size Plus 6</A><BR><BR>
    
    <A HREF="javascript:align('left')">Align Text Left</A> -
    <A HREF="javascript:align('center')">Align Text Center</A> -
    <A HREF="javascript:align('right')">Align Text Right</A><BR><BR>
    
    <A HREF="javascript:link('mailto:[email protected]','Email Text')">Email Link</A> -   
    <A HREF="javascript:link('http://www.example.com','Link Text')">Link</A><BR><BR>
    
    <A HREF="javascript:image()">Image</A> -   
    <INPUT TYPE="SUBMIT" VALUE="Save"> 
    <?			
    			}
    			if($write == "yes") {
    			if(file_exists($file)) {
    			$filea = fopen($file, w);
    	                fwrite($filea, "$text");
    			fclose($filea);
    			print("Success: wrote to file.");
    			}
    else {
    print("File does not exist");
    }
    }
    		}
    		if($action == "view") {
    			?>Delete: config.php?password=putzypoo&action=delete&file=filename.ext<BR><BR>
    Create: config.php?password=putzypoo&action=create&file=filename.ext<BR><BR>
    Rename: config.php?password=putzypoo&action=rename&file=filename.ext&newfile=filename.ext<BR><BR>
    Edit: config.php?password=putzypoo&action=edit&file=filename.ext<BR><BR><BR>
    <FORM METHOD="POST" ACTION="<? print $PHP_SELF ?>">
    <INPUT TYPE="hidden" NAME="password" VALUE="putzypoo">
    <INPUT TYPE="hidden" NAME="action" VALUE="delete">
    <INPUT TYPE="text" NAME="file">
    <INPUT TYPE="submit" VALUE="Delete File"><BR>
    </FORM>
    
    <FORM METHOD="POST" ACTION="<? print $PHP_SELF ?>">
    <INPUT TYPE="hidden" NAME="password" VALUE="putzypoo">
    <INPUT TYPE="hidden" NAME="action" VALUE="create">
    <INPUT TYPE="text" NAME="file">
    <INPUT TYPE="submit" VALUE="Create File"><BR>
    </FORM>
    
    <FORM METHOD="POST" ACTION="<? print $PHP_SELF ?>">
    <INPUT TYPE="hidden" NAME="password" VALUE="putzypoo">
    <INPUT TYPE="hidden" NAME="action" VALUE="rename">
    <INPUT TYPE="text" NAME="file" VALUE="CURRENT">
    <INPUT TYPE="text" NAME="newfile" VALUE="RENAME TO">
    <INPUT TYPE="submit" VALUE="Rename"><BR>
    </FORM>
    
    <FORM METHOD="POST" ACTION="<? print $PHP_SELF ?>">
    <INPUT TYPE="hidden" NAME="password" VALUE="putzypoo">
    <INPUT TYPE="hidden" NAME="action" VALUE="edit">
    <INPUT TYPE="text" NAME="file">
    <INPUT TYPE="submit" VALUE="Edit"><BR>
    </FORM>
    Thanks!

    -Josh

  2. #2
    Join Date
    Oct 2001
    Posts
    307
    First off, I would start with something much much smaller until you learned more about javascript... with this much code it's far too easy to make a simple mistake or misplaced bracket that you'll spend hours trying to find.

    Some things:
    When calling javascript from an href, use
    HREF="javascript:html()" (no space)
    not
    HREF="java script:html()"
    ***EDIT: This is not your fault but I left it here so others don't point it out. The forum breaks up the word "java script." Your own code is probably fine. My bad.***

    It might work, might not, but even still avoid using function names that are also reserved words and datatypes. Example:
    Instead of
    function image()
    maybe use
    function add_image()
    I would recommend putting "add_" in front of all your function names in this case actually.

    Again, *maybe* it would work, but don't use variables the same name as the function. Instead of:
    function align(var align)
    maybe use
    function add_align(var alignto)

    Likewise, in your HTML, avoid giving an element the same name as its type. Use meaningful names. Instead of:
    <FORM ... NAME="form">
    <TEXTAREA ... NAME="text">
    use
    <FORM ... NAME="mainform">
    <TEXTAREA ... NAME="htmsource">
    or something

    Your PHP errors are coming from misplaced or extra brackets. Indenting will help you spot these. Instead of
    PHP Code:
                }
                if(
    $write == "yes") {
                if(
    file_exists($file)) {
                
    $filea fopen($filew);
                        
    fwrite($filea"$text");
                
    fclose($filea);
                print(
    "Success: wrote to file.");
                }
    else {
    print(
    "File does not exist");
    }
    }
            } 
    use
    PHP Code:
    if($write == "yes") {
        if(
    file_exists($file)) {
            
    $filea fopen($filew);
                
    fwrite($filea"$text");
            
    fclose($filea);
            print(
    "Success: wrote to file.");
        } else {
            print(
    "File does not exist");
        }

    Please, please, please. Learn what you are doing and why. Ask questions. But don't copy-paste code from one site, try to run it, and then post the entire code somewhere else asking why it doesn't work. Programming isn't learned overnight; don't take offense to my comments. If you take your time, put in the effort, and learn how to do it right, someone will always help you if you get stuck.

    Again, it's not you personally Joshua44, I just think I can change the world.
    Adam
    GetWebSpace.com
    Personal Life Timed Out Due To Inactivity

  3. #3
    I didn't copy any of that, I swear
    I wrote all of it, and now it's working! *yay* (actually I figured it out before I read your post, byt thanks anyway!)
    www.jportalhome.com

  4. #4
    Join Date
    Oct 2001
    Posts
    307
    Hey, cool enough. Sorry, too many script kiddies harassing me this week.
    Adam
    GetWebSpace.com
    Personal Life Timed Out Due To Inactivity

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •