Jump to content

alecks

Members
  • Posts

    80
  • Joined

  • Last visited

    Never

Everything posted by alecks

  1. http://ffmpeg-php.sourceforge.net/ http://ffmpeg-php.sourceforge.net/apidoc.php It looks pretty simple $movie = new ffmpeg_movie(String path_to_media, boolean persistent); $height = $movie->getFrameHeight(); $width = $movie->getFrameWidth(); ffmpeg-php needs to be installed, though.
  2. I don't think that is possible; as said above sessions are only open as long as the user's browser is. 'Remember me' features generally use cookies to start a user's session again.
  3. you really need to tell us A LOT more about what you want to do, why you want to do it, what you have available to you... trying to answer your question 'how to implement american express in my site?' would be a waste of time
  4. If there are multiple rows of data, then you need to use the while loop.
  5. If you know there is only one row that you are getting (if query is something like '.... WHERE `id` = [specific id]', or you know for certain that your table only has one row) then you can just do $result = mysql_fetch_array(mysql_query("SELECT * FROM `details`")); echo $row['FirstName'] . " " . $row['LastName']; echo "<br />"; otherwise you need the while() to loop through all the rows.
  6. print $result and see what it comes out with, it is probably returning (I think your query is incorrectly formatted) $sql = "SELECT * FROM `books` WHERE `id` = '$id'"; $result = mysql_query($sql);
  7. adding the [] makes it an array, in which case you cant subtract whole arrays at a time (you'd have to do it one value at a time) or arrays from strings, et cetera. $timediff = $timenow - $date[0]; Probably would have worked as well if you wanted it to be an array
  8. I'm not really quite sure what you are trying to do, could you explain a bit more?
  9. There is no easy way to do this (I don't think php has any built in functions to handle video files); you need to install the ffmpeg-php extension, with which you can do this sort of stuff... once it is installed if you want to get say, the middle frame, you'd do something like $frame = new ffmpeg_movie("/path/to/movie",0); $frame->.5*getFrameCount(); $frame->getFrame($frame); ... rest of the stuff to resize and save $frame as a thumbnail. because your host said he won't install sql, I doubt they'd install ffmpeg-php...
  10. I just did this really quickly, hope it helps <?php echo "<form action=\"test.php\" method=\"post\">" ."<textarea name=\"origdata\">".$_POST['origdata']."</textarea>" ."<br /><input type=\"submit\" value=\"convert\" />" ."</form>"; echo "<textarea name=\"origdata\">"; if (isset($_POST['origdata'])){ $return = preg_replace('/(\\s){2,}/', '$1', $_POST['origdata']); $return = explode(" ", $return); } foreach ($return as $piece){ echo $piece + 20; echo " "; } echo "</textarea>"; ?>
  11. I was wondering: If I've only got one database that I need to use, would it be better to simply mysql_connect at the beginning of the script and stay connected until the end, or connect each time I need to query? I was doing it the latter way, here is the function that I was using... function basic_query($query){ mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $result = mysql_query($query) or die(mysql_error()); mysql_close(); return $result; } The returned $result could then be used in a fetch array loop, etc... Is there a better way to do this?
  12. How do I query the database to select all the data from say, March 2007? There is a "date" column Thanks
  13. Ha! This is so weird! I was just working on something like this. I ended up using AJAX. in the <head> of your website, add <script language="javascript"> http = getHTTPObject(); function getHTTPObject(){ var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(E){ xmlhttp = false; } } @else xmlhttp = false; @end @*/ if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){ try { xmlhttp = new XMLHttpRequest(); }catch(e){ xmlhttp = false; } } return xmlhttp; } function loadPage(page){ var url = page + ".php"; http.open("GET", url, true); http.onreadystatechange = handleHttpResponse; http.send(null); } function handleHttpResponse(){ if(http.readyState == 4){ document.getElementById('content').innerHTML = http.responseText; } } </script> That's basically all AJAX has to it. It's really not as hard as it sounds Now, create a PHP script that outputs the content of what you want each page to have in plain text. Change "var url" under "function loadPage" in the script above to the location of this PHP script. (So, if, for example, the content is fetched from a sql database, have a php script that does that in a different file.) Also, change this document.getElementById('content').innerHTML = http.responseText; in the handleHttpResponse function to whatever <div> that you want the page to load in. Now, on your site, have the navigation links look like this: <a href="javascript:loadPage('THE PAGE YOU WANT TO LOAD MINUS THE .PHP')">The Link</a> That should work Example files: <?php // Script.php echo "This is the content of the page that I want to load asynchronously so that I don't have to reload the flash header everytime."; ?> The website index. (index.html) <html> <head> <title>This is a simple page</title> <script language="javascript"> http = getHTTPObject(); function getHTTPObject(){ var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(E){ xmlhttp = false; } } @else xmlhttp = false; @end @*/ if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){ try { xmlhttp = new XMLHttpRequest(); }catch(e){ xmlhttp = false; } } return xmlhttp; } function loadPage(page){ var url = page + ".php"; http.open("GET", url, true); http.onreadystatechange = handleHttpResponse; http.send(null); } function handleHttpResponse(){ if(http.readyState == 4){ document.getElementById('content').innerHTML = http.responseText; } } </script> </head> <body> <h1>This is my website</h1> <div id="flash_header" style="width:500px;height:100px;padding:10px;margin:10px;">Pretend flash header.</div> <div id="navigation"><a href="javascript:loadPage('script')">This is a link to the page I want to load asynchronously</a> into the div CONTENT.</div> <div id="content">The content output by script.php will be put here.</div> </body> </html> You get the idea. With a little imagination and better programming you can get some pretty good results. You can do alot more stuff than what you can do with iframes. (plus, it's compliant unlike iframes).
  14. I am pretty sure that even if they did download the .php file all they would get would still be the HTML resulting from that script also, though that .htaccess works fine, you could also just chmod the folders so that ordinary uses can't access the files.
  15. PHP is server-side, which means that the code is executed on the server's side. A person browsing your website cannot see any of the PHP code in the website's source (View > Page Source). This is the basic flowchart: PHP File -> Interpreted by the server Server, which -> spits out HTML code to the user.
  16. I think, IP may be the only way to go :-X As far as I know, cookies and sessions are kept separate (IE's cookies and sessions are separate from FF's cookies and sessions). So that rules that out. What else is there? - Looking for login patterns? This would be a problem if your site grows to the point that many people are logging in all the time at random times. - Checking IP addresses As you said, this could be a problem for those who share IP addresses. Ah! Maybe you could combine looking for login patters and IP addresses? Ex. if some one logs in from a school at 10:30, and someone else at 10:31, then it's likely that they are the same person. But if someone from one IP address logs in at 10:30, and the other 5 hours later, then it's likely they are not the same person! Then again, this also could cause many problems (what if the people who log in at 10:30 and 10:31 are different people, but friends?). There's also the coding aspect, I imagine it would be a bit more complicated. Yes, I think IP may be the only solution. You could also try making it inconvenient for the user to make two+ different accounts. You probably already have this, but you could do things such as allowing only one email to one username, or having them enter extra details such as name, etc.
  17. I want to do something like this" $name = "test"; if (function_exists (".$name."_function"){ $name."_function"(); } Basically, the prefix of the name of the function will be in a variable, and I want to use that to call a function. This may seem like a long way around to something, but I have reasons. Please don't give me a run around and tell me to do it another way, I'd just like to know if it can be done Thanks for any help, its very appreciated.
  18. Umm... not sure what you are trying to do here, but I am guessing that you want to have a forum, and in this forum separate boards. I am going to spell this out as detailed as possible. Ex, the forum structure: YOUR FORUM (1) General (2) Another (3) Another Board If the URL is "index.php", then it would show main(), which is just a listing of these boards. If $oid is set ("index.php?$board=board&oid="), then it would do board($oid), and board() would display the forum board that corresponds to $oid. Ex. If $oid was 1 then based on the example forum structure above board() would display the General forum. Am I right so far? You really don't need the $board variable, based on what I'm seeing. Your code, based on this, may look something like this in the end: include_once("config.php"); function main() { global $whatever_vars_from_config_you_need if (checkLoggedIn("yes")){ doCSS(); print("Welcome to the members page <b>".$_SESSION["login"]."</b><br>\n"); print("<a href=\"logout.php"."\">Logout</a>"); }else{ print("You are not logged in."); } } function board($oid) { // Code to display the board that corresponds with $oid, probably from a database. Also, tests (checkLoggedIn("yes")) to see if they are logged in or not. } switch($board) { default: main(); break; case "board"; board($oid); break; } [/cODE] Sorry if I can't be more help, but you are being pretty vague :/
  19. As far as I can tell this is a valid reg. expression: ^/\*.*?\*/$ It's ^/*.*?*/$ without the escaping. Basically its looking for (php) quoted out (using /* and */) sections in a string. But when I try to $tc = "/* This is a Test */ tttttttttttttttttttt /* This is another test */ tttttttttttttrrrrrrrrrr"; $r = preg_split("^/\*.*?\*/$", $tc, -1); I get the warning Warning: preg_split() [function.preg-split]: No ending delimiter '^' found in /path/to/file.php on line # Any help?
  20. is there a function that can remove characters from the end of a string, ex $string = abcdefghijklmnop; this_function($string,-3); // abcdefghijklm I know a function sorta like this exists bunt I can't recall it, I'm afraid ): can you help me out, please :3 ?
  21. I want to put the outputs of an include function that is in a basic "fetch while there are still rows" while loop into a variable. ex. while ($result = mysql_fetch_array($query)){ include("post.inc"); } and the contents of post.inc are <h1><?php print $result['row_that_was_fetched']; ?></h1> And say that there were three rows, so the product of this while loop would be <h1><?php print $result['row_that_was_fetched']; ?></h1><h1><?php print $result['row_that_was_fetched']; ?></h1><h1><?php print $result['row_that_was_fetched']; ?></h1> I want to put all of those into a variable, so that $variable = <h1><?php print $result['row_that_was_fetched']; ?></h1><h1><?php print $result['row_that_was_fetched']; ?></h1><h1><?php print $result['row_that_was_fetched']; ?></h1> Is it possible to do this? I'm kinda thinking this: while ($result = mysql_fetch_array($query)){ $variable .= include("post.inc"); } But I don't think it will work because PHP will interpret it as me wanting to define an anonymous function in $variable. Am I correct or am I just crazy? Any help you can give is very appreciated -alecks
  22. I want to retrieve only a certain length of data from an entry in a mysql table, how would I do that? ex. I only want the first 5 letters in the entry "example", so what should be returned to me is "examp". Can I do this with only a mysql query or will I have to use some PHP functions to clip the string, and if it is the latter what functions do I have to use?
  23. Have you checked to see if the permissions are set correctly? see if languages/en_US.php has the same permissions as ja.php
  24. I want to query a table (mysql) and fetch all information from rows starting at a specific row. How would I do this? ex: (rows I want to get info from are bolded) Mysql Table 1 info 2 info 3 info 4 info 5 info 6 info 7 info 8 info 9 info ... etc More specifically, what would the query have to be like? mysql_query(SELECT * FROM `table` WHERE...)
  25. Not adding an element to an array, but adding a string to an element in an array ex. $array = array('x' => 'jorge'); and I would like for "joe" to be added to the "x" element of array $array, so that (at the end of the script) the array will look like this: print_r($array); /* Should output something like Array{[x] => jorgejoe} */ Is there any way to do this, or will I have to work around it?
×
×
  • 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.