Member Avatar for rajarajan2017

Yes, but what happen when you did like that? I think you do not understand what I am saying, the above code will not affect your url display, your url display only coming from the link, not from there. so tell me clearly what happening after implementing the above code.

I understand you all your code working perfect the problem is only the url displaying music1.mp3 i think you understand me

Member Avatar for rajarajan2017

Please give me a screenshot

Please give me a screenshot

ok i am showing you what i did i have also database please it

Hi Raja i did a pop up player and all my mp3 file in a single directory to the server i created a database here is what i did please help me
accessdb.php

<?php

if (isset($_GET['id'])) {
    $id = $_GET['id'];

   
    $link = mysql_pconnect('localhost','peter','123456');
   
    mysql_select_db('audio');

    $query = "INSERT INTO mp3s (id,artist,title,filepath)
              VALUES (1,'John','I need','/path/music.mp3')";
    $result = mysql_query($query);
   
    $query = "SELECT * FROM mp3s WHERE id=".$id." LIMIT 1";
    $result = mysql_query($query);   
   
}

?>

popup player.php

<?php if (empty($id)) { ?>
<?php } else {
// you can fetch data from database result set using mysql_fetch_assoc()
     $row = mysql_fetch_assoc($result);
?>

<table>
<tr>
<td><h1><?php echo $row['title'] ." by " . $row['artist']; ?></h1></td>
</tr>
<tr>
<td>
<td valign="top"> <div align="center"> <embed src="mydomail.com/bashaash1/php/<?php echo $row['filepath']; ?>
" type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1"
CONTROLS="ControlPanel,StatusBar" HEIGHT="57" WIDTH="400" AUTOSTART="true"></div>
</td>
</tr>
</table><br>


       
    <?php } ?>

link code

<a href="/play.php?id=1">listen music</a>
Member Avatar for rajarajan2017

Confused. Have a link as play.php where is the code of play.php?

Confused. Have a link as play.php where is the code of
play.php?

