VHPirie Posted June 21, 2007 Share Posted June 21, 2007 Hi, I'm a php newbie so thought I would come here and ask for a bit of help. I once followed a tutorial which showed me how to select a single entry from the database. I want to do the same, but not using a database. I have some video's on youtube which I have put into seperate HTML pages. Wat I want to do is have one page, and link to it like www.something.com/video.php?vid=001 And I'll have a page with all the variables set, like 001 = vid1 & description1. So when the url is loaded it loads up the video URL and the video description and puts them on the page....then when the URL is loaded with 002, 003 etc etc it loads up the different vids. Does that make sense? I'm not sure how to do it...does anyone know how it could be done? Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/ Share on other sites More sharing options...
chronister Posted June 21, 2007 Share Posted June 21, 2007 I used something similar for a while. I used to "template" my sites using this method. Here is the code I have array.php <?php $page[home] = array( 'page_title' => 'Just A Web Page', 'path' =>'pages/page.php', ); $page[page1] = array( 'page_title' => 'Another Web Page', 'path' =>'pages/page2.php', ); ?> index.php <?php $includefile=$page[$id][path]; // get file path for $id //using fopen to verify file. the third parameter triggers include_path search $handle = fopen($includefile, "r", 1); if ($handle) { fclose($handle); include ($includefile); } else{ echo "<h3 align=center>Please Try Again.<br><br> This Page Cannot Be Found</h3>"; }; ?> You will need to take the code and adapt it to your needs, but this is basically what your after. In this script I would pass the $id variable through the URL. So my URL looked like this www.mysite.com?id=page1 I think this would work for what your wanting it for. Hope it helps, Nathan Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279135 Share on other sites More sharing options...
VHPirie Posted June 21, 2007 Author Share Posted June 21, 2007 Thx heaps for that mate. Just tried it and have got the following: Notice: Undefined variable: id in d:\program files\easyphp1-8\www\kbkustoms\movie_index.php on line 2 Notice: Use of undefined constant path - assumed 'path' in d:\program files\easyphp1-8\www\kbkustoms\movie_index.php on line 2 Notice: Undefined variable: page in d:\program files\easyphp1-8\www\kbkustoms\movie_index.php on line 2 Please Try Again. This Page Cannot Be Found Is this because the variables used on line 2 aren't set? Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279143 Share on other sites More sharing options...
chronister Posted June 21, 2007 Share Posted June 21, 2007 The errors are popping up because your error-reporting is set too low. If you have access to php.ini, set error_reporting to E_ERROR, that should take care of your errors. The page cannot be found item is because the "path" is not correct. Fix the error and then post back with some of your code and I will take a look. Also show me what your trying to call in the url. Thanks, Nate Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279349 Share on other sites More sharing options...
VHPirie Posted June 22, 2007 Author Share Posted June 22, 2007 thanks mate, changed the php.ini file and it's fixed the errors, now just get the page error: Please Try Again. This Page Cannot Be Found This is movie_index.php <?php $includefile=$page[$id][path]; // get file path for $id //using fopen to verify file. the third parameter triggers include_path search $handle = fopen($includefile, "r", 1); if ($handle) { fclose($handle); include ($includefile); } else{ echo "<h3 align=center>Please Try Again.<br><br> This Page Cannot Be Found</h3>"; }; ?> And this is array.php...for testing I'm just trying to load up different sections of the site. <?php $page['forsale'] = array( 'page_title' => 'For Sale Section', 'path' =>'forsale.php', ); $page['footer'] = array( 'page_title' => 'The Footer', 'path' =>'footer.php', ); ?> And the URL I'm trying to access is... http://127.0.0.1/KBKUSTOMS/movie_index.php?id=forsale Can u see anything wrong? Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279937 Share on other sites More sharing options...
CrazeD Posted June 22, 2007 Share Posted June 22, 2007 You could use a MySQL table for this. You could have a row called vid_id, and then a row called description and a row called location, for example. Say your vid_id is 001, description is blah blah blah, and the location is www.somewhere.com/media/vid_001.swf You could do something like this: <?php $sql = "SELECT * FROM your_table_name WHERE vid_id={$_GET['vid']} LIMIT 1"; if ($result = mysql_query ($sql)) { $row = mysql_fetch_array ($result); print '<object width="550" height="400"> <param name="movie" value="'.$row['location'].'"> <embed src="'.$row['location'].'" width="550" height="400"> </embed> </object>'; } else { // Query failed print '<p>Error: <b>'.mysql_error().'</b></p>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279944 Share on other sites More sharing options...
VHPirie Posted June 22, 2007 Author Share Posted June 22, 2007 thx mate, sorta wanted to stay away from using a database for it...will give it a shot tho. Here's something I tried to do, but it doesn't work.....maybe someone knows wat I'm doing wrong lol The url I'm using is... http://127.0.0.1/KBKUSTOMS/test.php?vid=001 <?php $vid = $_GET['vid']; $vid['001'] = array( 'title' => 'VH Exhaust', 'code' =>'oPtuYU0hxEA', ); $vid_title = $vid['title']; $vid_id = $vid['code']; echo " <b>$vid_title</b><br> <br> <object width=425 height=350> <param name=movie value=http://www.youtube.com/v/$vid_id></param> <param name=wmode value=transparent></param> <embed src=http://www.youtube.com/v/$vid_id type=application/x-shockwave-flash wmode=transparent width=425 height=350></embed> </object> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279954 Share on other sites More sharing options...
CrazeD Posted June 22, 2007 Share Posted June 22, 2007 I'm sorry, I think I mis-read what you wanted to do. Do you just have a few videos that you want to hard-code? I was thinking you were trying to make a youtube-like site, where people would upload videos. If you just want to hard-code a few videos based on the vid_id that's pretty easy. Just use a conditional. For example: <?php switch ($_GET['vid']) { case 001: // Execute your code if test.php?vid=001 break; case 002: // Execute your code if test.php?vid=002 break; } ?> If that's not what you wanted then nevermind... Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279957 Share on other sites More sharing options...
VHPirie Posted June 22, 2007 Author Share Posted June 22, 2007 thanks heaps mate, that works bloody great! Here's the final working page if anyone else is interested. thanks again to chronister and CrazeD for ur time and effort helping me out! Now I'll go and add more vids and adapt it to suit my website. <?php switch ($_GET['vid']) { case 001: $vid_title = 'VH Exhaust'; $vid_id = 'oPtuYU0hxEA'; $vid_desc = 'Video Description'; break; case 002: $vid_title = 'VH Wags Burnout'; $vid_id = 'NS5qg7O8doQ'; $vid_desc = 'Video Description'; break; } echo " <b>$vid_title</b><br> <br> <object width=425 height=350> <param name=movie value=http://www.youtube.com/v/$vid_id></param> <param name=wmode value=transparent></param> <embed src=http://www.youtube.com/v/$vid_id type=application/x-shockwave-flash wmode=transparent width=425 height=350></embed> </object><br> <br> $vid_desc<br> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279964 Share on other sites More sharing options...
CrazeD Posted June 22, 2007 Share Posted June 22, 2007 No problem. Quote Link to comment https://forums.phpfreaks.com/topic/56517-solved-need-a-bit-of-help/#findComment-279965 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.