Jump to content

Recommended Posts

You can do it this way:

 

<?php

print<<<HERE

    All your HTML/text goes here. All your HTML/text goes here. All your HTML/text goes here.
    All your HTML/text goes here. All your HTML/text goes here. All your HTML/text goes here.
    All your HTML/text goes here. All your HTML/text goes here. All your HTML/text goes here.
    All your HTML/text goes here. All your HTML/text goes here. All your HTML/text goes here.

HERE;

?>

Ahh, thanks so much for all this information guys.  I think I may need some more help with this though.  Basically I took some code I found in a tutorial online for password protecting some of my content.  The password code has an echo line where the original author states to insert your content.  Well, my content contains additional php coding and that's causing some problems.  This is the page in question:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

    <title>ACDC Membership Database</title>
    <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Language" content="en-us">
    <meta name="Robots" content="index,follow">
    <style type="text/css">@import "style.css";</style>

</head>

<body>

<?php
include("config.php");
$cookuser = $_COOKIE["cookuser"];
$cookpass = $_COOKIE["cookpass"];
$adminpass = md5($adminpass);
if($cookuser && $cookpass) {
    if(($cookuser == $adminuser) && ($cookpass == $adminpass)){
    echo("You have successfully logged in!");
    //Paste protected content here:


echo "<div id=\"mdb_top\">";
echo "<div id=\"mdb_nav\" style=\"padding: 2px;\" align=\"center\"><a href=\"index.php\">MDB Home</a> | <a href=\"add.php\">Add Nation</a> | <a href=\"search.php\">Find Nation</a></div>";
echo "</div>";
     
echo "      <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" width=\"700\">";
echo "       <tr>";
echo "        <td width=\"700\" colspan=\"6\" bgcolor=\"#414B3F\">";
echo "        <h3>ACDC Membership Database</h3>";
echo "        </td>";
echo "       </tr>";
echo "       <tr>";
echo "      	<td width=\"100\" bgcolor=\"#768872\"  valign=\"top\" align=\"left\">";
echo "      	 <b>ID</b>";
echo "      	</td>";
echo "      	<td width=\"130\" bgcolor=\"#768872\" valign=\"top\" align=\"left\">";
echo "      	 <b>Nation</b>";
echo "      	</td>";
echo "      	<td width=\"130\" bgcolor=\"#768872\" valign=\"top\" align=\"left\">";
echo "      	 <b>Ruler</b>";
echo "      	</td>";
echo "      	<td width=\"120\" bgcolor=\"#768872\" valign=\"top\" align=\"left\">";
echo "      	 <b>ACDC User</b>";
echo "      	</td>";
echo "     	<td width=\"120\" bgcolor=\"#768872\" valign=\"top\" align=\"left\">";
echo "      	 <b>Position</b>";
echo "      	</td>";
echo "      	<td width=\"100\" bgcolor=\"#768872\" valign=\"top\" align=\"left\">";
echo "      	 <b>Commands</b>";
echo "      	</td>";
echo "     </tr>";

        <?
        //connect to mysql
        //change user and password to your mySQL name and password
        mysql_connect("localhost","username","password");
        	
        //select which database you want to edit
        mysql_select_db("database"); 
        
        //select the table
        $result = mysql_query("select * from members limit 30");
        
        //grab all the content
        while($r=mysql_fetch_array($result))
        {

           $id=$r["id"];
           $cnnation=$r["cnnation"];
           $cnruler=$r["cnruler"];
           $acdcuser=$r["acdcuser"];
           $positions=$r["positions"];
           $nationlink=$r["nationlink"];
           
           //display the row
           echo "<tr>";
           echo "<td width=\"100\" bgcolor=\"#9DAB9B\"  valign=\"top\" align=\"left\">";
           echo "$id";
           echo "</td>";
           echo "<td width=\"130\" bgcolor=\"#9DAB9B\"  valign=\"top\" align=\"left\">";
           echo "<a href=\"$nationlink\" target=\"_blank\">$cnnation</a>";
           echo "</td>";
           echo "<td width=\"130\" bgcolor=\"#9DAB9B\" valign=\"top\" align=\"left\">";
           echo "$cnruler";
           echo "</td>";
           echo "<td width=\"120\" bgcolor=\"#9DAB9B\" valign=\"top\" align=\"left\">";
           echo "$acdcuser";
           echo "</td>";
           echo "<td width=\"120\" bgcolor=\"#9DAB9B\" valign=\"top\" align=\"left\">";
           echo "$positions";
           echo "</td>";
           echo "<td width=\"100\" bgcolor=\"#9DAB9B\" valign=\"top\" align=\"left\">";
           echo "<a href='edit.php?cmd=edit&id=$id'>Edit</a> | <a href='delete.php?cmd=delete&id=$id'>Delete</a>";
           echo "</td>";
           echo "</tr>";
        }

        ?>

echo "     </table>";

     
    }
    else{
    echo($incorrect_error_message);
    }
}
else{
echo($not_logged_in_message_error_message);
}
?>