Here is play.php i think the porblem is the red lines }else{ help my teacher

<?php if (empty($id)) { ?>
<?php } else {// you can fetch data from database result set using mysql_fetch_assoc()
     $row = mysql_fetch_assoc($result);
?>

<table>
<tr>
<td><h1><?php echo $row['title'] ." by " . $row['artist']; ?></h1></td>
</tr>
<tr>
<td>
<td valign="top"> <div align="center"> <embed src="mydomail.com/path/<?php echo $row['filepath']; ?>
" type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1"
CONTROLS="ControlPanel,StatusBar" HEIGHT="57" WIDTH="400" AUTOSTART="true"></div>
</td>
</tr>
</table><br>


       
    <?php } ?>

I'll jump in here. I noticed that bit of code before, and it seems odd.

First, you're opening and closing PHP unnecessarily.

Second, you have no code if your condition is met.

Third, now that I look at it, your if statement isn't closed, and your table TD tags aren't closed.

Nothing is going to work right from the start of your table tags aren't tags and statements aren't opened and closed properly. Get a good syntax colouring text editor like Notepad++ (free), then validate your HTML - that will help you a lot. See my signature lines below for links.

Instead of:

<?php if (empty($id)) { ?>
<?php } else {// you can fetch data from database result set using mysql_fetch_assoc()
     $row = mysql_fetch_assoc($result);
?>

Try something like this:

<?php 
if (!empty($id)) { 
  // you can fetch data from database result set using mysql_fetch_assoc()
  $row = mysql_fetch_assoc($result);
}
?>

Further to that, it's hard to read this code without the wider context of what's happening.

Is player.php supposed to receive the song id as a query string?

If that's the case, you want to do something like this;

if (isset($_GET['id']) && $_GET['id'] != "") {
  $id = $_GET['id'];

  // connect to database server and select db to work with
  $link = mysql_pconnect('localhost','peter','123456');
  mysql_select_db('audio');

  // capture data from database
  $query = "SELECT * FROM mp3s WHERE id=".$id." LIMIT 1";
  $result = mysql_query($query);
   
  while ($row = mysql_fetch_array($result)) {

    // create a variable for each attribute
    foreach($thisrow as $var => $value){
      $$var = $value;
    }
   
    ?>
    <table>
      <tr><td><h1><?php echo "$title by $artist"; ?></h1></td></tr>
      <tr><td valign="top"> <div align="center">
        <embed src="mydomail.com/bashaash1/php/<?php echo "$filepath"; ?>
        " type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1"
        CONTROLS="ControlPanel,StatusBar" HEIGHT="57" WIDTH="400" AUTOSTART="true">
      </div></td></tr>
    </table><br>
    <?php
  }
} else {
  echo "Sorry, didn't receive the song ID, can't do anything.";
}

I'll jump in here. I noticed that bit of code before,

Ok teacher can you do write all code play.php thanks i understood what you said thanks but i wanna your help please give full code

Honestly, nobody is going to write your whole application for you. Lots of people are happy to help out, but you have to be prepared do most of the work yourself.

Honestly, nobody is going to write your whole application for you. Lots of people are happy to help out, but you have to be prepared do most of the work yourself.

you for got to wrote <?php above the line one

you for got to wrote <?php above the line one

No, I didn't intend to enclose that block of PHP code in <?php ?> tags. You may have also noticed that I didn't put ?> on the last line either.

You'll often see code samples on web forums without them.

Cheers,

Rob

No, I didn't intend to enclose that block of PHP code in <?php ?> tags. You may have also noticed that I didn't put ?> on the last line either.

You'll often see code samples on web forums without them.

Cheers,

Rob

i did what you did still not working i dont know where the problem is still help

I don't know what else I can do to help you. Validate your code to make sure the HTML is correct. If that doesn't work you'll have to keep researching it.

Whenever I have trouble with something like this I start by validating my HTML, then if that doesn't fix it (it often does) I strip everything down to the most simple example I can create and start to build once I get that working.

Member Avatar for rajarajan2017

Mr. bashaash ,

Finally I want to do onething, please attach your php files, give your table structure and records (in the sense, create table and insert into) just I need to paste in my phpmyadmin and it should created the table and inserted the records (U understand?),no need of music files and I will use dummies. Hope you understand well. Please attach and I will test in my system and if any error occurs I will try to fix it. becoz this thread is going long but it may be fixed while I seen the code files.Thanks

Thanks mr Raja i show all what i did an hope you will help me really first i begin the table ¨

======================================================
|      id       |     title    |    artist   |  filepath   |
------------------------------------------------------------
|      1        |  Song Name   |  song artist|  song.mp3   |
------------------------------------------------------------
|      2        |  Song Name   |  song artist|  song.mp3   |
------------------------------------------------------------
|      3        |  Song Name   |  song artist|  song.mp3   |
============================================================

here is the full code i did all in one
play.php

<?php  

  $connection = mysql_connect('localhost','user','pass'); 
  if (!$connection) 
  {  
   die ('error connecting to database server'.mysql_error());     
  } 
   
   mysql_select_db('audio', $connection); 
  
  $result = mysql_query("SELECT * FROM mp3s WHERE id = '{$_GET['id']}'") or die(mysql_error()); 
  if(mysql_num_rows($result)) 
  { 
  while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { 
     $mp3s = $row['mp3s']; 
  } 
  }   
?>   
<?php   
  if (isset($_GET['id']) && $_GET['id'] != "") {  
  $id = $_GET['id']; 
  $row = mysql_fetch_array($result); 
} 
?> 

<head> 
<title><?php echo $row['title']; ?></title> 
</head> 
  
<tr> 
<td><h1><?php echo $row['artist']; ?></h1></td> 
</tr> 
<tr> 
<td height="30" colspan="0" valign="top"><table width="400" height="80" border="0" align="center" cellpadding="0" cellspacing="1"> 
<tr> 
<td height="181" bgcolor="#ffffff"><table width="100%" border=0 align="left" 
    cellpadding=0 cellspacing=0 bordercolor=#009900 style="BORDER-COLLAPSE: collapse"> 
<tbody> 
<tr> 
<td> <div align="center"><strong><font color="#0000FF" size="2" face="Verdana, Arial, Helvetica, sans-serif"></font></strong></div> 
<table style="BORDER-COLLAPSE: collapse" bordercolor=#009900 cellspacing=0 
    cellpadding=0 width="100%" border=0> 
<tbody> 
<tr> 
<td><div align="center"><font color=#000000><b></b></font></div> 
<tr> 
<td> <div align=center></div> 
<div align=center><font color="#000000" size="3"><strong><font face="Verdana, Arial, Helvetica, sans-serif"></font></strong></font></div> 
<tr> 
<th height="200"> 
<div align="center"> 
<center> 

<table  align="center" border="2"  cellpadding="0" cellspacing="1" style="border-collapse: collapse" bordercolor="#9B8C34" width="45" id="AutoNumber1"> 
  <tr> 
    <td > 
      <p align="center"> 
   <object id="p67" 
height=64 width=360 border="0" 
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" 
type="application/x-oleobject" 
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"> 
          <param name="URL" value="http://www.mydomain.com/play.php?id=<?php echo $row['filepath']; ?>"> 
          <param name="autostart" value="-1"> 
          <param name="rate" value="1"> 
          <param name="balance" value="0"> 
          <param name="currentPosition" value="0"> 
          <param name="defaultFrame" value> 
          <param name="playCount" value="1"> 
          <param name="currentMarker" value="0"> 
          <param name="invokeURLs" value="-1"> 
          <param name="baseURL" value> 
          <param name="volume" value="50"> 
          <param name="mute" value="0"> 
          <param name="uiMode" value="full"> 
          <param name="stretchToFit" value="0"> 
          <param name="windowlessVideo" value="0"> 
          <param name="enabled" value="-1"> 
          <param name="enableContextMenu" value="-1"> 
          <param name="fullScreen" value="0"> 
          <param name="SAMIStyle" value> 
          <param name="SAMILang" value> 
          <param name="SAMIFilename" value> 
          <param name="captioningID" value> 
          <param name="enableErrorDialogs" value="0"> 
          <param name="_cx" value="7117"> 
          <param name="_cy" value="1191"> 
          <embed type="application/x-mplayer2" 
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" 
name="p12" 
width=434 
height=45 
src="http://www.mydomain.com/play.php?id=<?php echo $row['filepath']; ?>"> 
showcontrols="true" 
autostart="false"> </embed> 
</object></th> 
</tr> 
</BODY>

pop up link

<A HREF="javascript:void(1)"onclick="window.open('play.php?id=1','linkname','height=300, width=414, resizable=0, scrollbars=0')"><b>listen music</b></a>

Hi Mr Raja i posted all the here thanks again

Member Avatar for rajarajan2017

Let I will check it and get you back now

Member Avatar for rajarajan2017

HTML file:

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<A HREF="#"onclick="window.open('play.php?id=1','linkname','height=300, width=414, resizable=0, scrollbars=0')"><b>listen music</b></a>
</body>
</html>

Play.php:

<?php  

  $connection = mysql_connect('localhost','root',''); 
  if (!$connection) 
  {  
   die ('error connecting to database server'.mysql_error());     
  } 
   
   mysql_select_db('testdb', $connection); 
  
  $result = mysql_query("SELECT * FROM mp3s WHERE id = '{$_GET['id']}'") or die(mysql_error()); 
  if(mysql_num_rows($result)) 
  { 
  while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { 
     $mp3s = $row['filepath'];
	//echo $mp3s;
  } 
  }   
?>
<html>
	<body>
	 <table>
		 <tr>
			 <td><object id="p67" 
height=64 width=360 border="0" 
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" 
type="application/x-oleobject" 
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"> 
          <param name="URL" value="<?php echo $mp3s; ?>"> 
          <param name="autostart" value="-1"> 
          <param name="rate" value="1"> 
          <param name="balance" value="0"> 
          <param name="currentPosition" value="0"> 
          <param name="defaultFrame" value> 
          <param name="playCount" value="1"> 
          <param name="currentMarker" value="0"> 
          <param name="invokeURLs" value="-1"> 
          <param name="baseURL" value> 
          <param name="volume" value="50"> 
          <param name="mute" value="0"> 
          <param name="uiMode" value="full"> 
          <param name="stretchToFit" value="0"> 
          <param name="windowlessVideo" value="0"> 
          <param name="enabled" value="-1"> 
          <param name="enableContextMenu" value="-1"> 
          <param name="fullScreen" value="0"> 
          <param name="SAMIStyle" value> 
          <param name="SAMILang" value> 
          <param name="SAMIFilename" value> 
          <param name="captioningID" value> 
          <param name="enableErrorDialogs" value="0"> 
          <param name="_cx" value="7117"> 
          <param name="_cy" value="1191"> 
          <embed type="application/x-mplayer2" 
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" 
name="p12" 
width=434 
height=45 
src="<?php echo $mp3s;?>"> 
showcontrols="true" 
autostart="false"> </embed> 
</object></td>
		 </tr>
	 </table>
	</body>
</html>

I have tested with my localhost working fine.

Note:
1. I have changed javascript dummy code within ahref="#"
2. PHP code is altered

<param name="URL" value="<?php echo $mp3s; ?>">

and

src="<?php echo $mp3s; ?>

Because there is no need of play.php?id=music1.mp3 again. You give the path whatever you want in the database. for tested it locally I used music1.mp3 and placed in the same folder. In your case store http://mydomain.com/music1.mp3 in the database and use the above code as it is.

Hope you say solved!

Again Thank you , the code is working now

Thnak you very very much Mr Raja for your help realy appreciated !

regards

Member Avatar for rajarajan2017

Welcome!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.