The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Html read php variables
Discuss Html read php variables in the PHP Development forum on Dev Shed. Html read php variables PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 17th, 2012, 02:12 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 2 h 39 m 51 sec
Reputation 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.
|

December 17th, 2012, 02:16 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
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 include it)
Last edited by aeternus : December 17th, 2012 at 02:19 AM.
|

December 17th, 2012, 02:27 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 2 h 39 m 51 sec
Reputation 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?
|

December 17th, 2012, 03:01 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
Quote: | 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
|

December 17th, 2012, 03:34 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 2 h 39 m 51 sec
Reputation 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....
|

December 17th, 2012, 03:49 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
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.
|

December 17th, 2012, 05:03 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 2 h 39 m 51 sec
Reputation 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
|

December 17th, 2012, 05:13 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
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?
|

December 17th, 2012, 05:23 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 2 h 39 m 51 sec
Reputation Power: 0
|
|
|
Yes work and print hello worldthis is a variable but i want to display my variable from php file to index.html
|

December 17th, 2012, 05:26 AM
|
 |
For POny!
|
|
Join Date: Apr 2012
Location: Amsterdam
|
|
Quote: | 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.
|

December 17th, 2012, 05:31 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 7
Time spent in forums: 2 h 39 m 51 sec
Reputation 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?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|