need help with radio script

any ideas why djadmin.php does not load at all and i get a 404 error but djadmin.htm works ok apart from getting

<? echo $_SESSION['currentname']; ?> <? echo $_SESSION['currentnickname']; <? echo $_SESSION['currentdesc']; ?> <? echo $_SESSION['lastupded']; ?>

Ah, well, yes… I never finished all the code. It was just a starting sample for you to review and see how things are done. I was going to create a database table matching this and then get it all working for you.

I will be able to do that tonight. I have to leave for an hour or two and am creating the database right now.
So, I can fix the holes in the code and it will be working later. But, do you understand all the code in general?

I will send you the fixed versions in a few hours…

i understand most of it and i can not wait to get it all working. i can not get the djadminupdates to work at all

have you got this script working yet :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:

Yes, I have it working. First, I had to create the tables that would be used.
In my simplest logic, I used this program to create the tables and ran it on the server.

createtables.php
[php]

<?PHP // Ready for user's data, now verify by database access and load load rest of data $hostname = "******"; $username = "******"; $password = "******"; $dbname = "******"; $conn = mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); $query = " CREATE TABLE IF NOT EXISTS presenters ( id INT AUTO_INCREMENT, djname TEXT, djnickname TEXT, djdesc TEXT, djpicture TEXT, djpromopicture TEXT, djlastupdated TEXT, INDEX (id))"; $result = mysql_query($query, $conn); echo mysql_errno($conn) . ": " . mysql_error($conn) . "\n"; $query = " CREATE TABLE IF NOT EXISTS shifts ( id INT AUTO_INCREMENT, presenter INT, days TEXT, hours TEXT, INDEX (id))"; $result = mysql_query($query, $conn); echo mysql_errno($conn) . ": " . mysql_error($conn) . "\n"; echo "Tables processiont complete!"; ?>

[/php]

Next, I created a DJ-editor that allows options for Add/delete/edit and includes options for various shifts.
I took the connection info and placed this into an include along with the database-open lines. Here:

my-connect.php
[php]

