Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Scripts And Html
khaibar
post Jun 19 2007, 05:53 PM
Post #1


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 8
Joined: 19-June 07
Member No.: 22,771



Hey smile.gif,


In the note pad, I put the proper code for php

<?php


?>

and save the file as name.php


But i can't put that file in html. This is a big problem since Iam trying to make an online text based game. Whats the code to put a

script inside a web page. And do i need any special software for it?

If so where can i download it?

Thanks for reading biggrin.gif.
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jun 19 2007, 10:11 PM
Post #2


Super Member
Group Icon

Group: [HOSTED]
Posts: 713
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



QUOTE(khaibar @ Jun 19 2007, 12:53 PM) *
Hey smile.gif,
In the note pad, I put the proper code for php

<?php
?>

and save the file as name.php
But i can't put that file in html. This is a big problem since Iam trying to make an online text based game. Whats the code to put a

script inside a web page. And do i need any special software for it?

If so where can i download it?

Thanks for reading biggrin.gif.

You can't do this, instead what you do is to put the html code inside the php file, then in your browser when you run the php file you vie the output generated by. For example:
CODE
<?php
// simple example
?>
<html>
<head>
<?php
echo "<title>Simple Example</title>\n";
?>
</head>
<?php
echo "<body style=\"margin:0 auto;color:#900;\">\n" .
       "<p>Simple Example<br />Other texts....</p>\n";
?>
</body>
</html>

Best regards,
Go to the top of the page
 
+Quote Post
FirefoxRocks
post Jun 20 2007, 04:23 AM
Post #3


Super Member
Group Icon

Group: [HOSTED]
Posts: 589
Joined: 12-July 06
From: Ontario, Canada
Member No.: 14,464



Yes, PHP is designed to be integrated within HTML documents, with the file having a .php extension.
So therefore, your code could look like this:
CODE
<?php
// Some scripts can even come before the HTML part of the document, like session scripts.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My page with PHP scripts</title>
</head>
<body>
<?php //Some scripts. ?>
<p>A paragraph in HTML</p>
<?php //Some more scripts. ?>
<p>Well, you get the idea.</p>
</body>
</html>


So you don't make separate files for the PHP code, you just add them in the page.
Go to the top of the page
 
+Quote Post
Habble
post Jun 20 2007, 06:06 AM
Post #4


Premium Member
Group Icon

Group: [HOSTED]
Posts: 255
Joined: 17-June 07
From: Tasmania
Member No.: 22,699



Also, on most servers, you cannot put php scripts in .htm/.html files, although that can be changed.
If you wish, you can make one .php file, and include other .php files in it, if you have a lot. E.g.
CODE
<html>
<head>
<title>Test Page</title>
</head>
<body>
<p>There's some included scripts below this!</p>
<?php include("[b]script.php[/b]"); ?>
</body>
</html>

Replacing script.php with the filename of your .php file.
Go to the top of the page
 
+Quote Post
khaibar
post Jun 20 2007, 12:14 PM
Post #5


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 8
Joined: 19-June 07
Member No.: 22,771



Thanks a lot guys smile.gif

<quote>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">


</quote>

Is that necessary O_o?
Go to the top of the page
 
+Quote Post
MediYama
post Jun 20 2007, 06:14 PM
Post #6


Member - Active Contributor
Group Icon

Group: Members
Posts: 93
Joined: 11-June 07
Member No.: 22,564



I would like to learn PHP to use it for my website, make it look fancy. But it seems to be really hard for me. Maybe I need to learn HTML a bit better... Would make a difference heh.
Go to the top of the page
 
+Quote Post
lonelym
post Jun 21 2007, 10:53 AM
Post #7


Member - Active Contributor
Group Icon

Group: Members
Posts: 91
Joined: 18-May 07
Member No.: 22,008



Maybe your server/host doesn't allow the <?php ?> ending. I'm not sure, but I remember being taught that it is in one of the .INI files of PHP.
Go to the top of the page
 
+Quote Post
FirefoxRocks
post Jun 21 2007, 12:55 PM
Post #8


Super Member
Group Icon

