Jump to content

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!

Edited by Boxerman
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?

Edited by Boxerman

Jordan, sorry for the slow response. After leaving this for a few hours and coming back it was clear as daylight.

 

If this helps anyone else. It was because I was doing watch.php?id= where I should of done watch.php?title=

 

 

Thanks again Jordan.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.