CJ - Twitch Posted February 17, 2010 Posted February 17, 2010 Why is it that every time I paste PHP code it gets messed up.. Example: <?PHPinclude(DIRNAME(__FILE__) . '/globals.php');print "<font size='4' face='Arial, Helvetica, sans-serif'>Your Attack Logs</font> <hr width='75%'> "; switch($_GET['step']){case 'ayw': ayw(); break;case 'ayl': ayl(); break;default; index(); break;}function index(){print "So you want to see you attack logs huh? Please choose a section. ";Print "• [url='pal.php?step=ayw']Attacks you've won[/url]. • [url='pal.php?step=ayl']Attacks you've lost[/url].";print " <hr width=75%>> <a href=index.php>Home</a><hr width=75%>";}function ayw(){global $db,$userid;$atks=$db->query("SELECT a.*,u1.username as attackern, u2.username as attackedn FROM attacklogs a LEFT JOIN users u1 ON a.attacker=u1.userid LEFT JOIN users u2 ON a.attacked=u2.userid WHERE (u1.userid=$userid) AND result='won' ORDER BY time DESC LIMIT 100");print "The last 100 players you have killed. <center><table width=75% cellspacing=1></center><tr bgcolor=#999999> <th>Time</th><th>Attacked</th></tr>";while($r=$db->fetch_row($atks)){$bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf";$d=date('F j, Y, g:i:s a',$r['time']);print "<tr bgcolor=$bgcolor><td><center>$d</td><td>[url='viewuser.php?u={$r[']<center>{$r['attackedn']}[/url]</td></tr>";}print "</table>";print " <hr width=75%>> <a href=pal.php>Back</a><hr width=75%>";}function ayl(){global $db,$userid;$atks=$db->query("SELECT a.*,u1.username as attackern, u2.username as attackedn FROM attacklogs a LEFT JOIN users u1 ON a.attacker=u1.userid LEFT JOIN users u2 ON a.attacked=u2.userid WHERE (u2.userid=$userid) AND result='won' ORDER BY time DESC LIMIT 100");print "The last 100 players that killed you. <center><table width=75% cellspacing=1></center><tr bgcolor=#999999><th>Time</th><th>Attacker</th></tr>";while($r=$db->fetch_row($atks)){$bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf";$d=date('F j, Y, g:i:s a',$r['time']);print "<tr bgcolor=$bgcolor><td><center>$d</td><td>[url='viewuser.php?u={$r[']<center>{$r['attackern']}[/url] </td></tr>";}print "</table>";print " <hr width=75%>> <a href=pal.php>Back</a><hr width=75%>";}?> That is from notepad... Quote
Djkanna Posted February 17, 2010 Posted February 17, 2010 <?php /* Some random connection */ $con = mysql_pconnect (host, user, pass) or trigger_error (mysql_error(), E_USER_ERROR); mysql_select_db (db, $con) or trigger_error (mysql_error(), E_USER_ERROR); /* Some random if else statement */ if ($donkey !== $kingKong) { echo 'We have a serious problem here'; } else { echo 'WTF?!?! A Donkey and King Kong are you mad?!?'; } /* Some random switch */ $_GET['cases'] = isset($_GET['cases']); switch($_GET['cases']) { case 'one' : echo 'one'; break; case 'two' : echo 'two'; break; case 'andsoon' : echo 'I\'m sure you get the picture now'; default : echo 'cases'; break; } /* Form */ if (!isset($_POST['email'])) { ?> <form action="file.php" method="post"> <span>Email:</span><input type="text" name="email" /> <input type="submit" value="submit" /> </form><?php } else { if (!filter_var ($_POST['email'], FILTER_VALIDATE_EMAIL) ) { echo 'Oh nuts I wanted a real one to feed my Google Bots -.-'; } else { echo 'There you go little bottys!'; } echo 'Your Email: '.$_POST['email']; } /* Just testing the PHP tags on MakeWebGames...... */ ?> That's from NotePad ++ Quote
CJ - Twitch Posted February 17, 2010 Author Posted February 17, 2010 So I should use notepade ++? Quote
Djkanna Posted February 17, 2010 Posted February 17, 2010 Well I shouldn't think that the programme you use is a problem but then again depends on the way it's laid out in Notepad. Or the PHP tags on here screw it up I have no clue whatsoever you'll have to see if anyone else has had this problem either using Notepad or a different app ;) Quote
CJ - Twitch Posted February 17, 2010 Author Posted February 17, 2010 Ill test it with the code tags. :) <?PHPinclude(DIRNAME(__FILE__) . '/globals.php'); print "<font size='4' face='Arial, Helvetica, sans-serif'>Your Attack Logs</font> <hr width='75%'> "; switch($_GET['step']){case 'ayw': ayw(); break;case 'ayl': ayl(); break;default; index(); break;}function index(){print "So you want to see you attack logs huh? Please choose a section. ";Print "• [url='pal.php?step=ayw']Attacks you've won[/url]. • [url='pal.php?step=ayl']Attacks you've lost[/url].";print " <hr width=75%>> <a href=index.php>Home</a><hr width=75%>";}function ayw(){global $db,$userid;$atks=$db->query("SELECT a.*,u1.username as attackern, u2.username as attackedn FROM attacklogs a LEFT JOIN users u1 ON a.attacker=u1.userid LEFT JOIN users u2 ON a.attacked=u2.userid WHERE (u1.userid=$userid) AND result='won' ORDER BY time DESC LIMIT 100");print "The last 100 players you have killed. <center><table width=75% cellspacing=1></center><tr bgcolor=#999999> <th>Time</th><th>Attacked</th></tr>";while($r=$db->fetch_row($atks)){$bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf";$d=date('F j, Y, g:i:s a',$r['time']);print "<tr bgcolor=$bgcolor><td><center>$d</td><td>[url='viewuser.php?u={$r[']<center>{$r['attackedn']}[/url]</td></tr>";}print "</table>";print " <hr width=75%>> <a href=pal.php>Back</a><hr width=75%>";}function ayl(){global $db,$userid;$atks=$db->query("SELECT a.*,u1.username as attackern, u2.username as attackedn FROM attacklogs a LEFT JOIN users u1 ON a.attacker=u1.userid LEFT JOIN users u2 ON a.attacked=u2.userid WHERE (u2.userid=$userid) AND result='won' ORDER BY time DESC LIMIT 100");print "The last 100 players that killed you. <center><table width=75% cellspacing=1></center><tr bgcolor=#999999><th>Time</th><th>Attacker</th></tr>";while($r=$db->fetch_row($atks)){$bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf";$d=date('F j, Y, g:i:s a',$r['time']);print "<tr bgcolor=$bgcolor><td><center>$d</td><td>[url='viewuser.php?u={$r[']<center>{$r['attackern']}[/url] </td></tr>";}print "</table>";print " <hr width=75%>> <a href=pal.php>Back</a><hr width=75%>";}?> Quote
Magictallguy Posted February 17, 2010 Posted February 17, 2010 <?php include(DIRNAME(__FILE__) . '/globals.php'); echo "<font size='4' face='Arial, Helvetica, sans-serif'>Your Attack Logs</font> <hr width='75%'> "; switch($_GET['step']) { case 'ayw': ayw(); break; case 'ayl': ayl(); break; default; index(); break; } function index() { echo "So you want to see you attack logs huh? Please choose a section. "; echo "• [url='pal.php?step=ayw']Attacks you've won[/url]. • [url='pal.php?step=ayl']Attacks you've lost[/url]."; echo " <hr width='75%'>> [url='index.php']Home[/url]<hr width='75%'>"; } function ayw() { global $db,$userid; $atks = $db->query( "SELECT a.*, u1.username AS attackern, u2.username AS attackedn " . "FROM attacklogs a " . "LEFT JOIN users u1 ON (a.attacker = u1.userid) " . "LEFT JOIN users u2 ON (a.attacked = u2.userid) " . "WHERE ((u1.userid = $userid) AND (result = 'won')) " . "ORDER BY time DESC LIMIT 100"); echo "The last 100 players you have killed. <table width='75%' cellspacing='1' class='table' style='text-align:center;'> <tr style='background-color:#999;'> <th>Time</th> <th>Attacked</th> </tr>"; while($r = $db->fetch_row($atks)) { $bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf"; $d = date('F j, Y, g:i:s a', $r['time']); echo "<tr style='background-color:$bgcolor;'> <td>$d</td> <td>[url='viewuser.php?u={$r[']{$r['attackedn']}[/url]</td> </tr>"; } echo "</table>"; echo " <hr width='75%'>> [url='pal.php']Back[/url]<hr width='75%'>"; } function ayl() { global $db, $userid; $atks = $db->query( "SELECT a.*, u1.username AS attackern, u2.username AS attackedn " . "FROM attacklogs a " . "LEFT JOIN users u1 ON (a.attacker = u1.userid) " . "LEFT JOIN users u2 ON (a.attacked = u2.userid) " . "WHERE ((u2.userid = $userid) AND (result = 'won')) " . "ORDER BY time DESC LIMIT 100"); echo "The last 100 players that killed you. <table width='75%' cellspacing='1' class='table' style='text-align:center;'> <tr style='background-color:#999;'> <th>Time</th> <th>Attacker</th> </tr>"; while($r = $db->fetch_row($atks)) { $bgcolor = ($bgcolor == "#dfdfdf") ? "#cccccc" : "#dfdfdf"; $d = date('F j, Y, g:i:s a', $r['time']); echo "<tr style='background-color:$bgcolor;'> <td>$d</td> <td>[url='viewuser.php?u={$r[']{$r['attackern']}[/url]</td> </tr>"; } echo "</table>"; echo " <hr width='75%'>> [url='pal.php']Back[/url]<hr width='75%'>"; } $h->endpage(); ?> Works fine for me Quote
Zeggy Posted February 17, 2010 Posted February 17, 2010 Notepad doesn't treat unix/mac new lines correctly. Use a real text editor or IDE! Notepad++, crimson editor, textpad, textmate are all decent gui text editors. Eclipse, zend studio, komodo, phped are all good PHP IDEs. vim or emacs for a more advanced code editor. nano for a simple notepad-like editor. Quote
Lithium Posted February 18, 2010 Posted February 18, 2010 Most likely you need to enable "wordwrap" on notepad, though that might notbe the problem as well Quote
DigitalGerm Posted April 8, 2010 Posted April 8, 2010 I like pspad :P cuz you don't need plug-ins Quote
Djkanna Posted April 9, 2010 Posted April 9, 2010 I like pspad :P cuz you don't need plug-ins Interesting.. More info? Quote
DigitalGerm Posted April 9, 2010 Posted April 9, 2010 http://www.pspad.com/en/screenshot.htm here you go. a plus to loading and online edit. Free for home / commercial use Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.