<?PHP $hostname = "******"; $username = "******"; $password = "******"; $dbname = "******"; $dbConn = mysql_connect($hostname, $username, $password) or die("Error connecting to database!
Error: " . mysql_error()); mysql_select_db($dbname) or die("Error opening database!
Error: " . mysql_error()); ?>

[/php]

This editor uses JS/AJax for pulling data from another PHP file that accesses the database. Also called is
an updating PHP file to make changes to the database. All seems to work well. Here are the files…

djadmin.php
[php]

<?PHP session_start(); include('my-connect.php'); ?> DJ ADMIN page

DJ Administration Form!

Instructions:
First, select a DJ to edit or create a new one. Then, alter the data areas for that DJ.
You can alter their name, description, days of the week they are schedule or hours of shifts.

Remember, if multiple shifts over days or hours, they are entered each as a separate schedule.

When done updating, press the "UPDATE" button and the data will be saved in the database.

*** Remember once this data is stored on the database, this data will show on the "LIVE" site! ***

Select a DJ to View/Edit/Delete: > <?php // Connected to your database, get names of DJs... $query = "SELECT * FROM presenters ORDER BY djname asc"; $results = mysql_query($query) or mysql_error(); // loop through the results, creating an option list, I am just using Name and Description for this test... echo "Select a DJ!"; while( $row = mysql_fetch_assoc($results) ) { echo "" . $row['djname'] . "\n"; } ?> Add New DJ!
DJ info will be listed here.
[/php]

djadminupdate.php
[php]

<?PHP SESSION_START(); include('my-connect.php'); $timestamp = date('Y-m-d H:i:s'); $_SESSION['currentdj']=$_POST['djname']; // Handle DJ Updates... if(isset($_POST['updateDJ'])) { // Upload DJ's picture (if one)... if($_FILES['djpicture']){ $target_path = "djimages/"; $target_path = $target_path . $_FILES['djpicture']['name']; if(move_uploaded_file($_FILES['djpicture']['tmp_name'], $target_path)) { //echo "The file ". $_FILES['djpicture']['name'] . " has been uploaded!
"; }else{ die ("There was an error uploading the DJ picture file, please try again!"); } } } // Upload Promo Picture (if one)... if($_FILES['djpromopicture']['name'] != ""){ $target_path = "djimages/"; $target_path = $target_path . $_FILES['djpromopicture']['name']; if(move_uploaded_file($_FILES['djpromopicture']['tmp_name'], $target_path)) { //echo "The file ". $_FILES['promopicture']['name'] . " has been uploaded!
"; }else{ die ("There was an error uploading the PROMO picture file, please try again!"); } } // Load all info into database... if($_POST['updateDJ']){ if($_POST['djselect']=="Enter new DJ NAME..."){ $query = "INSERT INTO presenters (djname, djnickname, djdesc, djpicture, djpromopicture, djlastupdated) VALUES ('" . $_POST['djname'] . "', '" . $_POST['djnickname'] . "', '" . $_POST['djdesc'] . "', '" . basename($_FILES['djpicture']['name']) . "', '" . basename($_FILES['djpromopicture']['name']) . "', '" . $timestamp . "')"; } else { $query = "UPDATE presenters SET djname='" . $_POST['djname'] . "', djnickname='" . $_POST['djnickname'] . "', djdesc='" . $_POST['djdesc'] . "', djpicture='" . basename($_FILES['djpicture']['name']) . "', djpromopicture='" . basename($_FILES['djpromopicture']['name']) . "', djlastupdated='" . $timestamp . "') WHERE djname = '" . $_POST['djname'] . "'"; } $result = mysql_query ( $query ) or die(" Errors in update/insert of DJ info!
Query=" . $query . "
Error: " . mysql_error()); } // Delete the current DJ if(isset($_POST['deleteDJ'])) { // Delete the current DJ... $query = "DELETE FROM presenters WHERE djname = '" . $_POST['djname'] . "'"; $dbResID = mysql_query ( $query ); } // Add a new shift for current DJ... if(isset($_POST['addshift'])) { $query = "INSERT INTO shifts (presenter, days, hours) VALUES (" . $_POST['djid'] . ", '" . $_POST['djnewday'] . "', '" . $_POST['djnewshift'] . "')"; $result = mysql_query ( $query ) or die(" Errors in shift update/insert!
Query=" . $query . "
Error: " . mysql_error()); } // Delete the current shift... if(isset($_POST['deleteshift'])) { $shift = substr($_POST['deleteshift'],strlen($_POST['deleteshift'])-2,2); $query = "DELETE FROM shifts WHERE id = '" . $shift . "'"; $dbResID = mysql_query ( $query ) or die(" Errors deleting this DJ's shift!
Error: " . mysql_error()); } mysql_close( $dbConn ); // After update or delete is completed, go back to ADMIN page... header("Location: djadmin.php"); ?>

[/php]

getdj.php
[php]

<?php include("my-connect.php"); // Locate the current DJ and retrieve their info... $dj = $_GET["dj"]; $sql = "SELECT * FROM presenters WHERE id = '" . $dj . "'"; $result = mysql_query($sql, $dbConn) or die("Error in presenters query!
Error: " . mysql_error); $row = mysql_fetch_assoc($result); ?> DJ ADMIN page
DJs Full Name:
DJs Nickname:
Description:
DJs Picture:
DJs Show Promo Picture:
       
Current Shifts for <? echo $row['djname']; ?>: <?PHP // Now retrieve their various shifts... $sql2 = "SELECT * FROM shifts WHERE presenter = '" . $dj . "'"; $result2 = mysql_query($sql2, $dbConn) or die("Error in shifts query!
Error: " . mysql_error); if(mysql_num_rows($result2)){ while($row2 = mysql_fetch_assoc($result2)) { echo ""; echo ""; } }else{ echo ""; } ?>
Shift : ". $row2['id'] . " : " . $row2['days'] . " - " . $row2['hours'] . "
No shifts are schedule!
Add New Scheduled Shift for this DJ: Sunday Monday Tuesday Wednesday Thursday Friday Saturday 0000 to 0600 0600 to 0900 0900 to 1200 1200 to 1400 1400 to 1600 1600 to 1800 1800 to 2000 2000 to 2100 2100 to 2200 2200 to 2400
Updated On: <? echo $row['djlastupdated']; ?> <?php mysql_close($dbConn); ?> [/php]

