Jump to content

NLCJ

Members
  • Posts

    129
  • Joined

  • Last visited

    Never

Everything posted by NLCJ

  1. The Chrome inspector - or whatever it's called - helped me a lot. It seems I forgot a ")", what caused all scripts to fail within those tags (I guess that makes sense?). Now the only thing that isn't working is changing the href. But I think I will figure something out, I will keep you guys updated.
  2. JavaScript is now acting really weird, I've got no clue what happened but no script works anymore... Even the scripts that I didn't modify! I've set it like: function verifyfile() { var ext = $('#file').val().split('.').pop().toLowerCase(); if($.inArray(ext, ['avi','mpg','mpeg','wmv','mov','vob','flv']) != -1) { document.getElementById('errorextension').style.display="none"; document.getElementById('uploadbutton').style.display="block"; } else { document.getElementById('errorextension').style.display="block"; document.getElementById('uploadbutton').style.display="none"; } } function uploadfile() { document.getElementById('uploadform').style.display="none"; document.getElementById('processing').style.display="block"; setTimeout(uploadstarted(),10000); } function uploadstarted() { document.getElementById('uploadprogress'.style.display="block; document.getElementById('processing').style.display="none"; } verifyfile() is called when the file is changed in the form, it worked fine until now. Now nothing works, even though I didn't touch that part... Does anyone know what happened or how I can solve this? I'm pretty new in JavaScript, maybe it's a silly mistake or so...
  3. I can't get it to work. I've set it like this: iFrame code: <iframe name="uploadprogress" id="uploadprogress" style="display: none; border: none; width: 100%; height: 300px;" src="about:blank"><p>Your browser doesn't support iFrames...</p></iframe> JavaScript code: function uploadfile() { document.getElementById('uploadform').style.display="none"; document.getElementById('uploadprogress').style.display="block"; window.uploadprogress.location.href="uploadprogress.php?id=test"; } Like before, the style.display works, but the window.uploadprogress doesn't...
  4. Hello, I got a HTML form where users can upload a file. Since these files can be pretty big (about 4-5GB) I thought I would let JavaScript verify it so they don't waste time for an error (ofcourse I still got a backend verification). What I did is: I added an onchange="verifyfile()" to the file part of the form. And I made (with the help of Google ) this JavaScript: function verifyfile() { var ext = $('#file').val().split('.').pop().toLowerCase(); if($.inArray(ext, ['avi','mpg','mpeg','wmv','mov','vob','flv']) == 1) { document.getElementById('errorextension').style.display="none"; document.getElementById('uploadbutton').style.display="block"; }else { document.getElementById('errorextension').style.display="block"; document.getElementById('uploadbutton').style.display="none"; } } It works fine if I, e.g. start with an .avi file and after that I get a .rar file. First I don't get the error message, and after that I get the error message. However, it doesn't work the other way around. If I first do a wrong extension the button disappears and the error comes up, but if I change it to the right extension nothing happens. I'm kinda lost and new in JavaScript so... Regards,
  5. Somehow, this still isn't working. I set the default src to "about:blank", is this a problem?
  6. Hello, I've been creating an upload script, and it's going great so far after big problems. But now the final touch... I want to change the src of an iframe when the button is pressed. I got this: function uploadfile() { document.getElementById('uploadform').style.display="none"; document.getElementById('uploadprogress').style.display="block"; document.getElementById('uploadprogress').src="uploadprogress.php?id=test"; } The .style.display part works fine. The iframe is being displayed, however the URL is not changed... Am I doing something wrong?! What?!
  7. I found the problem, I think. When I couldn't solve it I was searching for the original docs of this extension. After a few broken links I found the examples at: http://svn.php.net/viewvc/pecl/uploadprogress/tags/RELEASE_1_0_1/examples/ Copying and viewing those resulted in a page with the information about the current settings. A few of those are: I was aware of the max filesize of 50M, so I uploaded files around 40M. Due to the post_max_size being 8M it wouldn't return any information. So I tried a 6M file with the example script, and it resulted in the wanted results!
  8. The form gets an unique id, just for testing I set it manually: <input id="UPLOAD_IDENTIFIER" name="UPLOAD_IDENTIFIER" type="hidden" value="12345" /> This field will tell the extension uploadprogress that the identifier for this upload is 12345. Then you should be able to get it by using filename.php?id=12345: <?php print uploadprogress_get_info($_GET['id']); ?> However, it seems that no data is being made using this extension. I got no clue... Once I figured it out I will post it here.
  9. Seems that no-one can help me. I will take a look at APC, and see if that works. I will keep you guys up to date.
  10. Hello, I've been trying to create a progress bar for the past 3 days, but I can't get it to work. I've got my own dedicated server with cPanel on it, using cPanel I installed the PECL extension. However, it doesn't respond to anything. The script I'm using is: HTML code: <form id="uploadform" enctype="multipart/form-data" method="post"> <input id="UPLOAD_IDENTIFIER" name="UPLOAD_IDENTIFIER" type="hidden" value="12345" /> <input id="ulfile" name="ulfile" type="file" /> <input type="submit" value="Upload" /> </form> To request the information I made another page with: <?php print uploadprogress_get_info($_GET['id']); ?> Nothing is returned however, no error, nothing... I'm totally lost! Regards,
  11. Nevermind, I've rewritten it: <script type="text/javascript"> function show(box){ document.getElementById(box).style.visibility="visible"; } function hide(box){ document.getElementById(box).style.visibility="hidden"; } </script> <img onmouseover="hide('amenu'); show('dmenu');" src="navigate.png" width="180" height="30" id="amenu" style="visibility: visible;" /> <div id="dmenu" onmouseout="hide('dmenu'); show('amenu');"> Works fine.
  12. Hello, I'm trying to hide and show something if it's shown (on mouseover) and vice versa when the mouse goes over the other div. However, it doesn't work (anymore). I've got no idea what happened. I changed something and it didn't work anymore (I tried CTRL + Z, didn't work). function menutop(hide, show){ var hide = document.getElementById(hide); if(hide.style.visibility == 'visible') { hide.style.visibility = 'hidden'; } if(hide.style.visibility == 'hidden') { hide.style.visibility = 'visible'; } var show = document.getElementById(show); if(show.style.visibility == 'visible') { show.style.visibility = 'hidden'; } if(show.style.visibility == 'hidden') { show.style.visibility = 'visible'; } } HTML code: <img onmouseover="menutop('dmenu', 'amenu')" src="button.png" width="30" height="30" id="amenu" style="visibility: visible;" /> <div id="dmenu" onmouseout="menutop('amenu', 'dmenu')" style="visibility: hidden;"> Thank you,
  13. NLCJ

    MySQL queue

    Okay, but what if ID is the primary key? This is also auto_increment. How do I fix this? Is there another way besides setting name as primary key? Thanks
  14. NLCJ

    MySQL queue

    Okay, I've been away for a while but started yesterday again. I'm working on inserting with multiple values, but what if it already exists? Then it got to update it... So I was looking for 'ON DUPLICATE UPDATE', but have no clue... How would I do it if I have multiple values? INSERT INTO foo (name,variable) VALUES ('apple','".$variable."'), ('banana','".$variable."'), ('pear','".$variable."') ON DUPLICATE KEY UPDATE variable='".$variable."' Would this work / will it update the right row?
  15. Going to test that out, another thing learned! Thanks!
  16. NLCJ

    MySQL queue

    Currently I'm converting the database, and I already figured that INSERT INTO 'trick' out, and successfully modified that part (I have to admit it looks way better now). But I don't understand the first part of your post, can you give an example for that? By the way, I won't be here until about monday. Thanks for all your help though!
  17. Not like this though, as you would get undefined index error's, you need to check to see if the var is there (isset()) but yes, this logic is the right approach... Rw What do you mean? I always get the wanted result. If an user submitted the form, and that field was empty it will echo 'nothing' -> empty.
  18. NLCJ

    MySQL queue

    Okay, I will convert the current database to a (apparently better) database structure. Thanks for your suggestions!
  19. NLCJ

    MySQL queue

    Thank you, a while ago I read that this way was as fast as without mysql_real_escape_string. I will do that. Also I wasn't aware that $_GET['type'] slows it down. I will make it better, and see how it goes. Thanks! And I created this database structure because I thought it was easier for the server. Apparently a table with more than 50.000 rows is faster?
  20. Please notice that if you use the method specified above, the user will have to refill all the fields. In order to prevent that you can use: <input type="text" name="first_name" size="50" value="<?php echo $first_name; ?>"/>
  21. PHPFreaks is right. Another way to fix this is to set your nameservers, the first one to that server and then the other one to the router / modem. In this way your computer will look at the server first and then go onto the internet. At this moment it's searching for that IP address at the internet, and then going local. I think you've got multiple routers or so?
  22. NLCJ

    MySQL queue

    Lets say that every line got a specific ID. If that ID doesn't exist, it creates a table for that ID. Then it will insert the rest of the information into that table. Why did I do it this way? I thought this would be less heavy for the server when requesting, because when all ID's are in the same table it would have more than 50.000 rows.
  23. NLCJ

    MySQL queue

    Thank you for your reply. This is the part of the code: for($number = 0; $number <= $lines - 1; $number++) { if($error = 1) { break; }else { if($setinactive != 1) { mysql_query("UPDATE `".$d_userinformation['username']."-".mysql_real_escape_string($_GET['type'])."s` SET status='inactive'"); $setinactive = 1; } $values = explode(",", $postedinfo[$number]); $since = date("Y-m-d", strtotime($values[1])); $lastclick = date("Y-m-d", strtotime($values[2])); $differencedate = (strtotime($since) - strtotime(date("Y-m-d")))/(24*60*60); if($differencedate == 0) { $differencedate = 1; } $average = $values[3] / $differencedate * -1; $d_checkexistence = mysql_query("SELECT * FROM `".mysql_real_escape_string($values[0])."` LIMIT 0,1"); if($d_checkexistence == false) { mysql_query("INSERT INTO `".$d_userinformation['username']."-".mysql_real_escape_string($_GET['type'])."s` (name,since,importedtime,lastimport) VALUES ('".mysql_real_escape_string($values[0])."','".mysql_real_escape_string(date("Y-m-d"))."','".mysql_real_escape_string(date("H:i:s"))."','".mysql_real_escape_string(date("Y-m-d"))."')"); mysql_query(" CREATE TABLE `".mysql_real_escape_string($values[0])."` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `since` DATE NOT NULL , `lastimport` DATE NOT NULL , `imported` DATE NOT NULL , `username` VARCHAR( 255 ) NOT NULL ) ENGINE = MYISAM ; "); mysql_query("INSERT INTO `".mysql_real_escape_string($values[0])."` (since,lastimport,imported,username,status) VALUES ('".mysql_real_escape_string($since)."','".mysql_real_escape_string($lastimport)."','".mysql_real_escape_string(date("Y-m-d"))."','".mysql_real_escape_string($d_userinformation['username'])."','active')"); }else { mysql_query("UPDATE `".$d_userinformation['username']."-".mysql_real_escape_string($_GET['type'])."s` SET since='".mysql_real_escape_string($since)."',lastclick='".mysql_real_escape_string($lastclick)."',clicks='".mysql_real_escape_string($values[3])."',average='".mysql_real_escape_string($average)."',lastimport='".mysql_real_escape_string(date("Y-m-d"))."',status='active' WHERE name='".mysql_real_escape_string($values[0])."'"); mysql_query("UPDATE `".mysql_real_escape_string($values[0])."` SET since='".mysql_real_escape_string($since)."', lastclick='".mysql_real_escape_string($lastclick)."', clicks='".mysql_real_escape_string($values[3])."', average='".mysql_real_escape_string($average)."', username='".mysql_real_escape_string($d_userinformation['username'])."' WHERE imported='".date("Y-m-d")."'"); } } } They all are different actions / tables, so it doesn't seem to get faster in my opinion. MOD EDIT: . . . tags added.
  24. NLCJ

    MySQL queue

    Hello, I've created a little script, that takes infromation from a CSV file and then imports it into the database. Sadly, this can be up to 5 query's per line. Some files are big (then I mean more than 4000 lines) and require full attention of the server, which makes all other sites slow. So I was wondering if it's possible to limit it to for example 5 or 10 query's per second? Like putting all the queries into a queue and then spread it over the time. A CSV file with 200 lines takes about 20 seconds now, what I'm afraid of is that the user thinks that the site is stuck so he refreshes it, what resends it and then gives inserts it again. Ofcourse I've got a protection for that, but it definetly can make the server freeze. Regards, P.S.: I'm sorry if it's placed in the wrong forum. I was not sure where to place it! EDIT: Okay, I just saw that I placed it in PHP Applications. It was meant to be in Coding Help...
×
×
  • 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.