TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Starting with php in my html page (http://www.talkphp.com/absolute-beginners/1883-starting-php-my-html-page.html)

Shinoken 01-07-2008 03:03 PM

Starting with php in my html page
 
Hello, I made the following page (plain html, no css or anything):

html4strict Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <title>.:: Ragnarok Society :: Home ::.</title>
  <meta content="Evrsoft First Page" name="GENERATOR">
</head>

<body bgcolor="#000000">

    echo "MySQL Working"; ?>
 <div align="center">
   <table style="WIDTH: 728px; font-face: Verdana" bordercolor="#FF0000" align="center" border="1">
    <tbody>
      <tr style="HEIGHT: 90px">
        <td colspan="5">
          <div align="center">
            <font face="verdana"><img height="90" alt="" src="http://www.talkphp.com/images/Banner3.png" width="728" border="0"></font>
          </div>
        </td>
      </tr>

      <tr align="middle" bgcolor="red">
        <td width="20%">
          <center>
            <font face="Verdana"><b>Home</b></font>
          </center>
        </td>

        <td width="20%">
          <center>
            <font face="Verdana"><b>Information</b></font>
          </center>
        </td>

        <td width="20%">
          <center>
            <font face="Verdana"><b>Forum</b></font>
          </center>
        </td>

        <td width="20%">
          <center>
            <font face="Verdana"><b>Downloads</b></font>
          </center>
        </td>

        <td width="20%">
          <center>
            <font face="Verdana"><b>Staff</b></font>
          </center>
        </td>
      </tr>

      <tr>
        <td valign="top" align="middle" width="20%"><font face="Verdana"><font color="red" size="-1">Login Server:</font><br>
        <font color="green" size="-1"><b>Online</b></font><br>
        <font color="red" size="-1">Char Server:</font><br>
        <font color="green" size="-1"><b>Online</b></font><br>
        <font color="red" size="-1">Map Server:</font><br>
        <font color="green" size="-1"><b>Online</b></font><br>
        <font color="red" size="-1">Users Online:</font> <font color="green" size="-1"><b>4</b></font><br></font></td>

        <td width="60%" colspan="3">
          <div id="cboxdiv" align="center">
            <iframe id="cboxmain" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" name="cboxmain" marginwidth=
            "2" marginheight="2" src="http://www5.cbox.ws/box/?boxid=26440&amp;boxtag=eh478a&amp;sec=main" frameborder="0" width="100%" height="100%" allowtransparency="">
</iframe><br>
            <iframe id="cboxform" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: 0px; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" name="cboxform" marginwidth="2"
            marginheight="2" src="http://www5.cbox.ws/box/?boxid=26440&amp;boxtag=eh478a&amp;sec=form" frameborder="0" width="160" scrolling="no" height="75" allowtransparency="">
</iframe>
          </div>
        </td>

        <td valign="top" align="middle" width="20%" height="50%">
          <table bordercolor="red" height="100%" width="100%" border="1">
            <tbody>
              <tr>
                <td>
                  <p><font face="Verdana" color="#FF0000">ID:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="public"><br>
                  <font color="#FF0000">Password:</font> <input type="public"></p>

                  <div align="left">
                    <font face="Verdana" color="blue" size="-2"><u>Sign Up!</u></font>
                  </div>

                  <div align="right">
                    <button><font face="Verdana" size="-1">Log In!</font></button>
                  </div>
                </td>
              </tr>

              <tr>
                <td>
                  <center>
                    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
                      <input type="hidden" value="_s-xclick" name="cmd"> <input type="image" alt="Make payments with PayPal - it's fast, free and secure!" src=
                      "https://www.paypal.com/en_US/i/btn/x-click-but04.gif" border="0" name="submit">
<img height="1" alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" border="0">
                      <input type="hidden" value=
                      "-----BEGIN PKCS7-----MIIHTwYJKoZIhvcNAQcEoIIHQDCCBzwCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKE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DEWBBQTNJCXX5XErLxDEiZQkoEEo4fmYzANBgkqhkiG9w0BAQEFAASBgJBirCbrZBihLS78ywnsRXuzBXzi4L7z9O3UcgcJgA4vo61K+dR0jqFrIVDzMd1TeOLQ60zKb0S/BFppDBGfejXvOAwzfs2fatIeAlyTGm9UcMY3y71w4+q5BrPoO3ynFSYkv+4isugoM3mHDL8sReTA9dXsxhb3t3U7ZM9WzyAe-----END PKCS7-----
  "

                      name="encrypted">

                    </form><font face="Verdana" color="#FF0000" size="-1">Billing Date: 02/02/2008<br>
                    Donation Status: $0/$27</font>
                  </center>
                </td>
              </tr>
            </tbody>
          </table>
        </td>
      </tr>

      <tr bgcolor="red">
        <td colspan="6">
          <center>
            <font face="Verdana">Latest News</font>
          </center>
        </td>
      </tr>

      <tr height="100%">
        <td colspan="6">
          <p><font face="Verdana" color="#FF0000">Here is the news displayed</font></p>

          <p>&nbsp;</p>

          <p>&nbsp;</p>

          <p>&nbsp;</p>

          <p>&nbsp;</p>

          <p>&nbsp;</p>

          <p>&nbsp;</p>

          <p>&nbsp;</p>

          <p>&nbsp;</p>

          <p>&nbsp;</p>
        </td>
      </tr>
    </tbody>
  </table>
</body>
</html>

Now I need to let it connect to an mysql server to have an working login form and the server status working.

First I'd like to do an MySQL check (if the script works, by letting is connect under an wrong login)

putting this under <body>:
<?php $con = mysql_connect("localhost","die","nuthing") or die(mysql_error()); ?>

Saved, tested and nothing.. just the html page without the die message.

Anyone knows why it isn't working? (I have WAMP installed, PHP, Apache + MySQL, also tried it with just apache & php, no result either)

Thanks in Advance!

Your Sincerely,
Shinoken

xenon 01-07-2008 05:21 PM

The page needs to have a .php extension, so the webserver knows that the file is a php script and parse it accordingly.

Shinoken 01-07-2008 05:29 PM

Did that, still the same, now i've added the mysql connect above the <html> tag, and still no difference, but whhen I make an new file in notepad, put the code there, and put <html><body>test if mysql works</body></html> under it, then run mysql.php, you'll see that it worked (also added an echo "MySQL Connected" now, and in the mysql.php it worked but in the real file it didn't work.

vujsa 01-07-2008 06:53 PM

Well, this seems to be a problem with your PHP script and not your HTML...

To test, insert the following anywhere in your HTML document:
<?php echo "PHP TEST HERE!"; ?>

If this doesn't display on your webpage, then there is some problem with the server recognizing the .php extension.

Otherwise, this is a PHP code error and you'll need to post that code here for us to see what is wrong with it.

vujsa

Wildhoney 01-08-2008 02:20 PM

1 Attachment(s)
...Alternatively download the following file, drop it into your web root and run it in a web-browser.

sketchMedia 01-08-2008 02:34 PM

first off, unless you configure apache differently, nothing but .php files will be passed to the php interperter, hence y its just farting it back to browser without running php.

i know this might sound daft, but you have remembered to clear you cache and are making sure that you have .php appended to the filename, because to me it sounds like php isnt getting it, it could also be an apache problem, but because you havnt configured it yourself, i find it unlikely.

if you want to pass a .html file to php and make apache treat it as a php file, add following to your httpd.conf or in a .htaccess:

Code:

AddType application/x-httpd-php .html


All times are GMT. The time now is 02:27 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0