So, the “djadmin.php” file shows a list of the DJ’s in a drop-down. You select one or select to create a new DJ entry. Then, once you select a DJ, their personal info shows up. You can edit this data and update it. Or, delete them, whatever you need. You can add a scheduled shift for them or several. And, of course, you can upload the DJ’s picture and their “promotional” picture for the live site.

This data is saved in the database. Then, in the live pages, this database would be pulled and used to display the “promotional” picture from the “djimages” folder.

I think that covers everything we discussed in our talks posted or private. This code can be altered to be used in other ways, too. It is a simple ADMIN page. Some error checking is in place. Future improvements could be previewing the pictures on the page and perhaps some further error-checking…

its looking good but when i click add dj i get this error

Errors in shift update/insert!
Query=INSERT INTO shifts (presenter, days, hours) VALUES (Enter new DJ NAME…, ‘Friday’, ‘1200 to 1400’)
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘new DJ NAME…, ‘Friday’, ‘1200 to 1400’)’ at line 1

and how do i place it on my website?

sorry i notice my mistake i put the files in a sub folder /test/ but when i uploaded it to my root folder it worked perfect :slight_smile: .

how do i add the script o my website to display the picture.

Well, this was just a general layout so you could see how all the parts work.
Basically, now, we should change the layout that I made up to fit your ideas of what you need.
So, first, let’s alter anything you think you might need in it.

Next, you need to create a test DJ, let’s say YOU. Then, you need to upload the two pictures and a description of your “style” or whatever. I envisioned the picture to be a picture of the DJ that might be placed on the page somewhere with a “Now presenting…” or whatever. And, the “Promotional” picture to be the flashy promo that would include an advertisement for the DJ that might show what they played like “Oldies” or “The best 70’s!”…
So, these are just pictures in the form of JPG’s or PNG’s. It is displayed on a page the same as any picture.
The name of the picture would be pulled from the database and displayed in a standard HREF. That routine is just a little tricky due to day of week and hours. I will create a routine to get this info out of the database and display it as needed. Check back in a few hours for it…

i have added my presenters i just need to know how i get them shown on the site. everything works perfect :slight_smile:

only thing i need taken away is promo picture and this time added on tuesday and thursday 14:00 - 17:00

everything else is perfect :slight_smile: thank you for your hard work ernie

i take it i just delete this in getdj.php

  <tr>
	<td align="right">DJs Show Promo Picture:</td>
    <td align="left"><input type="file" id="djpromopicture" name="djpromopicture" size="35" /></td>
  </tr>

to delete the promo line.

and to add 1400 - 1700

            <option  value="1400 to 1600">1400 to 1600</option>
            <option  value="1400 to 1700">1400 to 1700</option>
                <option  value="1700 to 1800">1600 to 1800</option>

Yes, flying fingers late at night! So, here is a PHP page that lets you test the DJ code. It basically, let’s you select a day and hour and pulls the DJ that would be working then. It displays some info just for testing.

It lets you test various days and hours and pulls the info from the shifts, getting the presenter.
Then, it pulls the info for that presenter and displays it. In real life, on the live site, it would be used to
display the DJ’s picture from the djpicture name from the djimages folder and the djpromopicture, too.

(Most of this code would not be needed for the live site. Just the DB parts.) Here is the code for testing:

getpresenter.php
[php]

Testing: Retrieve and display current presenter! <?php include("my-connect.php");

