PHP Echo: How to view/call data from separate file into echo
Hye all,
I would like to ask about echo "<--statement==>";
Ok my senario let say like this i got a file name as datax01.php & script.php
Let say on script.php i got a code to use echo. So how from echo i can recall datax01.php to view on that script?
My theory is to use $ let say script like this
<?php
$data = "datax01.php";
echo "$data";
?>
I know my theory/code is wrong so how i can do that? My limitation in this issue is i must view/recall a data from echo.
Thanxs.
*datax01.php is containing a PHP script where to process a submit form and also PHP if..else syntax
[673 byte] By [
xdefconx] at [2007-11-20 8:53:49]

# 2 Re: PHP Echo: How to view/call data from separate file into echo
Please remember to search before posting. This has been asked here many times and Google would have given you some good results. You have four options.
include() (http://us.php.net/manual/en/function.include.php)
include_once() (http://us.php.net/manual/en/function.include-once.php)
require() (http://us.php.net/manual/en/function.require.php)
require_once() (http://us.php.net/manual/en/function.require-once.php)
EDIT: If you are trying to read the contents of a file...
$content = file_get_contents('path/to/file.txt');
echo $content;
Dear PeejAvery thanxs for ur reply n ur suggestion. Actually before i posting all of that here i already do some research even at major search engine and also dev-archive.com but i didnt find it or maybe i dont understand it.
I really sorry if this question make hard for you to answer. Well i will try all of the best with this posting. Ok now i tell a 100% real case scenario. What i would like to do now is a develop a song request script to work out with Shoutcast service.
I already do a request form base script name file as request.php. Here is my code:
<?php
include ("config.php");
$reg = "yes";
$ip = $_SERVER['REMOTE_ADDR'];
?>
<html>
<head>
<title>Request a song</title>
</head>
<body>
<?php
if (isset($_POST['submit'])) {
if (empty($_POST['song'])) {
echo "Sorry, you haven't supplied the song title!<br />";
$reg = "no";
}
if (empty($_POST['artist'])) {
echo "Sorry, you haven't supplied the artists name!<br />";
$reg = "no";
}
if (empty($_POST['name'])) {
echo "Sorry, you haven't supplied your name<br />";
$reg = "no";
}
$sql = "SELECT COUNT(*) FROM request_song WHERE ip='{$ip}'";
$result = mysql_query($sql);
if (mysql_result($result, 0) > 0) {
echo "Sorry, your ip has already wished for one song, you can not wish for <br />another until the DJ's have seen your request!<br />";
$reg = "no";
}
if ($reg == "yes") {
$sql = "INSERT INTO request_song(song, artist, name, ip)
VALUES('{$_POST['song']}', '{$_POST['artist']}', '{$_POST['name']}', '{$ip}')";
mysql_query($sql);
}
echo "Your ip is: ".$ip."<br />";
}
?>
<form action="request.php" method="POST">
<table>
<tr><td>Song title: </td><td><input type="text" name="song" value=""></td></tr>
<tr><td>Artist: </td><td><input type="text" name="artist" value=""></td></tr>
<tr><td>Your name: </td><td><input type="text" name="name" value=""></td></tr>
</table>
<input type="submit" name="submit" value="Send!">
</form>
</body>
</html>
However that web page also i need to view a Shoutcast radio statistic so here is full Shoutcast radio statistic:
<?php
include ("config.php");
if ($scsuccs!=1) {
if($streamstatus == "1"){
if (isset($dj)) {
echo "
<b>Listeners:</b> $currentlisteners  <br>
<b>Current Stream URL</b>: <a href=\"http://$scip:$scport/listen.pls\"> http://$scip:$scport/listen.pls </a><br>
<b>Current Stream Title</b>: $servertitle<br>
<b>Current Song:</b> $song[0]<br>
<b>Current DJ</b>: $name<br>
<b>Current DJ ID</b>: $dj<br>
";
if ((empty($aimdb)) && (isset($aim) && $aim) && ($aim != "N/A")) {
$aimdb = $aim;
}
if ((empty($icqdb)) && (isset($icq) && $icq)) {
$icqdb = $icq;
}
if (isset($aimdb) && $aimdb) {
echo "<b>AIM</b>: $aimdb<br>";
}
if (isset($msn) && $msn) {
echo "<b>MSN</b>: $msn<br>";
}
if (isset($yim) && $yim) {
echo "<b>YIM</b>: $yim<br>";
}
if (isset($icqdb) && $icqdb) {
echo "<b>ICQ</b>: $icqdb<br>";
}
if ($showsetby == 1) {
echo "<br><br><b>This DJ was found by checking:</b> $setby";
}
} else {
echo "<center><b>A DJ of LepakFM.net is not currently signed on to the system or not in duty today. LepakFM.net radio services may running on auto run mode. <br>Please check again later.</b></center><br>
<br><b>Current Stream Title</b>: $servertitle<br>
<b>Current Song:</b> $song[0]<br>";
}
} else {
echo "<b>A DJ of LepakFM.net is not currently connected to the radio or not in duty today. Please check again later.</b>";
}
} else {
echo "<b>Lepakfm.net radio services is currently down. Please check again later.</b>";
}
echo "<br><br><font size=\"-1\"><strong>Powered by $version - ©2007 sTup|D - <a href=\"http://www.lepakfm.net\" target=\"_blank\">www.lepakfm.net</a></strong></font>";
?>
So my problem is how to "insert request.php" into this echo:
<?php
include ("config.php");
if ($scsuccs!=1) {
if($streamstatus == "1"){
if (isset($dj)) {
echo "
<!-- I WANT TO PUT REQUEST SCRIPT HERE -->
<br>
<b>Listeners:</b> $currentlisteners  <br>
<b>Current Stream URL</b>: <a href=\"http://$scip:$scport/listen.pls\"> http://$scip:$scport/listen.pls </a><br>
<b>Current Stream Title</b>: $servertitle<br>
<b>Current Song:</b> $song[0]<br>
<b>Current DJ</b>: $name<br>
<b>Current DJ ID</b>: $dj<br>
";