Boxerman Posted October 23, 2012 Share Posted October 23, 2012 (edited) 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 October 23, 2012 by Boxerman Quote Link to comment https://forums.phpfreaks.com/topic/269796-converting-current-script/ Share on other sites More sharing options...
Boxerman Posted October 23, 2012 Author Share Posted October 23, 2012 If any more info is require please let me know. Quote Link to comment https://forums.phpfreaks.com/topic/269796-converting-current-script/#findComment-1387116 Share on other sites More sharing options...
jordan21 Posted October 23, 2012 Share Posted October 23, 2012 (edited) Edited October 23, 2012 by jordan21 Quote Link to comment https://forums.phpfreaks.com/topic/269796-converting-current-script/#findComment-1387138 Share on other sites More sharing options...
Boxerman Posted October 23, 2012 Author Share Posted October 23, 2012 (edited) 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 October 23, 2012 by Boxerman Quote Link to comment https://forums.phpfreaks.com/topic/269796-converting-current-script/#findComment-1387167 Share on other sites More sharing options...
jordan21 Posted October 23, 2012 Share Posted October 23, 2012 Hi Can you post the complete code for watch.php. I'm at work at the moment, but I'll be able to have a proper look at it when I get home in a couple of hours. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/269796-converting-current-script/#findComment-1387192 Share on other sites More sharing options...
Boxerman Posted October 23, 2012 Author Share Posted October 23, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/269796-converting-current-script/#findComment-1387341 Share on other sites More sharing options...
jordan21 Posted October 23, 2012 Share Posted October 23, 2012 You're welcome Quote Link to comment https://forums.phpfreaks.com/topic/269796-converting-current-script/#findComment-1387343 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.