Group: [HOSTED]
Posts: 589
Joined: 12-July 06
From: Ontario, Canada
Member No.: 14,464



QUOTE(khaibar @ Jun 20 2007, 07:14 AM) *
Thanks a lot guys smile.gif

<quote>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
</quote>

Is that necessary O_o?


That is necessary for every HTML document that you have. the xml:lang and lang things in the <html> element just declares the document to be English, so those are optional. However, the simplest format are either:
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

or stricter....
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

It is part of the HTML/XHTML standards and absolutely cannot be ignored, PHP or not.

QUOTE(MediYama @ Jun 20 2007, 01:14 PM) *
I would like to learn PHP to use it for my website, make it look fancy. But it seems to be really hard for me. Maybe I need to learn HTML a bit better... Would make a difference heh.

Yes, I recommend having an average knowledge of XHTML before integrating PHP. Seems a lot easier tongue.gif
QUOTE(lonelym @ Jun 21 2007, 05:53 AM) *
Maybe your server/host doesn't allow the <?php ?> ending. I'm not sure, but I remember being taught that it is in one of the .INI files of PHP.

Astahost's servers are PHP and MySQL compatible. Unless you are on a non-PHP host, you should be able to execute PHP commands successfully.
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jun 22 2007, 04:08 AM
Post #9


Super Member
Group Icon

Group: [HOSTED]
Posts: 713
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



QUOTE(lonelym @ Jun 21 2007, 05:53 AM) *
Maybe your server/host doesn't allow the <?php ?> ending. I'm not sure, but I remember being taught that it is in one of the .INI files of PHP.

No, it is not a configuration variable of the php.ini file, the configuration variable that you can set is short_open_tag and the suggested setting of this variable is to always set this to Off and in your php files always use <?php.

if you turn off this variable you cant be able to use the short tag <? and if your turn On you can be able to use both, <? and <?php.

Best regards,
Go to the top of the page
 
+Quote Post
SilverFox
post Jun 22 2007, 04:49 AM
Post #10


Premium Member
Group Icon

Group: Members
Posts: 206
Joined: 26-February 07
From: Texas
Member No.: 20,598



I own an online text based game. Good luck, I hope it works.

Download WAMP5 (google it to find it) and dev it locally I recommend for one. Using this you can build your project on your local PC, which is faster and more secure. It comes with SQL, Apache, PHP5 and PHPmyadmin and runs from your taskbar.

You do not need a doc type.
Simply echo PHHP.

<?php

echo "<html><head>..etc";
?>
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Basic Tips and Tricks in HTML(15)
  2. Embedding XML into HTML(2)
  3. Force Object To Load Last(2)
  4. Free Shoutbox? HTML, Flash or PHP Code(24)
  5. Where Can I Learn Advanced Html ?(11)
  6. Where Can I Learn Html Codes ?(8)
  7. Here Are Some Html Tutorial Sites(1)
  8. Get Input From Html/txt File?(2)
  9. How Can You Spice Up Your Basic HTML Site ? Beginner Needs Help(9)
  10. HTML Editor(23)
  11. Need Help With The HTML HR Tag(5)
  12. Two Cool Web-Design Scripts(1)
  13. HTML: Seems Like A Simple Problem, But I'm Baffled!(4)
  14. Where To Find A WML To HTML Converter ?(2)
  15. A First Peep Into Html(5)
  1. Home Videos(4)
  2. Bulletproof HTML: 37 Steps To Perfect Markup(4)
  3. Quick Tips On Html And Css(11)
  4. Firefox Inventing Its Own Html?(9)
  5. Stretching My Site Vertically(6)
  6. Html Stats(3)
  7. About Html(15)
  8. Html Table Issue.(18)
  9. Html Emails How?(12)
  10. Are There Imageless, Xml Compatable Css Corners Scripts?(3)
  11. Sitepoint's Css And Html Reference Sites(2)
  12. Yaml - (x)html/css Framework(2)
  13. Style P And H? Html Tags(1)


 



- Lo-Fi Version Time is now: 7th July 2008 - 12:24 AM