1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how can i replace name of the file with php echo

Discussion in 'PHP' started by macaela, Jul 12, 2011.

  1. #1
    hi i have the above function but what i am trying to do is replace the above the name of the file with the one that will be queried from the database but i keep getting sintax error.
    want to to put where it says filr name example (file1.mp4) with the ( <?php echo $filename?>) but i keep getting sintax error

    echo "<td><a href='#' onClick=\"jwplayer().load({'file': 'file1.mp4', 'hd.file': 'file2.mp4'})\"> </td>";
    
    PHP:
    so it would look like this

    echo "<td><a href='#' onClick=\"jwplayer().load({'file': '<?php echo $filename1?>', 'hd.file': '<?php echo $filename2?>'})\"> </td>";
    PHP:
    but gives me error
     
    macaela, Jul 12, 2011 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    You are already inside a php tag, and inside an echo statement too, so you cannot open another php tag anymore.

    You should:

    echo "<td><a href='#' onClick=\"jwplayer().load({'file': '$filename1', 'hd.file': '$filename2'})\"> </td>";
    PHP:
    Or,

    echo "<td><a href='#' onClick=\"jwplayer().load({'file': '".$filename1."', 'hd.file': '".$filename2."'})\"> </td>";
    PHP:
    Read more about php basic concatenation and using variables inside a string.
     
    ads2help, Jul 12, 2011 IP
  3. macaela

    macaela Active Member

    Messages:
    181
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    ok the way you mention got rid of the error but i am a lil confused because the link doesnt work but i think that would be another problem just wanted to doubel check this line as it is will fetch all the first name in the database and display as many time as it is on the database as if i had the line like this??

      echo "<td>" . $row['FirstName'] . "</td>";
    
    PHP:
    or like this i will need something extra like a GET_[FirstName] on top of my while fetch loop
    echo "<td><a href=\"#\" onClick=\"jwplayer().load({'file': '".$FirstName."', 'hd.file': '".$FirstName."'})\"> " . $row['FirstName'] ."</td>";



    this how the whole code looks now that should do a normal database query or i am missing something in order for those new line that you gave me to work

    <html>
    <head>
    
    </head>
    
    
    <body>
    
    
    
    
    <?php
    $q=$_GET["q"];
    
    $con = mysql_connect('localhost', 'root', '');
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("droptest", $con);
    
    $FirstName=$_GET['FirstName'];
    
    
    $sql="SELECT * FROM user WHERE id = '".$q."'";
    
    
    $result = mysql_query($sql);
    
    echo "<table border='1'>
    <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
    <th>Hometown</th>
    <th>Job</th>
    <th>secondvideo</th>
    
    </tr>";
    
    //jwplayer().load('file':hofbell30732_SD.mp4','hd.file':'hofbell30732_SD.mp4')
    //<a href="#" onClick="jwplayer().load({'file': 'hofbell30732_SD.mp4', 'hd.file': 'videos/film.mp4'})"> </a>
    //onClick="jwplayer().load({\'file\': \'hofbell30732_SD.mp4\', \'hd.file\': \'videos/film.mp4\'})">
    //  echo $row['FirstName'] . " " . $row['LastName'];
    
    while($row = mysql_fetch_array($result))
    
      {
      echo "<tr>";
    //echo "<td><a href=\"#\" onClick=\"jwplayer().load('" . $row['FirstName'] . "')\">" . $row['FirstName'] . "<a/></td>";
       echo "<td>" . $row['LastName'] . ''. $row['Job'] . "</td>";
      echo "<td>" . $row['Age'] . "</td>";
      echo "<td>" . $row['Hometown'] . ''. $row['Job'] . "</td>";
      echo "<td>" . $row['Job'] . "</td>";   
    
      
    echo "<td><a href=\"#\" onClick=\"jwplayer().load({'file': '".$FirstName."', 'hd.file': '".$FirstName."'})\"> " . $row['FirstName'] ."</td>";
    
      echo "<td>" . $row['arr'] . "</td>";  
        echo "<td>" . $arr . "</td>";
    
    
      echo "</tr>";
      }
    echo "</table>";
    
    mysql_close($con);
    
    ?>
    
    </body>
    </html>
    PHP:
     
    macaela, Jul 12, 2011 IP
  4. protocol96

    protocol96 Peon

    Messages:
    413
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Can you please check if you're passing the value for $FirstName, please echo the output as well
     
    Last edited: Jul 13, 2011
    protocol96, Jul 13, 2011 IP