Jump to content

BinaryBird

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BinaryBird's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, i am trying to stream a video from Rackspace clould files account. I could simply get the url of the video file and stream the video using the php api they have provided. But they have provided a stream function which they suggest to be used for video streaming or for large images. Here is the code of the api : /** * Streaming read of Object's data * * Given an open PHP resource (see PHP's fopen() method), fetch the Object's * data and write it to the open resource handle. This is useful for * streaming an Object's content to the browser (videos, images) or for * fetching content to a local file. * * Pass in $hdrs array to set specific custom HTTP headers such as * If-Match, If-None-Match, If-Modified-Since, Range, etc. * * Example: * <code> * # ... authentication/connection/container code excluded * # ... see previous examples * * # Assuming this is a web script to display the README to the * # user's browser: * # * <?php * // grab README from storage system * // * $my_docs = $conn->get_container("documents"); * $doc = $my_docs->get_object("README"); * * // Hand it back to user's browser with appropriate content-type * // * header("Content-Type: " . $doc->content_type); * $output = fopen("php://output", "w"); * $doc->stream($output); # stream object content to PHP's output buffer * fclose($output); * ?> * * # See read() above for a more simple example. * # * </code> * * @param resource $fp open resource for writing data to * @param array $hdrs user-defined headers (Range, If-Match, etc.) * @return string Object's data * @throws InvalidResponseException unexpected response */ function stream(&$fp, $hdrs=array()) { list($status, $reason) = $this->container->cfs_http->get_object_to_stream($this,$fp,$hdrs); #if ($status == 401 && $this->_re_auth()) { # return $this->stream($fp, $hdrs); #} if (($status < 200) || ($status > 299 && $status != 412 && $status != 304)) { throw new InvalidResponseException("Invalid response (".$status."): " .$reason); } return True; } Here is the sample code they shared : $output = fopen("test.jpg", "w"); $pic->stream($output); fclose($output); If i echo the $pic variable, it just contains the name of the file. How do i display the image and how do i use this for streaming a video? Iam very new to php, so kindly help me. Thanks.
  2. Tried to change the id. Still not working. It worked perfectly for an other form. Not this one. Not sure why. But that was just a html page. If any one could suggest what could be wrong, would be great. I am basically trying to make sure that a value is entered in the field before the user submits it. Thanks.
  3. I will change the id , thanks for the suggestion. I have tried that with other forms and it worked. Maybe it is due to the id. Anyways let me check. Thanks.
  4. Thanks. I have posted in the JS section. I managed to solve the sessions problem. Thanks again for all the help.
  5. Hi, i am trying to validate a form field using javascript in a php page. But its not working. Here is the code : <?php session_start(); $pvt_id = session_id(); //if(isset($_POST['submit'])) { $_SESSION['name'] = 'Jester'; $_SESSION['id'] = $pvt_id ; //echo $id; //} ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Validation</title> <script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script> </head> <body> <form id="createaccount" name="createaccount" action="register.php" method="post" > ID:<input type="text" name="id" id="id" size="30" value="" /> <input style="width:19em" id="submit" name="submit" type="submit" value='Validate' /> </form> <script language="JavaScript" type="text/javascript"> var frmvalidator = new Validator("createaccount"); frmvalidator.addValidation("id","req","Please enter your ID") frmvalidator.addValidation("id","maxlen=10","Max length for ID is 10"); </script> </body> </html> Please find the js code attached. Am i missing something here? Kindly help me. Thanks. [attachment deleted by admin]
  6. I have solved the session problem. I finally inserted a javascript validation for the id filed. But it doesn work. <?php session_start(); $pvt_id = session_id(); //if(isset($_POST['submit'])) { $_SESSION['name'] = 'Jester'; $_SESSION['id'] = $pvt_id ; //echo $id; //} ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Validation</title> <script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script> </head> <body> <form id="createaccount" name="createaccount" action="register.php" method="post" > ID:<input type="text" name="id" id="id" size="30" value="" /> <input style="width:19em" id="submit" name="submit" type="submit" value='Validate' /> </form> <script language="JavaScript" type="text/javascript"> var frmvalidator = new Validator("createaccount"); frmvalidator.addValidation("id","req","Please enter your ID") frmvalidator.addValidation("id","maxlen=10","Max length for ID is 10"); </script> </body> </html> Is there something i have missed out here? If i click on the submit button with out entering a value in the id field, it should alert me. But it just takes me to the action page. Help me out please. Thanks.
  7. I tried but something is wrong. Could some one tell me how do i read a value from a form sent it as a session variable ? I mean say i have a input field id, is it possible to read the value and set it as a session variable in the same page?
  8. For which if block should i add the exit code? I am sorry but i am new to php. Please help. Or is there any other way to access the register.php page on successfully validating a db entry?
  9. Hi, i am trying to create a registration page. But i want users to access this page only validating their id not be able to access it directly. Say my landing page is home.php , i have a id field here where users can enter their id. I can check if this id exists in the db and if so take them to register.php where they can enter their details . But they should not be able to access the register page directly. A friend of mine tried to help me with this. He is using sessions. Here is the code for the home page <?php session_start(); require_once('connection.php'); if(!isset($_SESSION['id'])) { if(isset($_POST['submit'])) { $id = $_POST['id']; if(!empty($id)) { $query = "SELECT * FROM studentids where usn='".$id."'"; /* Please change the tablename and id column name here*/ $result = mysqli_query($conn,$query); while ($row = mysqli_fetch_array($result)) { $tid = $row['usn']; /* If Column Name is not id then you need to make changes here */ } if($tid == $id) { $row = mysqli_fetch_array($result); $_SESSION['id'] = $id; setcookie('id', $row['id'], time()+(60*60*24*30)); $url = 'http://www.googlewaveindia.com/'; $url .= 'shantanu/apps/register.php'; /*Change the path to redirect into register.php */ header('Location: ' . $url); } else { echo '<p class="error">Sorry,You must enter a valid ID to log in.</p>'; } } else { echo '<p class="error">Sorry,You must enter your ID to log in.</p>'; } } } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Validation</title> </head> <body> <form id="createaccount" name="createaccount" action="register.php" method="post" > ID:<input type="text" name="id" id="id" size="30" value="" /> <input style="width:19em" id="submit" name="submit" type="submit" value='Validate' /> </form> </body> </html> This is not validating. Here is the link : http://www.googlewaveindia.com/shantanu/apps/newgister.php could some one tell me what could be wrong? Thanks.
  10. You have got a point. We cannot let users download the songs unless they purchase them. I will try out the ffmpeg method first. Thanks anyways.
  11. Thanks for the idea paddy. Will try it out.
  12. Thanks for the suggestion. Is it not possible to limit the duration of a mp3 using php? The main problem is that there are more than 100,000 songs. So creating separate clips for all those songs will take up space and if required to do on the fly, it might take up server resources. So thinking if there is a way to extract 30 seconds from a song or limit the duration to 30 sec using php. In any case thanks for your suggestion.
  13. The server has Cent OS 5 running. The option you are suggesting is to trim the song on the fly?
  14. Hello, me a few friends of mine are developing a php-based music store for a client. The client specifically wanted a preview option where by users could listen to the first 30 seconds of a song. All the songs are .mp3's Could any one tell me, if it is possible to trim down a mp3's duration to the first 30 seconds using php? or suggest any player that will limit the clip duration to 30 seconds? We are currently using a xml based flash player to play the songs on the site. There are quite a high number of songs, so creating a short 30 seconds clips would not be ideal. And please forgive me if i have posted the question in the wrong section. Kindly help me out. Thanks in advance.
  15. Not sure why my earlier logic failed. But joins did solve my problem. Thank you all. Here is the final code that worked as intended: <?php $dl = mysql_connect ("localhost","nitin_nick","test1234"); $db = mysql_select_db("nitin_registration",$dl); echo "<table border='0' width='986' align='center' cellspacing='1' cellpadding='5'>"; echo "<tr>"; echo "<th>Team Name</th>"; echo "<th>Team Contact</th>"; echo "<th>Member Name</th>"; echo "<th>Member Email</th>"; echo "<th>Mobile Phone</th>"; echo "<th>College</th>"; echo "</tr>"; $result1=""; $result2=""; $query1 = "SELECT * FROM team "; $q1_set = mysql_query($query1,$dl); while ($result1 = mysql_fetch_array($q1_set)) { $team_id = $result1['id']; echo "<tr>"; echo "<td>".$result1['team_name']."</td>"; echo "<td>".$result1['contact']."</td>"; echo "<td>".""."</td>"; echo "<td>".""."</td>"; echo "<td>".""."</td>"; echo "<td>".""."</td>"; echo "</tr>"; $query2 = "SELECT * FROM team,member WHERE (team.id=member.team_id) AND (team.id={$team_id})"; $q2_set = mysql_query($query2,$dl); while ($result2 = mysql_fetch_array($q2_set)){ echo "<tr>"; echo "<td>".""."</td>"; echo "<td>".""."</td>"; echo "<td>".$result2['member_name']."</td>"; echo "<td>".$result2['email']."</td>"; echo "<td>".$result2['phone']."</td>"; echo "<td>".$result2['college']."</td>"; echo "</tr>"; } } echo "</table>"; ?>
×
×
  • 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.