#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Html read php variables


    I make a simple temrerature.php file into my webserver with $temp="25"; simple variable.How i can display this variable into my intex.html file?I try this
    Code:
    <td><input type="text" size="4" value="<?temperature.php echo $temp; ?>"/></td>
    but no work....My site support php.
  2. #2
  3. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    you forgot the name=" " attribute btw

    Code:
    <input type="text" name="somefield" value="<?php echo $temp; ?>"  />
    Also notice the php tags (if temperature.php is a different file you need to [PHPNET="include"]include[/PHPNET] it)
    Last edited by aeternus; December 17th, 2012 at 02:19 AM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    I try it but no work...i try and this...
    Code:
    Temperature is: <?temperature.php echo $_GET["temp"]; ?>.<br>
    ...but no work...For save data work...i use this
    Code:
    <form name="delay" method="post" action="delay.php">  Input delay time seconds: <input type="text" name="sec" value=""  size="4" maxlength="4">
    .Where is my mistake?
  6. #4
  7. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Originally Posted by antkan
    I try it but no work...i try and this...
    Code:
    Temperature is: <?temperature.php echo $_GET["temp"]; ?>.<br>
    ...but no work...For save data work...i use this
    Code:
    <form name="delay" method="post" action="delay.php">  Input delay time seconds: <input type="text" name="sec" value=""  size="4" maxlength="4">
    .Where is my mistake?
    Did you read the link??

    this is wrong (already mentioned it):
    <?temperature.php
    should be <?php
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    I test this...inside my html index.html
    Code:
    <td><input type="text"  name="somefield"  size="4" value="<?php include 'temp.php';  echo $temp;  ?>"/></td>
    temp.php

    <?php
    $temp="25";
    ?>

    but no work....
  10. #6
  11. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Any errors?
    (if you are testing place this above all your scripts)
    PHP Code:
    <?php
    ini_set
    ('display_errors',1); 
     
    error_reporting(E_ALL);

    ?>
    Make sure in your case that the 2 files are in the same directory
    Btw it is probably a better Idea to include the file at the top of your script to keep it more organized
    Last edited by aeternus; December 17th, 2012 at 03:55 AM.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    I try this code....
    Code:
    <html>   <head>     <title>Untitled</title>   </head>   <body>  <?php ini_set('display_errors',1);   error_reporting(E_ALL); echo "hello"; ?>    </body> </html>
    but no display anything...
    Host optios are...
    Php support is on,
    Allow web users to use scripts is on but
    Apache ASP support is off....

    when load mysite/temp.php

    with this code
    Code:
    <?php $temp = "23";  echo $temp;  ?>
    display data 23
  14. #8
  15. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    OK lets start with the basics. Skipp your code and do the following nothing more nothing les.

    Make a file in notepad and call it test.php Put in that code the following. Upload it and run it.

    PHP Code:
    <?php

    echo 'hello world';

    $variable 'this is a variable';

    echo 
    $variable;

    ?>
    Does that work? Do you have a book or something about php?
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    Yes work and print hello worldthis is a variable but i want to display my variable from php file to index.html
  18. #10
  19. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Originally Posted by antkan
    Yes work and print hello worldthis is a variable but i want to display my variable from php file to index.html
    EXACTLY!~ but you can't because the file should be named .php for your server to process it as php. (unless you mess around with some server settings which i recommend you don't)

    So rename all files you have that you would like to include php in to .php (so with a .php extension instead of a .html one)

    You might want to get a decent book instead of online tutorials. books tend to start at the beginning .
    Last edited by aeternus; December 17th, 2012 at 05:29 AM.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    Ok.I understand i must make index.php.I want to make an apk to my android to upload a simple variable temperature....and read from client.It is possible for auto refresh if receive web server the data?Any advise?What type file must upload for my variable temperature .php .txt?

IMN logo majestic logo threadwatch logo seochat tools logo