can someone explain what this code trying to do?? expecially this line $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='$myfilmurlstr' size='72'>"; <?php include("../../includes/config.php"); mysql_connect($db_address, $db_username, $db_password); mysql_select_db($db_name) or die(mysql_error()); $fid = $_GET['fid']; $fid = mysql_real_escape_string($fid); $query4 = "SELECT * FROM films WHERE (film_id = '$fid')"; $qry_result4 = mysql_query($query4) or die(mysql_error()); while($row = mysql_fetch_array($qry_result4)) { $myfilmurlstr = "http://www.onfilm.biz/streaming/home/$row[film_client]/$row[film_client_office]/$row[film_filename].mp4"; $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='$myfilmurlstr' size='72'>"; } mysql_close(); //EDIT 290510 echo $display_string4;?> PHP:
<?php include("../../includes/config.php"); PHP: Get the config file with all the passwords etc in it. mysql_connect($db_address, $db_username, $db_password); mysql_select_db($db_name) or die(mysql_error()); PHP: Connect to the database and if you can't for some reason quit everything. Don't try to continue. $fid = $_GET['fid']; $fid = mysql_real_escape_string($fid); PHP: This page will have been called from a form or perhaps a url with ?fid=234 in the url. These are called $_GET variables. If the url will have any chance to be tampered with (ie doesn't exist in your own admin system or something where the circle of trust is absolute) then it pays to do a security check on the field. Security is an ongoing problem and the best way to do it will vary. Id fields can be converted to integers and checked that they are >0. $query4 = "SELECT * FROM `films` WHERE (`film_id` = '{$fid}')"; PHP: Creates a query that will be sent to the database. As an example of good practice I've added some extra bits. $qry_result4 = mysql_query($query4) or die(mysql_error()); PHP: Run the query and return a result set that can be worked on. while($row = mysql_fetch_array($qry_result4)) { PHP: Loop through the results until there are none left $myfilmurlstr = "http://www.onfilm.biz/streaming/home/{$row[film_client]}/{$row[film_client_office]}/{$row[film_filename]}.mp4"; PHP: Create a url based on the data that is returned from the database... only it wouldn't work as is so I've added some bits to make the string get created properly. I'll leave you to play spot the difference $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='{$myfilmurlstr}' size='72'>"; PHP: Create an html input field that can be echo'd out later when the main form is created. } mysql_close(); //EDIT 290510 echo $display_string4;?> PHP: Finish the loop, close MySQL and for some reason do the echo here. You will also get issues if $display_string4 isn't initialised. PHP lets you create variables on the fly but in this code you are appending it using .= and you'll get errors if there is no existing value. $display_string4 = ''; is all that is needed.
Thank you very much. Just have another question is it possible that i can grab that url value from either way $myfilmurlstr = "http://www.onfilm.biz/streaming/home/{$row[film_client]}/{$row[film_client_office]}/{$row[film_filename]}.mp4"; PHP: or $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='{$myfilmurlstr}' size='72'>" PHP: and send it to another page. i tried to replicate the same script into another page and then just echo like <?php echo $stream="http://www.onfilm.biz/streaming/home/{$row[film_client]}/{$row[film_client_office]}/{$row[film_filename]}.mp4"; ?> PHP: or <?php echo $client; ?> PHP: but it never show me the value of the url. this how i tried index.php <?php include("../../includes/config.php"); mysql_connect($db_address, $db_username, $db_password); mysql_select_db($db_name) or die(mysql_error()); $fid = $_GET['fid']; $fid = mysql_real_escape_string($fid); $query4 = "SELECT * FROM films WHERE (film_id = '$fid')"; $qry_result4 = mysql_query($query4) or die(mysql_error()); while($row = mysql_fetch_array($qry_result4)) { $myfilmurlstr = "http://www.onfilm.biz/streaming/home/$row[film_client]/$row[film_client_office]/$row[film_filename].mp4"; $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='$myfilmurlstr' size='72'>"; } mysql_close(); //EDIT 290510 echo $display_string4;?> //echo <?php echo $myfilmurlstr ; ?> PHP: but doesnt display the data how can i get to show me the data
I'm assuming you called it with a ?fid=234 type of thing $row[film_client] really needs to have {} around it. Arrays inside a string don't always turn out the way you expect. Add in some basic debugging such as var_dump($myfilmurlstr); or echo $myfilmurlstr; I often put echo '<hr>'; after a var_dump if I have a few of them just so that they're easier to read. If they get really messy view the source where its laid out nicely. In this case that won't be necessary.
You might be right but i don't think i've actually lay out my problem propelly this my issue I have a the following site http://www.estateagentsonfilm.co.uk/tv/bellway/indextest.php# the site uses a jwplayer and php to load the video into the player this how the php load the video into the player the full script bellow but this the line that loads the $efilm="http://www.onfilm.biz/streaming/home/".$client."/".$client.".mp4"; and on the player i'll have the <?php echo $efilm; ?> Now this is the first movie the player picks up but what i am trying to figure out is when you click a different propriety from the link above it plays a different video what i wanted to know how is that that video gest load into the player when i only have the first video onto the player which is <?php echo $efilm; ?> i do have other files but they written in ajax which which i don't really understand if anyone here understand ajax i can send all three files to have a look if possible thanks in advance ?php $playme = "true"; ?> <?php // $playme=1; if($efilm=="") { $efilm="http://www.onfilm.biz/streaming/home/".$client."/".$client.".mp4"; } else { // nothing } ?> include("../../includes/config.php"); //connect to DB $connectionci = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT."); $dbci = @mysql_select_db($db_name, $connectionci) or die("Couldn't select DATABASE."); //SELECT All based on current cookie Information $queryci="SELECT * FROM clients WHERE (client_company = '$client')"; $resultci = mysql_query($queryci) or die("Couldn't execute QUERY."); while ($rowci = mysql_fetch_array($resultci)) { $client_name = $rowci[client_company_name]; $client_addr_01 = $rowci[client_address01]; $client_addr_02 = $rowci[client_address02]; $client_addr_city = $rowci[client_city]; $client_addr_county = $rowci[client_county]; $client_addr_postcode = $rowci[client_postcode]; $client_addr_telephone = $rowci[client_telephone]; $client_addr_email = $rowci[client_email]; $client_url = $rowci[client_url]; } mysql_close($connectionci); ?> <script type="text/javascript" src="../jwplayer/jwplayer.js"></script> <script type="text/javascript"> jwplayer("mediaplayer").setup({ 'flashplayer': '../jwplayer/player.swf', 'id': 'playerID', 'width': '640', 'height': '360', 'file': '<?php echo $efilm; ?>', 'skin': '../jwplayer/glow.zip', 'dock': 'false', 'viral.oncomplete': 'false', 'hd.state': 'false', 'viral.allowmenu': 'false', autostart: true, 'plugins': { 'hd-1': { file: '<?php echo $stream="http://www.onfilm.biz/streaming/home/$row[film_client]/$row[film_client_office]/$row[film_filename].mp4"; ?>' } } }); var player = null; function playerReady(obj) { player = document.getElementsByName(obj.id)[0]; } function loadNplay(file) { if(player!=null){ player.sendEvent('LOAD', {file:file, type:'video'}); player.sendEvent('PLAY', 'true'); } } function playerStart(file) { player.sendEvent('PLAY',true); } function playerStop(file) { player.sendEvent('STOP'); } function playerPause(file) { player.sendEvent('PLAY',false); } </script> <script> //call after page loaded window.onload=function(){ ajaxFunction1(); setTimeout("createPlayer()",2000); } </script> PHP:
Are we copying their functionality or maintaining it? Either way you need to be using firefox and have firebug installed. That tells me that when I select something from the dropdown a call to http://www.estateagentsonfilm.co.uk...client=BELLWAY&office=WEST MIDLANDS&sortby=lh is made. From the url I can see $_GET['client'] = 'BELLWAY'; $_GET['office'] = 'WEST MIDLANDS'; $_GET['sortby'] = 'lh'; Now it actually makes 2 calls per request. The first seems to reload the entire page, only it doesn't, and I wonder if it is in fact failing and when it fails the script thinks it has to generate the whole thing. The second time you get that <input field. Is there an observe form somewhere that is looking for that input to suddenly exist? All a bit odd, I'm afraid. Someone else might know more than me.
Thanks for the help! why is that when i try to do same query on different pages one queries from the database but the other one doesnt retrieve the data from the database readopropertyvideo.php script <?php include("../../includes/config.php"); mysql_connect($db_address, $db_username, $db_password); mysql_select_db($db_name) or die(mysql_error()); $fid = $_GET['fid']; $fid = mysql_real_escape_string($fid); $query4 = "SELECT * FROM films WHERE (film_id = '{$fid}')"; $qry_result4 = mysql_query($query4) or die(mysql_error()); while($row = mysql_fetch_array($qry_result4)) { $myfilmurlstr = "http://www.onfilm.biz/streaming/home/$row[film]/$row[client_office]/$row[filename].mp4"; $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='$myfilmurlstr' size='72'>"; } mysql_close(); //EDIT 290510 echo $display_string4;?> PHP: result correct readopropertyvideo.php url shows correct http://www.onfilm.biz/streaming/home/film/clientoffice/filename.mp4 now i tried a similiar on script on the indextest it only shows but when i try put the script on the indextest.php it doesnt query from the database its shows http://www.onfilm.biz/streaming/home///.mp4 <?php include("../../includes/config.php"); mysql_connect($db_address, $db_username, $db_password); mysql_select_db($db_name) or die(mysql_error()); $fid = $_GET['fid']; $fid = mysql_real_escape_string($fid); $query4 = "SELECT * FROM films WHERE (film_id = '{$fid}')"; $qry_result4 = mysql_query($query4) or die(mysql_error()); while($row = mysql_fetch_array($qry_result4)) { $myfilmurlstr = "http://www.onfilm.biz/streaming/home/$row[film]/$row[client_office]/$row[filename].mp4"; $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='$myfilmurlstr' size='72'>"; } mysql_close(); //EDIT 290510 echo $display_string4;?> PHP: