Jump to content

Converting Current Script


Boxerman

Recommended Posts

Evening all,

 

The mission is to change the below script from grabbing the $id to grabbing the $title

 

I have no idea where to start or what to do, anything to help is much welcome.

 

<?
/* function to return the first N words of a string */
function shorten_string($string, $wordsreturned) {
$retval = $string;
$array = explode(" ", $string);
if (count($array)<=$wordsreturned) {
$retval = $string;
}else{
array_splice($array, $wordsreturned);
$retval = implode(" ", $array)." ...";
}
return $retval;
}
/* check to see if an article has been selected */
if(!$_GET['id']) {
$id = 0;
}else{
$id = (int) $_GET['id'];
}
/* set the number of words for the brief */
$N = 15;
/* if id is set display the news */
if($id>0) {
$query = "SELECT * FROM movies WHERE id='$id' ORDER BY id DESC";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$title = $row['title'];
$timestamp = $row["added"];
$format='F j, Y, g:i a';
$formatedTime = date($format, strtotime($timestamp));
$imdb_id = $row['imdbid'];
$imdb = new IMDb(true);
$q = "$imdb_id";
$imdb->summary=true;
$movie = $imdb->find_by_id($q);
?><p>
<b><font size="5"><?PHP print_r($movie->title);?> (<? print_r($movie->year);?>)</font> </b><br />
<?
print_r($movie->tagline);
?></p><br>
<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
if ($iphone || $ipod == true){ ?>
<iframe width='200' height='150' src='http://*****/movies/<? echo "".$row['filename'].""; ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder='0' allowfullscreen></iframe><br>
<? }else{ ?>
<video src="http://****/movies/<? echo "".$row['filename'].""; ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls/>
<script type="text/javascript" src="jwplayer.js"></script>
<script type='text/javascript' src='swfobject-2.2.js'></script>
<div id="movie">
<iframe width='200' height='150' src='http://*****.com/movies/<? echo "".$row['filename'].""; ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder='0' allowfullscreen></iframe></div>
<script type="text/javascript">
jwplayer("movie").setup({
flashplayer: "player.swf",
file: "http://******/movies/<? echo "".$row['filename'].""; ?>",
autostart: "true",
bufferlength: "1",
smoothing: "0"
});
</script>
</video>
<br>
<? } }
?>

Posted At: <?php echo $formatedTime ?>

 

I have tried to change all id's to title but that failed.

 

Thanks guys!

Link to comment
https://forums.phpfreaks.com/topic/269796-converting-current-script/
Share on other sites

Hi there,

 

thanks for your post.

 

[/font][/color]<?
/* function to return the first N words of a string */
function shorten_string($string, $wordsreturned) {
$retval = $string;
$array = explode(" ", $string);
if (count($array)<=$wordsreturned) {
$retval = $string;
}else{
array_splice($array, $wordsreturned);
$retval = implode(" ", $array)." ...";
}
return $retval;
}
/* check to see if an article has been selected */
if(!$_GET['title']) {
$query_title = NULL;
}else{
$query_title = $_GET['title']; // you should use either mysql_real_escape_string or mysqli_real_escape_string here
}
/* set the number of words for the brief */
$N = 15;
/* if id is set display the news */
if(isset($query_title)) {
$query = "SELECT * FROM movies WHERE title='$query_title' ORDER BY id DESC";
$result = mysql_query($query);

$row = mysql_fetch_array($result);

$title = $row['title'];

$timestamp = $row["added"];

$format='F j, Y, g:i a';

$formatedTime = date($format, strtotime($timestamp));
$imdb_id = $row['imdbid'];
$imdb = new IMDb(true);
$q = "$imdb_id";
$imdb->summary=true;
$movie = $imdb->find_by_id($q);
?><p>
<b><font size="5"><? print_r($movie->title);?> (<? print_r($movie->year);?>)</font> </b><br />

<?
print_r($movie->tagline);
?></p><br>

<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
if ($iphone || $ipod == true){ ?>
<iframe width='200' height='150' src='http://truvibefm.com/movies/<? echo "".$row['filename'].""; ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder='0' allowfullscreen></iframe><br>
<? }else{ ?>
<video src="http://truvibefm.com/movies/<? echo "".$row['filename'].""; ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls ?>" width="500" height="300" controls/>
<script type="text/javascript" src="jwplayer.js"></script>
<script type='text/javascript' src='swfobject-2.2.js'></script>
<div id="movie">
<iframe width='200' height='150' src='http://truvibefm.com/movies/<? echo "".$row['filename'].""; ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder="0" allowfullscreen ?>' frameborder='0' allowfullscreen></iframe></div>
<script type="text/javascript">
jwplayer("movie").setup({
flashplayer: "player.swf",
file: "http://truvibefm.com/movies/<? echo "".$row['filename'].""; ?>",
autostart: "true",
bufferlength: "1",
smoothing: "0"
});
</script>
</video>

<br>



<? } }

?>



Posted At: <?php echo $formatedTime ?>

<br><br>[color=#282828][font=helvetica, arial, sans-serif]

 

This now display the title in the URL = watch.php?id=American%20Fails

 

This however does now grab the data from the database to display the title and the movie url etc, instead i get the following errors:

 

Notice: Undefined index: title in C:\xampp\htdocs\devbox\watch.php on line 137
and
Notice: Undefined index: formatedTime in C:\xampp\htdocs\devbox\watch.php on line 137

 

Any advice on this?

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.