SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    The WYSISYG editor doesn't like PHP code

    I click on the php icon, then paste my php code. However, when I save new posts it shows my php code as a mess. What am I doing wrong?
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    SitePoint Guru bronze trophy TheRaptor's Avatar
    Join Date
    Jul 2011
    Location
    New York
    Posts
    710
    Mentioned
    40 Post(s)
    Tagged
    0 Thread(s)
    Are you speaking about the post editor on this forum?
    TheRaptor - Joe

  3. #3
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes.
    Convert your dollars into silver coins. www.convert2silver.com

  4. #4
    SitePoint Guru bronze trophy TheRaptor's Avatar
    Join Date
    Jul 2011
    Location
    New York
    Posts
    710
    Mentioned
    40 Post(s)
    Tagged
    0 Thread(s)
    After clicking the PHP button do you see [PHP] bbcode tags appear in the editor?

    Off Topic:

    I've moved your topic to the Forum Support and Feedback section as it is more applicable to this question.
    TheRaptor - Joe

  5. #5
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, I do. That is why I don't understand why the code looks scrambled after I click the post button.
    Convert your dollars into silver coins. www.convert2silver.com

  6. #6
    Galactic Overlord gold trophysilver trophybronze trophy
    HAWK's Avatar
    Join Date
    Aug 2003
    Location
    New Zealand
    Posts
    12,572
    Mentioned
    975 Post(s)
    Tagged
    14 Thread(s)
    Can you link me to an example please @busboy ; ?

    If you take this post of yours, you'll notice that you are using [code] tags rather than [php] tags. That could be the issue.

  7. #7
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,882
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by busboy View Post
    I click on the php icon, then paste my php code. However, when I save new posts it shows my php code as a mess. What am I doing wrong?
    Search your editor and see if there is a function to "change TABS to SPACES".
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  8. #8
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Does that mean that users on this website could be using different types of editors? That is really strange. I just click on the advanced button so that the PHP icon appears. Here is how it looks when I paste code in between those two tags:

    PHP Code:
                $sentAlerts++;                        $alerts++;                    $increaseAlerts "UPDATE searches SET alerts = $alerts, lastAlert = '$longDate' WHERE sID = $sID";                        mysql_query($increaseAlerts) OR die("<b>A fatal MySQL error occurred</b>.\n<br />Query: " $increaseAlerts "<br />\nError: (" mysql_errno() . ") " mysql_error());                                             $updateLastMatch "UPDATE users SET lastMatch = '$longDate' WHERE uID = '$uID'";                        mysql_query($updateLastMatch) OR die("<b>A fatal MySQL error occurred</b>.\n<br />Query: " $updateLastMatch "<br />\nError: (" mysql_errno() . ") " mysql_error());                                         if ($clicks 0) {                            $ctr $clicks/$alerts;                $percent round($ctr 100);                $showPercent "$percent%";                        } else {                            $percent "0";                $showPercent "-";            } 
    Convert your dollars into silver coins. www.convert2silver.com

  9. #9
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,882
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    Removed formatting and simplified in next post...
    Last edited by John_Betong; May 11, 2012 at 17:44. Reason: added two options to use this editor to wrap code
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  10. #10
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,882
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    Using this editor and the "Switch editor to WSIWYG Mode" THEN manually applying the PHP tags


    PHP Code:
        $sentAlerts++; 
        
    $alerts++; 
        
    $increaseAlerts    =    
        
    "
            UPDATE    searches 
            SET            alerts =    
    $alerts, lastAlert = '$longDate
            WHERE        sID    =    
    $sID
        "
    ;

        
    mysql_query$increaseAlerts 
        OR
        die(
                
    "<b>A    fatal    MySQL    error    occurred</b>.\n<br />Query:    "    
                
    .    $increaseAlerts
                
    .    "<br />\nError:    ("
                
    .        mysql_errno()    
                .    
    ") " 
                
    .    mysql_error()
                ); 
                
        
    $updateLastMatch 
        
    "
            UPDATE users SET lastMatch = '
    $longDate
            WHERE    uID    =    '
    $uID'
        "


        
    mysql_query($updateLastMatch)    
        OR
        die
        (
                
    "<b>A    fatal    MySQL    error    occurred</b>.\n<br/>Query: " 
            
    .    $updateLastMatch 
            
    .    "<br />\nError:    (" 
            
    .    mysql_errno()    
            .    
    ") " 
            
    .    mysql_error()
        ); 
            
        if (
    $clicks    >    0)
        {
            
    $ctr                    =    $clicks/$alerts
            
    $percent            =    round$ctr    *    100    );
            
    $showPercent    =    "$percent%";
        }    
        else
        {
            
    $percent "0";
            
    $showPercent "-";    
        } 

    Conclusion:
    It is not necessary to use my editors "TABS to SPACES" option but must use the WYSIWYG option and then to use the PHP tags.
    Last edited by John_Betong; May 11, 2012 at 17:41. Reason: speeling not my fortay
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  11. #11
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
        if ($formContact != $_SESSION[contact]) {        $madeChanges  "Yes";    $changedData .= "<li><h6>Contact From Other Users:</h6>$_SESSION[contact] changed to $formContact</li>";    }                if ($formSendMatches != $_SESSION[sendMatches]) {        $madeChanges  "Yes";    $changedData .= "<li><h6>Receive Testimonial Match Emails:</h6>$_SESSION[sendMatches] changed to $formSendMatches</li>";    } 
    Convert your dollars into silver coins. www.convert2silver.com

  12. #12
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    1. I clicked on the button to "Go Advanced".
    2. Then I clicked on the button for "Switch editor to WSIWYG Mode".
    3. Then I clicked the button on the menu bar for PHP code snipet.
    4. I copied some of my source code from CODA on my iMac
    5. Then I pasted it between the PHP tags
    6. Clicked save

    The PHP code looks like a mess. What am I doing wrong?
    Convert your dollars into silver coins. www.convert2silver.com

  13. #13
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Silly question, what's your OS and what editor are you copying from? I've got the sneaking suspicion the problem lies somewhere between your browser and the editor...

    "Reply with quote" usually shows you exactly what's been posted, and there's no carriage returns in your post -- so I would assume that you're either losing them during copy to the clipboard, or when pasting. If you're using an editor that doesn't preserve linefeeds. I've seen this when people use 'textedit' and on a handful of *nix editors. The Linux world in particular can be a nightmare given the variety of different clipboard formats applications recognize (or don't).

    Though really, my advice is forget the stupid editor -- the forums are faster and more useful if you turn off the MEGABYTE of .js garbage anyways.

    Q: if you type in the PHP bbcode tag by hand, and then post into the editor box your code -- does it have line-feeds in the editor box? If it does NOT show up with linefeeds in the editor window, the problem is NOT these forums, it's somewhere between your browser and your editor.

  14. #14
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Testing...123

    PHP Code:

    // Pasted directly from CODA on a Mac:

    $pageWelcome .= "<ul class='star'>";
    if (
    $_SESSION[sponsorPosts] > 0)  {
        
    $pageWelcome .= "<li><a href = 'aromatherapy/7/$sponsorID'>Read my personal experiences</a></li>";}

    // Some code manually typed in:

    $myTest "Hello";

    if (
    $myTest == "Hello") {
        
    $pageWelcome .= "<li><a href='https://www2.example.com/signup/custType.faces?sponsorid=$sponsorMemberNumber&enrollerid=$sponsorMemberNumber'>Signup with as a customer or distributor</a></li>";

    Convert your dollars into silver coins. www.convert2silver.com

  15. #15
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It looks like it's better for me to manually add the PHP tags. It still doesn't preserve the same indenting that I used in CODA, but it certainly looks better than it did before.

    Thanks.
    Convert your dollars into silver coins. www.convert2silver.com

  16. #16
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,882
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by busboy View Post
    It looks like it's better for me to manually add the PHP tags. It still doesn't preserve the same indenting that I used in CODA, but it certainly looks better than it did before.

    Thanks.
    http://www.sitepoint.com/forums/show...=1#post5117725


    Using this editor and the "Switch editor to WSIWYG Mode" THEN manually applying the PHP tags
    My Conclusion was not precise - it is necessary to manually include the PHP tags

    Conclusion:
    It is not necessary to use my editors "TABS to SPACES" option but must use the WYSIWYG option and then to use the PHP tags.
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  17. #17
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    What I do is first use the tags around my PHP. Then I preview; usually it displays with the tabs/spaces I have in my code. I then manually change the tags to . Before coming to this process I tried:

    • Changing my php editor in Eclipse to use spaces not tabs... this did not help
    • Paste my code into a text editor (gedit) and ask it to Paste using no formatting... this did not help
    • Manually adding [PHP] tags from the start... this did not help


    I think that the javascript that is used in the editor does not parse spaces, \n\r, \r. When previewing it preserves and/or converts the code spaces, tabs ect. Then wrapping these converted spaces with the tag [PHP][HTML] ... that your want. Interestingly this does not happen if I have used Code Highlighting for PHP.

    I do use Linux and Eclipse (A Java based editor), so I don't expect everything to work great on products that have mainly been designed with Windows and maybe Mac.

    Regards,
    Steve
    ictus==""


Bookmarks

Posting Permissions

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