Jump to content

programming.name

Members
  • Posts

    46
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

programming.name's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, there. Is that bad practice not to have tag Ids except when needed? What about name and class? Are they necessary, and what happen if they don't appear Thanks in advance
  2. Hi, I'm trying to make some kind of image preview. I am currently using native html5 tag output and fileReader object in javascript. It works great with me but my target browser doen't support it. So I decided to go with xmlhttprequest to get this job done. It also works perfectly. My ajax image preview basically does the following: if an user select an image file from local disk, the onselect event fires the javascript function preview(). What it does is first, the file is uploaded to the desired folder, and the image will be displayed with the img tag. And if another file is chosen then the file currently uploaded is removed(in terms of server space) and new chosen image is uploaded to the server. So far so good. But if a tricky user keeps previwing image like 50 times or so, is that still fine? I'm just concerned about server overhead. Is this considered to be "heavy"? File size limit is 3MiB. If is this acceptable approach for normal, good, "tame" users? I need your advice. Thanks.
  3. Hi, Is that possible to implement an effect that F11 key is pressed automatically on load? I mean I'm trying to maximize the window and I don't want to actually resize the window with the window object. I rather to use the keycode to get the same effect as if I press the F11 key manually to "REALLY" maximize the window. (with auto-hide-and-show address bar) I want to return the value of keycode on load and I found that most browsers'(at least my target browsers) value for F11 is 122. So I tried the following: test.html <body onload="return max_win(event)"> test.js function get_keycode(e) { if (window.event) { keycode=event.keyCode; } else { keycode= e.which; } } function max_win(e) { get_keycode(e); return keycode=122; } It does nothing. can anyone fix my problem please? Thanks inadvance.
  4. Hi, Is there an acceptable way to call a method in a class from another class? I have 3 files and 2 classes as below: a.php class a { function func_a() { b::func_b //it is a place where I want to call func_b() and this give me an error } } b.php class b { function func_b() { echo 'I got in!'; } } c.php <?php include("a.php")// or require_once include("b.php")// or require_once $a = new a; $b = new b; ?> <html> <head> </head> <body> <?php $a->func_a(); //I got in! to the display ?> </body> </html> I tried: b::func_b in func_a in class a, it gives the following error: Strict standards: Non-static method b::func_b() should not be called statically, assuming $this from incompatible context in a.class.php on line 12 I can hide thie error using: error_reporting(E_ALL ^ E_STRICT); This is not what I want; I want some "clean code". Is there a way to achieve this? Thanks in advance.
  5. Hi, Please consider the following image: As you can see, there are 4 divs being one big green, "test_div" and 3 small squre divs, "div_1"," div_2", "div_3". All I want to do is trying to trigger some mouse events with these. When the page is loaded, the following function is called and the above divs are basically all hidden: function hide_div() { document.getElementById("test_div").style.visibility = "hidden"; } and whenever the mouse cursor is over them another event is triggered with this function: function show_div() { document.getElementById("test_div")style.visibility = "visible"; } And html code(partial): <div id="test_div" onmouseover="show_div();" onmouseout="hide_div();"> <div id="div_1"></div> <div id="div_2"></div> <div id="div_3"></div> </div> All it does is simply hide-and-show function, but when I actully do that it does't work what I intended; when I put the cursor on "test_div"(green part only) it does show all the 4 divs correctly but as soon as I move the cursor to the one of three square divs(div_1, div_2 or div_3; didn't really matter) all the divs are gone and sometimes it blinks. I figured out that this is because onmouseover="show_div() is only triggered to "test_div" but apart from that I have no idea how to solve this. Pleae help!! thanks.
  6. Thanks for the reply. I mean I need a multiple strings searched with no sequential or single string. if the string given is as below: “In veterinary school we studied the brain of the hippopotamus. At that time most students stayed on the main campus, while I stayed on the hippocampus.” and I enter "campus school(bolded)" at the same time I want it to be true. I think preg_match searches one sting or adjacent strings only. Thanks
  7. Hi, Please see the code below: $string = 'I want to be a PHP geek!'; if (preg_match('/'. urldecode($_GET['no']) . '/i', $string)) //do something issue 1: When I search with parenthesis '(' I got the following error: Warning: preg_match(): Compilation failed: missing ) at offset 1 and with ')': Warning: preg_match(): Compilation failed: unmatched parentheses at offset 0 isseu 2: I want to search letter by letter; please consider the following snippet: $string = 'Do you want to be a PHP geek?'; preg_match('/php want/i', $string) ? $var = 'Cool': $var = 'Noooooo'; I want it to have me the $var "Cool". How can I get it done please? thanks for helping me.
  8. Hi, please consider the following simplified code: function show_ajax_result(str) { var request = new XMLHttpRequest(); request.open("GET", "query/query_search_product.php?sp=" + str + "&nocache="+new Date().getTime() , true); request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=UTF-8;'); request.onreadystatechange = function() { if ((request.readyState != 4) || (request.status != 200)) { return; } document.getElementById("results").innerHTML = request.responseText; } request.send(null); } it works fine with pure English chars and numbers, but when it comes with non-English languages like Chinese, Japanese, Korean, Thai etc., some browser(ie9, ie10) doesn't pass the value to a server correctly. It works great with Chrome 23 and Firefox 16 and even Safari. And all the char values of the server and client are set to utf8. And without sending the data through XMLHttpRequest, query with non-English chars works perfectly. How can I have this solved please? Thanks.
  9. hi, I am using very simple ajax request as below: js file: function show_ajax_result(str) { var timer; clearTimeout(timer); var request = new XMLHttpRequest(); request.open("GET", "result.php?sp=" + str, true); request.onreadystatechange = timer = setTimeout(function() { if ((request.readyState != 4) || (request.status != 200)) { return; } document.getElementById("show_result").innerHTML = request.responseText; }, 400) request.send(null); } result.php: <?php $get = $_GET['sp']; if($get == 'test') echo 'I am here!'; else echo 'I'm not there yet!'; ?> They work perfectly. But as soon as I write the following code the request doesn't respond: $link = new mysqli("localhost", "root", "", "myDB"); I think its got to be something with db but I have no idea. Thanks in advance.
  10. This is somewhat simplifed codes in html. <form id="form" name="form" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" > <input id="image" name="image" type="file" /> <input id="normal_post_var" name="normal_post_var" type="text" /> </form> and in the php file if(empty($_FILES['image']['name'])) $_FILES['image']['name'] = ''; if(empty($_POST['normal_post_var'])) $_POST['normal_post_var'] =''; echo $_FILES['image']['name']; echo '<br />'; echo $_POST['normal_post_var']; When the page is first loaded nothing wil be displayed. Once the page is fully loaded I choose an image file named 'image.png' and I input the value 'It is Cool' in the normal_post_var field. And I submit it and the result of course will be: image.png It is Cool And then I do nothing but clicking the submit button again will display the following: It is Cool the $_files value is gone. could you explain what's going on please?
  11. Hi, there. As far as I know the POST method holds the value if it is submitted consistently. But unlike the POST, $_files does not hold the value all along; when I click the submit button for the first time it DOES hold the value as I want, but if I click the submit once again the value it contains is just gone. Could you explain what's going on and how to prevent this from happening? thanks in advance.
  12. <?php if('00' == '000') echo 'weired'; ?> Please consider the code above. Strangely it echoes the word "weired". Also if('00' == '000000000000000') returns true and so forth. What is really going on? Thanks in advance By the way the php version is 5.3.9 on wampserver 2.2
  13. Hi, Is there a way to stream wide range of video file types like avi, mov, mpg, etc.? What I want to do is to allow users to upload any video files on the server and like wmv extension, I want other file types (especially mpg or mpeg extension) to be played as soon as the page loads. I am running my own server, and so if any server setting is required, I have full control of the server and I have already done with file uploading thing. I only need to implement video file streamming. Thanks.
  14. Please consider the following code: <?php // The file $filename = 'test.jpg'; // Set a maximum height and width $width = 500; $height = 340; // Content type //header('Content-type: image/jpeg'); // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = 500; } else { $height = 340; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output imagejpeg($image_p, null, 100); ?> The code above works fine and also consider the following code which only added the html and body tags at the top and bottom: <html> <body> <?php // The file $filename = 'test.jpg'; // Set a maximum height and width $width = 500; $height = 340; // Content type //header('Content-type: image/jpeg'); // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = 500; } else { $height = 340; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output imagejpeg($image_p, null, 100); ?> </html> </body> The latter code just displays bunch of strange text rather than image itself. How can I solve this problem so that I can see cool images again? Thanks.
  15. Hi, I am thinking of making a very very simple PHP chat application with ajax(for conversation window and keeping track of users' status). What I want is just concepts of the application, especailly the concepts of how to determine user is out of the browser(so the other people know this guy has left the chat room). And also I want to know which method is more used to process this sort of application between db and files. Thanks.
×
×
  • 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.