Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. Well you are using an iframe. Why don't you use the embed tag? http://www.html-reference.com/EMBED.asp you may also want to look into the object/param tags: http://www.w3schools.com/TAGS/tag_object.asp
  2. well based on what you said and the code you posted, I assumed that this line printed the information you get $grabber->draw(); and what you want to do is store what is printed there. Is my assumption incorrect? If so can you reclarify what you wanted
  3. It sounds like what you are looking for is output buffering, and specifically, storing the contents of the buffer into a variable. look into the functions ob_start: http://www.php.net/manual/en/function.ob-start.php and ob_get_contents: http://www.php.net/manual/en/function.ob-get-contents.php it may also be useful to read about ob_end_flush: http://www.php.net/manual/en/function.ob-end-flush.php an example of their usage <?php ob_start(); echo "Hello "; $out1 = ob_get_contents();//$out1 now has hello echo "World"; $out2 = ob_get_contents();//$out2 now has world ob_end_flush();//this ends output buffering and prints whats in the buffer to the screen //alternatively, if you didnt want to output what was in the buffer, use ob_end_clean() ?>
  4. You may be going over the max execution time. What exactly happens? is there an error, or does the script inexplicably stop executing? Do you have error reporting turned on?
  5. It could be one of many things. What exactly is happening? Is your condition true or false? Just posting code and asking why it doesn't work won't get you an answer. What does url have in it? Try echoing it to see it has the value you expect
  6. are you getting a mysql error? Can you post it and the query that is giving you problems
  7. Ok. think about what you are asking for a minute, and what information you have given us. No one here knows what you want to insert, what your database table looks like, what information needs to go into it, etc. How can you expect us to help you if all you do is show us a for loop and say "I want to insert something, halp!". What do you expect us to tell you? If you are looking for a tutorial on mysql inserts, there is one here: http://www.tizag.com/mysqlTutorial/mysqlinsert.php But without more information, we really can't help you
  8. um, use a foreach loop? $array = array(some stuff in here) foreach ($array as $value) { echo $value . "<br />"; } or you could just use print_r print_r($array);
  9. you are inserting the string NULL into the id column, which I assume is of type int. Since you seem to want to pass NULL into it, I assume its some sort of primary or unique key that auto increments. If so, you can just leave it out of the INSERT query and it will be automatically generated. For example $menu = MYSQL_QUERY("INSERT INTO adminnews (name,date,message)". "VALUES ('$name', '$date', '$message')"); if that is still giving you trouble, you can try showing the mysql error if there is one like so $menu = MYSQL_QUERY("INSERT INTO adminnews (name,date,message)". "VALUES ('$name', '$date', '$message')"); or die (mysql_error());
  10. OK, this is pretty well documented so it should kind of explain itself. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="jquery.js"></script> </head> <body> <script type="text/javascript"> function slideSwitch() { //select the active image var active = $('#slideshow IMG.active'); //select the next image in line var next = active.next(); next.addClass('active'); active.removeClass('active'); //active.css("display", "none");//hide the inactive one //next.css("display", "inline");//show next one //this adds some simple animation. comment out next to lines, and uncomment previous lines if you want to just active.fadeOut("slow"); next.fadeIn("flow"); } $(function() { //variable to set how fast to switch in seconds secs = 1//set this to how many secs you want //this sets the slideSwitch() function to run every secs seconds setInterval( "slideSwitch()", secs * 1000 ); }); </script> <?php $path = "images/";//path to the directory with the images change this to your path //this script assumes the directory has nothing but images //which will allow us to simply select everything in the directory $images = glob($path."*.*"); //now we basically put all our images echo "<div id='slideshow' >"; foreach($images as $key=>$image){ if ($key == 0){ //here we just show the image echo "<img src='".$image."' class='active' />"; } else { //here we echo the image, but set it to display none style so it wont be rendered echo "<img src='".$image."' style='display:none' />"; } } echo "</div"; ?> </body> </html> But It basically gets the images in an array, outputs them into a div with an id of slideshow, and the javascript switches each image. However, this is a very simple script. It goes through all the images and once it gets to the end, the screen is blank. As for learning, PHP is actually a pretty good place to start, assuming you know HTML HTML intro: http://www.tizag.com/htmlT/ PHP Intro: http://www.php.net/manual/en/intro-whatis.php let me know if you have further problems
  11. hmm well are you sure the file you are trying to upload is making it to the tmp directory? try adding if (!is_uploaded_file($_FILES['file']['tmp_name'])){ echo "File failed to upload"; } before your move_uploaded_file() line
  12. PHP won't be able to change the image without some user interaction (IE hitting a next button or something). To have the images changed on the fly without the user doing anything, you would need some kind of client side code, like javascript. The Jquery library would make this process fairly simple if you wanted to learn about it. Jquery intro: http://docs.jquery.com/How_jQuery_Works Javascript Intro: http://www.tizag.com/javascriptT/ But i'm feeling generous today. I'll see if I can whip up something for you real fast. Give me a few minutes.
  13. you will need to keep track of the last character you output, and if the current character to be output is the same, then you dont output it. Something like //var will keep track of the last value of chr($i) $lastVal = "";//set it to an empty string at the beginning for($i = 65; $i < 91; $i++) { foreach (glob("{".chr($i).",".chr($i+32)."}*", GLOB_BRACE|GLOB_ONLYDIR) as $directoryname) { //here we have a condition that decides if we output the chr($i) | part echo ($lastVal != chr($i)) ? chr($i)."| " : " "; //3 spaces so it looks even echo $directoryname; //now we update our lastVal variable to the current on generated $lastVal = chr($i); } } hope this helps
  14. A quick google search would have probably helped you quicker, but the following may be a good start http://code.google.com/apis/customsearch/v1/overview.html
  15. is there a reason you are using 2 forward slashes in the filepath here: $result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload//" . $_FILES["file"]["name"]); Not sure if this is giving you an error, but this may be leading to unexpected results
  16. The purpose of what this code is doing is kind of unclear, but the reason you have splitting at unfortunate places is because of how you position the split. You basically split the string at an arbitrary and meaningless position. You use $var, which is the arbitrary middle of the string (which you may want to cast as an int btw, as you will have decimal values for strings with an odd length) added to the position of the "</p>" tag. I'm not sure why you do this, but depending on the value of article (and if it will have a value that is expected, or a dynamic calue from a database based on user input or something) you could easily have the string split at inconvenient places. What exactly are you trying to accomplish here?
  17. you can use the fread() function to read the data from a file, and store the binary data in your database (assuming your database is set up correctly). Try reading through this tutorial which details storing file data in a database with php: http://www.devarticles.com/c/a/MySQL/Blobbing-Data-With-PHP-and-MySQL/
  18. well file() returns an array with all the lines of the file. So if we do this $lines = file("path/to/file.txt"); $lines would contain all the lines from the text file. Because its an array, we can use the foreach loop to go through each of the lines easily. For example foreach($lines as $line){ //do something with them } explode will basically split up a string into an array of the pieces, based on some delimiter. so for example $str = "190.0.0.0 - 190.255.255.255"; //the delimiter is " - " since we just want the two ips $pieces = explode(" - ", $str); $firstPart = $pieces[0];//the low end of the range is the first index of the array $secondPart = $pieces[1];//the high end of the range is the second index of the array So, to put it all together $lines = file("path/to/file.txt"); //get the lines from the text file foreach($lines as $line){//loop through each of the lines //explode the line to get the two pieces of the string $pieces = explode(" - ", $line); //store the first part $firstPart = $pieces[0]; //store the second part $secondPart = $pieces[1]; }
  19. im assuming this if statement if ($query1) { is the condition you want where its true if there are rows returned from $query1, and false if there are no rows returned. If so, use mysql_num_rows(). this returns the number of rows returned from the query. for example if (mysql_num_rows($query1) > 0) {//if there is 1 or more rows returned hope this helps
  20. well code working is probably the most important thing, but code making sense is also very important. Imagine writing this code that, although it works, is all over the place and not documented well. You set it up, and forget it, and it inexplicably breaks some time down the line. Its very difficult to go through nonsensical code, especially if you haven't looked at it for a while. OOP doesn't really magically make your code make more sense, but it does a great job of separating things out a bit. Like for example, if you have a forum, you could have a page object, a user object, and a thread object. If something breaks with some sort of user functionality, you will know that the problem lies in the user object, and so on. PHPfreaks has a pretty nice tutorial on OOP, you can read it here.
  21. its because of this line in your newTemplate class $asf->_template = $template; that is essentially overwriting your asf objects data member as the string 'default'. So after you call your set template function, your asf objects data member _template is no longer a newTemplate object, but a simple string. Now how you would get around this is something i am unsure of. Your setTemplate function seems to expect a newTemplate object, rather than a string, but beyond telling you to pass a newTemplate object, since i'm not sure what function that object is supposed to fulfill, i can't really give you a definite answer. However, there are a few conceptual issues with your setup. First of all, your mutator setTemplate uses a global variable. This is bad practice, since one of the main draws of OOP is encapsulation. Encapsulation is a concept that basically says that objects are discrete things, in which the objects data only interacts with outside data through function arguments (like through a mutator), and otherwise outside data stays out, and inside data stays in, unless formally requested (like through an accessor). By using a global variable, you kind of make encapsulation pointless. Secondly, this method seems better suited to be in the asf object, as all it does is change a data member in the asf object. Currently, if you wanted to make use of this object, you have strict requirements, like using the variable name $asf. I realize this is just an example, but these kind of concepts are important. The same kind of stuff goes for getTemplate. get/setTemplate are basically an accessor/mutator for the asf class, but are inexplicably in the newTemplate class.
  22. well without more code to look at we can't really give a definitive answer. Is that if statement inside a loop? What is it part of? What is your script actually doing? Just saying "I'm getting an error, halp", makes it hard for us to help me. Oh, and if you are gonna post more code, please don't post the entire, 1000+ line script. just post the relevant code (like if its part of a while loop, post just the while loop)
  23. No. The database has nothing to do with the file structure, which is the problem. What you need is is_dir() and mkdir(). is_dir will check if a directory exists, and mkdir will make a directory. All you would need is a simple if statement to check if the directory you are trying to put an image in exists, and if not make it, before you use move_uploaded_file(). FOr example if (!is_dir("members/$id/")){ //means the directory we will try to put image in doesnt exist //make it mkdir("members/$id/"); } //now we can proceed with the rest of the upload script Hope this helps
  24. What exactly happens when you try this? An error? blank page? do you have error reporting set up? put the following code at the top of your page to turn it on ini_set('display_errors',1); error_reporting(E_ALL); report back with more information please. Posting some code, and saying "It doesn't work, HALP" makes it difficult for us to help you
×
×
  • 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.