</body>

 

The <? line just before //connect to mysql is the one kicking out an error.  I know I should really get some books and php and dig into them, but I kinda need to get this done soon.  This is my intro to php/mysql.  Thanks so much for all the help.

You need to make sure any echo statement is between PHP tags.

 

<?php

 

echo 'foo';

echo 'bar';

 

?>

 

You've currently got opening and closing PHP tags all over the place with no rhyme or reason.

 

Here are two different approaches.

 

<?php

// code
// code
// code

$var = "Lorem Ipsum is simply dummy text of the printing and typesetting 
industry. Lorem Ipsum has been the industry's standard dummy text ever 
since the 1500s, when an unknown printer took a galley of type and 
scrambled it to make a type specimen book. It has survived not only five 
centuries, but also the leap into electronic typesetting, remaining essentially 
unchanged. It was popularised in the 1960s with the release of Letraset sheets 
containing Lorem Ipsum passages, and more recently with desktop publishing 
software like Aldus PageMaker including versions of Lorem Ipsum. ";

echo $var;

// more code

?>

 

OR

 

<?php

// code
// code
// code

?>
Lorem Ipsum is simply dummy text of the printing and typesetting 
industry. Lorem Ipsum has been the industry's standard dummy text ever 
since the 1500s, when an unknown printer took a galley of type and 
scrambled it to make a type specimen book. It has survived not only five 
centuries, but also the leap into electronic typesetting, remaining essentially 
unchanged. It was popularised in the 1960s with the release of Letraset sheets 
containing Lorem Ipsum passages, and more recently with desktop publishing 
software like Aldus PageMaker including versions of Lorem Ipsum. 
<?php

// more code

?>

 

I prefer the second approach.  Do you see how I exited PHP mode and simply wrote out everything instead of using the echo command?

Thank you guys so much!  Vomit, I'm using this code to enable a passwd protected page:

 

<?php
include("config.php");
$cookuser = $_COOKIE["cookuser"];
$cookpass = $_COOKIE["cookpass"];
$adminpass = md5($adminpass);
if($cookuser && $cookpass) {
    if(($cookuser == $adminuser) && ($cookpass == $adminpass)){
    echo("You have successfully logged in!");

}
else{
echo($incorrect_error_message);
}
}
else{
echo($not_logged_in_message_error_message);
}
?>


 

See this line:    echo("You have successfully logged in!");

 

I need to replace that with about 100 lines of html that also includes more php code.  So I can't figure out how to get around that and use your suggestion.  It seems like I _have_ to embed more php code in there.  I'm terribly sorry for my ignorance on this, I'm probably making some of you dumber for having read this.

 

:)

If you need to print a large chunk of HTML that has bits of PHP in it, use the example I gave you in my first post.

 

Hey poco, I tried that but I kept getting a T_ENCAPSED_AND_WHITESPACE error, even after I removed all the blank spaces.  Your method is greatly appreciated though and I will likely refer to this thread again later.  Thanks!

It's probably because you don't have the last line at the very left of your text editor.

 

<?php

   print<<<HERE
       blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
       blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
       blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 

HERE; //<---This line has to be all the way to the left

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.