Nowplaying track in embedded container

You have a question or need an advice about how to do something? Ask it here!
friso
Posts: 173
Joined: 10 Apr 2012 10:05
Re: Nowplaying track in embedded container

Post by friso »

Bernd

No i don't have someone, but i think a lot of proppfrexx users have benefits with this when they have a little help.

I have tested a bit. So far i have this:

nowplaying.php:
<html>
<body>

<form action="songtitle.php" method="post">
$artist = $_POST["artist"];
$song = $_POST["song"];
</form>

</body>
</html>

songtitle.php
<html>
<body>

<?php echo $_POST["artist"]; ?>
<?php echo $_POST["song"]; ?>

</body>
</html>

In the command i give a test, and it says OK but nothing on the screen when going to songtitle.html
Attachments
screenshot_4.jpg
screenshot_4.jpg (10.77 KiB) Viewed 14813 times
User avatar
hdradio
Posts: 625
Joined: 10 Apr 2012 17:36
Location: Crete, Hellas
Re: Nowplaying track in embedded container

Post by hdradio »

Go to fiverr.com and ask someone to do that for you for $5.
friso
Posts: 173
Joined: 10 Apr 2012 10:05
Re: Nowplaying track in embedded container

Post by friso »

hdradio thanx :lol:
But now for real, is there nobody who can put me in the right direction. After reading some articles, i think that my command should be something like: EXEC_SEND_HTTP_GET http://frisotrip.nl/php/nowplaying.php?artist={artist}

and for testing this is the php script

<?php echo $_GET['artist']; ?>

After going to the site, a blank page is displayed.
So if i can let this simple code work, i can build this further. So please anyone can help?

Friso
friso
Posts: 173
Joined: 10 Apr 2012 10:05
Re: Nowplaying track in embedded container

Post by friso »

Bernd

Thanx, i will look at it, but can't it be more easy? Why do i have to use an database for such a simple task?
I only want to display Artist - Trackname.
So when it reads the variable, print it on my display, or put it in a txt file so i can display it on the website. The same i did with the writeplaylist command.

Friso
friso
Posts: 173
Joined: 10 Apr 2012 10:05
Re: Nowplaying track in embedded container

Post by friso »

Bernd

Come on don't be angry. I just want to learn. We are not all programming engineers
User avatar
radio42
Site Admin
Posts: 9056
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Nowplaying track in embedded container

Post by radio42 »

I am not angry; but your question is a pure web design question...
friso
Posts: 173
Joined: 10 Apr 2012 10:05
Re: Nowplaying track in embedded container

Post by friso »

Bernd

I'm still struggling with the code you give me.
Creating the mysql from the code give an error, and now i manually created the database and the tables in it. Also i found the most settings of the collums. But when created the php files gives me errors during test in proppfrexx.
Also i think that the database connection settings is the config.php file?
Attachments
screen_2.jpg
screen_2.jpg (50.28 KiB) Viewed 14906 times
screen_1.jpg
screen_1.jpg (38.37 KiB) Viewed 14906 times
User avatar
radio42
Site Admin
Posts: 9056
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Nowplaying track in embedded container

Post by radio42 »

You need to know PHP or ASP.Net to understand the basics...and as said, I can not teach all that here!
Don't you have someone local in your area who knows something about web-design?
User avatar
radio42
Site Admin
Posts: 9056
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Nowplaying track in embedded container

Post by radio42 »

You need 2 scripts: one for the update and one for the user's display.
In the update script you e.g. insert your now playing track data to a MySQL database table and you invoke this from within ProppFrexx.
In the display script you retrieve the last inserted value back again from that table and display it as a html page...

Here are 2 very simple and untested examples of those scripts:

1. Update Script:

Code: Select all

<?php Header("Content-Type: text/html; charset=utf-8")?>
<?PHP
$artist = $_REQUEST['artist'];
$title = $_REQUEST['title'];
require('inc/config.php');
$con = mysqli_connect($dbhost,$dbuser,$dbpasswd,$dbname);
if (mysqli_connect_errno($con))
{
}
else
{
	mysqli_autocommit($con, TRUE);
	mysqli_query($con,"SET NAMES 'utf8'");
	$artist = mysqli_real_escape_string($con, $artist);
	$title = mysqli_real_escape_string($con, $title);
	try
	{
		mysqli_query($con,"INSERT INTO NOWPLAYING (ARTIST, TITLE) " .
									  "VALUES ('$artist', '$title')");
	}
	catch (Exception $e)
	{
	}
}
mysqli_close($con);
?>
Note, that this script uses another php file, which contains your database connection parameters:

Code: Select all

<?php
$dbhost = 'your.mysql.dnsname';
$dbname = 'yourDBname';
$dbuser = 'yourUsername';
$dbpasswd = 'yourPassword';
?>
You can then call the update script from within ProppFrexx like this:

Code: Select all

EXEC_SEND_HTTP_POST http://yourwebsite.com/update.php?title=${title}&artist=${artist}
The display script for the user (to which you display the now playing content) might look like this:

Code: Select all

<?php Header("Content-Type: text/html; charset=utf-8")?>
<?PHP
echo <<<'EOT'
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Now Playing</title>
</head>
<body>
EOT;

require('inc/config.php');
$con = mysqli_connect($dbhost,$dbuser,$dbpasswd,$dbname);
if (mysqli_connect_errno($con))
{
}
else
{
	mysqli_query($con,"SET NAMES 'utf8'");
	$result = mysqli_query($con,"SELECT * FROM NOWPLAYING ORDER BY TIME desc LIMIT 1);
	while($row = mysqli_fetch_array($result))
	{
		$artist = $row['ARTIST'];
		$title = $row['TITLE'];
		echo "<div>" . $artist . " - " . $title ."</div>";
	}
}
mysqli_close($con);

echo <<<EOT
</body>
</html>
EOT;
?>
That's it - roughly...

The database table might look like this:

Code: Select all

CREATE TABLE `NOWPLAYING` (
  `ARTIST` varchar(256) NOT NULL DEFAULT '',
  `TITLE` varchar(256) NOT NULL DEFAULT '',
  `TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  PRIMARY KEY (`TIME`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
User avatar
radio42
Site Admin
Posts: 9056
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Nowplaying track in embedded container

Post by radio42 »

I gave you a database example, since most users might want to use a database; simply because tomorrow you also might want to display a history of 10 recently played tracks etc. and a database is simply more flexible than a plain file...
And NO, it can not be more simple...but if you don't like the answer, then please go and ask someone else, since as said, I am not a web designer...

Post Reply