Jump to content
MakeWebGames

Recommended Posts

Posted

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...

Posted
<?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 ++

Posted

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 ;)

Posted

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%>";}?>
Posted
<?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

Posted

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.

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...