// Locate the current DJ and retrieve their info…
$day = $_POST[‘day’];
$hour = $_POST[‘hour’] * 100;
$sql = “SELECT * FROM shifts WHERE days = '” . $day . “’”;
echo "Searching for DJ’s using query = " . $sql . “”;
$result = mysql_query($sql, $dbConn) or die(“Error in shifts query!
Error: " . mysql_error);
// First, calculate the start and end time of each shift to find the correct shift…
if(mysql_num_rows($result)==0){
echo “

No presenters scheduled today!

”;
}else{
while($row = mysql_fetch_assoc($result)){
$dj = $row[‘presenter’];
$shift = explode(” to ", $row[‘hours’]);
if( ($shift[0] >= $hour) && ($shift[1] <= $hour) )
break 2;
}
// The DJ’s id is found, now retrieve their info…
$sql = “SELECT * FROM presenters WHERE id = '” . $dj . “’”;
$result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error);
$row = mysql_fetch_assoc($result);
echo “

Current Presenter(DJ): " . $row[‘djname’] . “, Name of their picture: " . $row[‘djpicture’] . " and " . $row[‘djpromopicture’]. “

”;
$day=””;
}
?>

Select a day: Select Day Sunday Monday Tuesday Wednesday Thursday Friday Saturday Select hour of day: Select a hour 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [/php]

On the live site, you would use the current date/time and use that in this way to display the picture:
[php]

<?php include("my-connect.php"); // Locate the current DJ and retrieve their info... $day = date('l'); //Lower-case L $hour = date("G") * 100; $sql = "SELECT * FROM shifts WHERE days = '" . $day . "'"; $result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error); // First, calculate the start and end time of each shift to find the correct shift... if(mysql_num_rows($result)==0){ echo "

No presenters scheduled at this timeslot!

"; }else{ while($row = mysql_fetch_assoc($result)){ $dj = $row['presenter']; $shift = explode(" to ", $row['hours']); if( ($shift[0] >= $hour) && ($shift[1] <= $hour) ) break 2; } // The DJ's id is found, now retrieve their info... $sql = "SELECT * FROM presenters WHERE id = '" . $dj . "'"; $result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error); $row = mysql_fetch_assoc($result); // Display the DJ name and promo picture echo "Current Presenter(DJ): " . $row['djname'] . "
"; echo ""; } ?>

[/php]

Well, hope that explains it…

i am getting this code in getpresenter.php

Searching for DJ’s using query = SELECT * FROM shifts WHERE days = ‘Friday’

Current Presenter(DJ): Martan Lawrence, Name of their picture: martan.png and

so i take it thats working ok but the png does not show

when adding it to my website i get this code

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}} {*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\lang2057\f0\fs22\par Error: " . mysql_error);\par // First, calculate the start and end time of each shift to find the correct shift…\par if(mysql_num_rows($result)==0){\par echo "

No presenters scheduled at this timeslot!

“;\par }else{\par while($row = mysql_fetch_assoc($result)){\par $dj = $row[‘presenter’];\par $shift = explode(” to ", $row[‘hours’]);\par \tab if( ($shift[0] >= $hour) && ($shift[1] <= $hour) )\par \tab\tab break 2;\par \tab }\par // The DJ’s id is found, now retrieve their info…\par $sql = “SELECT * FROM presenters WHERE id = '” . $dj . “’”;\par $result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error);\par $row = mysql_fetch_assoc($result);\par // Display the DJ name and promo picture\par echo "
Current Presenter(DJ): " . $row[‘djname’] . "

";\par echo “”;\par }\par ?>\par }

also do i need to change this code to uk timezone

this is what it looks like on my site

Yes, it is working. It was just a sampler to show that you can use day/hour to pull the pictures and DJ info.

Use the last code to actually show the picture… Hey, actually, I will alter that getpresenter code to show
the pix for you… Here it is:

[php]

Testing: Retrieve and display current presenter! <?php include("my-connect.php");

// Locate the current DJ and retrieve their info…
$day = $_POST[‘day’];
$hour = $_POST[‘hour’] * 100;
$sql = “SELECT * FROM shifts WHERE days = '” . $day . “’”;
echo "Searching for DJ’s using query = " . $sql . “”;
$result = mysql_query($sql, $dbConn) or die(“Error in shifts query!
Error: " . mysql_error);
// First, calculate the start and end time of each shift to find the correct shift…
if(mysql_num_rows($result)==0){
echo “

No presenters scheduled today!

”;
}else{
while($row = mysql_fetch_assoc($result)){
$dj = $row[‘presenter’];
$shift = explode(” to ", $row[‘hours’]);
if( ($shift[0] >= $hour) && ($shift[1] <= $hour) )
break 2;
}
// The DJ’s id is found, now retrieve their info…
$sql = “SELECT * FROM presenters WHERE id = '” . $dj . “’”;
$result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error);
$row = mysql_fetch_assoc($result);
echo “

Current Presenter(DJ): " . $row[‘djname’] . “, Name of their picture: " . $row[‘djpicture’] . " and " . $row[‘djpromopicture’]. “

”;
$day=””;
}
echo “
<img src='djimages/” . $row[‘djpicture’] . “’>”;
echo “<img src='djimages/” . $row[‘djpromopicture’] . “’>
”;
?>

Select a day: Select Day Sunday Monday Tuesday Wednesday Thursday Friday Saturday Select hour of day: Select a hour 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [/php]

This new version just shows the images… I also noticed there is an extra “(” in the djadminupdate.php file.
In the line that updates data, remove the ) just before the WHERE. Hope that helps…

any idea what this link is about

/Dee/getpresenter.php

Sorry, that was my stupid editor redoing links. Remove the …/Dee/ part… Sorry!

And, this is the code you need to use to pull the data from the database and images based on NOW’s day/hour:

[php]

<?php include("my-connect.php"); // Locate the current DJ and retrieve their info... $day = date('l'); //Lower-case L $hour = date("G") * 100; $sql = "SELECT * FROM shifts WHERE days = '" . $day . "'"; $result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error); // First, calculate the start and end time of each shift to find the correct shift... if(mysql_num_rows($result)==0){ echo "

No presenters scheduled at this timeslot!

"; }else{ while($row = mysql_fetch_assoc($result)){ $dj = $row['presenter']; $shift = explode(" to ", $row['hours']); if( ($shift[0] >= $hour) && ($shift[1] <= $hour) ) break 2; } // The DJ's id is found, now retrieve their info... $sql = "SELECT * FROM presenters WHERE id = '" . $dj . "'"; $result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error); $row = mysql_fetch_assoc($result); // Display the DJ name and promo picture echo "Current Presenter(DJ): " . $row['djname'] . "
"; echo ""; // display PROMO picture, or change to djpicture, whichever you want... } ?>

[/php]

Sorry, helping too many people today…

Errors in shift update/insert!
Query=INSERT INTO shifts (presenter, days, hours) VALUES (Enter new DJ NAME…, ‘Monday’, ‘0900 to 1200’)
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘new DJ NAME…, ‘Monday’, ‘0900 to 1200’)’ at line 1

any idea on why thats appeared and i am still unsure on how to add it to my website :frowning:

i get this error also when saved in a .htm

include(“my-connect.php”); // Locate the current DJ and retrieve their info… $day = date(‘l’); //Lower-case L $hour = date(“G”) * 100; $sql = “SELECT * FROM shifts WHERE days = '” . $day . “’”; $result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error); // First, calculate the start and end time of each shift to find the correct shift… if(mysql_num_rows($result)==0){ echo "

No presenters scheduled at this timeslot!

“; }else{ while($row = mysql_fetch_assoc($result)){ $dj = $row[‘presenter’]; $shift = explode(” to ", $row[‘hours’]); if( ($shift[0] >= $hour) && ($shift[1] <= $hour) ) break 2; } // The DJ’s id is found, now retrieve their info… $sql = “SELECT * FROM presenters WHERE id = '” . $dj . “’”; $result = mysql_query($sql, $dbConn) or die("Error in shifts query!
Error: " . mysql_error); $row = mysql_fetch_assoc($result); // Display the DJ name and promo picture echo "
Current Presenter(DJ): " . $row[‘djname’] . "

"; echo “”; }

Sponsor our Newsletter | Privacy Policy | Terms of Service