Jump to content

Retriving URL from database


rahulvicky00

Recommended Posts

Hi Mates,

I am very new to PHP so this forums too. i have stored a URL in database as VARCHAR, now i want to retrieve that URL in src attribute..is it possible in php to retrieve that URL in src so i can get the latest URL running with the tag? if yes then how to get that.

 

 

Link to comment
https://forums.phpfreaks.com/topic/251538-retriving-url-from-database/
Share on other sites

 

Thanks for your reply... but the problem is still.. i am clearing my scenario here.

 

i have uploaded a video in my sites in a specified folder and stored the URL in database. now i want to retrieve that  particular URL to my video player with the help of "video tag". it requires "src attribute" in that i want to retrieve the URL so every time when the new video have been uploaded that video will run in the video player..

 

please send some suggestions...

freelance84 provided you with a tutorial that explains how to retrieve MySQL data using PHP. After reading it carefully for a good understanding, you should be able to adapt the examples there to fit what you need to do. If you get stuck, show us the code you have so far and we'll go from there.

freelance84 provided you with a tutorial that explains how to retrieve MySQL data using PHP. After reading it carefully for a good understanding, you should be able to adapt the examples there to fit what you need to do. If you get stuck, show us the code you have so far and we'll go from there.

;)

 

Thanks for your reply...

 

My code is looks like:

 

<html>

<head>

<script type="text/javascript" src="/jwplayer/jwplayer.js"> </script>

</head>

<body>

<?php

$link = mysql_connect("localhost", "dbname", "password");

if(!$link)

{

die("Connection Lost" . mysql_error());

}

mysql_select_db ("635177_vik", $link);

$data = mysql_query('SELECT * FROM vik ORDER BY id DESC LIMIT 1');

$info = mysql_fetch_array($data);

 

echo "<video class="jwplayer" src=".$info['path']." width="252" height="250"></video>";

mysql_close($link);

  ?>

</body>

</html>

it showing an error :: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /srv/disk3/635177/www/indiavsaustralia.in/vup/acha/flash.php on line 16

There may be other issues, but the thing that jumps out at me is the use of double quotes inside of a double quoted string:

 

<?php
//...

echo "<video class="jwplayer" src=".$info['path']." width="252" height="250"></video>";

//...
?>

 

 

You need to escape the quotes, switch to a single quoted string, or use single quotes for your attributes. For example:

 

<?php
//...

echo '<video class="jwplayer" src=' . $info['path'] . ' width="252" height="250"></video>';

//...
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.