Jump to content

Ustag

Members
  • Content count

    49
  • Joined

  • Last visited

Community Reputation

1 Neutral

About Ustag

  • Rank
    Newbie
  1. Ustag

    mysqli_query() error logging

    Hi, I have a mysqli_query that goes like this: $result = mysqli_query($db, "INSERT INTO device(`Identifier`, `IsAllowedToPost`)VALUES('ABC123', 0)") or die(error_log(mysqli_error($db), 3, "php_error.log")); It does not work and the logs either tells me "1", "0" or nothing depending on which method I try to log the error with. How can I get a better error message to log in my file? 1 or 0 means nothing to me. The current code gives me no error message at all in my file and the data does not get stored in the database.
  2. Ustag

    uploading big files with ftp

    ok what I did to fix this was to delete my .htaccess and create a new php.ini file and start over.
  3. Ustag

    uploading big files with ftp

    I've found many topics on how to fix this but nothing seem to work for me.I am uploading files trough ftp with a php script and what I am doing to make this work so far is this: editing .htaccess to make php settings allow a file of 10mb for sure: php_value session.gc_maxlifetime 86400php_value max_input_time 86400php_value max_execution_time 86400php_value upload_max_filesize 1100Mphp_value post_max_size 1100Mphp_value memory_limit 1100M Using custom timeout setting like this:ftp_connect($ftp_server, 21, 120000) Editing the same options as above in the actual php.ini file. I also have this in my php script: set_time_limit(0);And this: ini_set('upload_max_filesize',1100000000); What I get now is this error message when trying to upload a file of around 10mb: POST Content-Length of 10550339 bytes exceeds the limit of 10485760 bytes in Unknown on line 0 If I look in phpinfo(); ite tells me that post_max_size = 10M and upload_max_filesize = 10M even if I changed it. How come? Could it be my webhost that prevents this from increasing???
  4. Ustag

    XmlHttpRequest: sending file

    if I drop 2 files will it do this: create barcreate bar trigger progressFunctiontrigger progressFunction or this: create bartrigger progressFunction create bartrigger progressFunction ?
  5. Ustag

    XmlHttpRequest: sending file

    edit: I regret my post, im just lost ^^
  6. Ustag

    XmlHttpRequest: sending file

    Shouldnt this work? function progressFunction(evt) { //give each bar a % calculator var bars = document.getElementsByTagName('progress'); for (var i=0; i<bars.length; i++) { var progressBar = document.getElementById('progressBar' + i); var percentageDiv = document.getElementById('report' + i); if (evt.lengthComputable) { progressBar.max = evt.total; progressBar.value = evt.loaded; percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%"; } } }
  7. Ustag

    XmlHttpRequest: sending file

    I use the example at the bottom of that page you gave me but I want to edit this to fit my needs. This is my code now to give me one progress bar for each file dragged on to the dropzone, my problem is how I can also give each progrss bar its own % calculator. <script type="text/javascript"> function sendFile(file) { var uri = "upload.php"; var xhr = new XMLHttpRequest(); var fd = new FormData(); xhr.upload.addEventListener("progress", progressFunction, false); xhr.open("POST", uri, true); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { // Handle response. //alert(xhr.responseText); var percentageDiv = document.getElementById("report"); percentageDiv.innerHTML = 'Transfer complete'; } } fd.append('myFile', file); // Initiate a multipart/form-data upload xhr.send(fd); } window.onload = function() { var dropzone = document.getElementById("dropzone"); dropzone.ondragover = dropzone.ondragenter = function(event) { event.stopPropagation(); event.preventDefault(); } dropzone.ondrop = function(event) { event.stopPropagation(); event.preventDefault(); var filesArray = event.dataTransfer.files; for (var i=0; i<filesArray.length; i++) { var progressDiv = document.getElementById('progressDiv'); var pbar = document.createElement('progress'); var br = document.createElement('br'); var report = document.createElement('div'); pbar.setAttribute('id', 'progressBar' + i); pbar.setAttribute('value', '0'); pbar.setAttribute('max', '100'); report.setAttribute('id', 'report' + i) progressDiv.appendChild(pbar); progressDiv.appendChild(br); progressDiv.appendChild(report); progressDiv.appendChild(br); sendFile(filesArray[i]); } } } function progressFunction(evt) { var progressBar = document.getElementById('progressBar' + i); var percentageDiv = document.getElementById('report' + i); if (evt.lengthComputable) { progressBar.max = evt.total; progressBar.value = evt.loaded; percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%"; } }</script> The function progressFunction(evt) can not be placed in the for loop, then it will not work. Does anybody know how I could solve this? Thank you.
  8. Ustag

    XmlHttpRequest: sending file

    Thank you, that was very usefull!
  9. Ustag

    XmlHttpRequest: sending file

    Hello, im trying to create a nice file uploader using XmlHttpRequest so that we can get a nice progress bar and stuff without reloading the page. When I try to upload using my code the progress bar does show and count % up untill completed but no file is being uploded. I will show you my code and tell you what I think is wrong, but I will strip it down a bit. This is my js part: function uploadFile() { var xhrObj = new XMLHttpRequest(); var filesToBeUploaded = document.getElementById("fileControl"); var file = "filename="+filesToBeUploaded.files[0]; xhrObj.upload.addEventListener("progress", progressFunction, false); xhrObj.upload.addEventListener("load", transferCompleteFunction, false); xhrObj.open("POST", "upload.php", true); xhrObj.setRequestHeader("Content-type", file.type); xhrObj.send(file); } My form is not important, its a button with onclick="uploadFile()". But my upload.php might not be correct. This is where I wonder if I can use this:move_uploaded_file($_FILES['Filedata']['tmp_name'], "files/".$name."/".$filename) my upload.php: <?phpsession_start(); //Set some variables$name = $_SESSION['name'];$filename = $_POST['filename'];$key = uniqid(); // Move uploaded fileset_time_limit(0); if(move_uploaded_file($_FILES['Filedata']['tmp_name'], "files/".$name."/".$filename)){ // Update database}?>
  10. Ustag

    php upload multiple files

    hi I have problem with my file uploader which dont make sense for me. I am trying to upload 3 files with the following code but only one of them is being uploaded and its the .xbst file. Please have a look, it gives me no error message at all: //image file if (($_FILES['image']['error'] == 0) && ($_FILES["image"]["type"] == true)) { $ext = substr(strrchr($_FILES["image"]["name"], '.'), 1); if (($ext == "jpg") || ($ext == "JPG") || ($ext == "jpeg") || ($ext == "JPEG")) { if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key , 0755); } else { move_uploaded_file($_FILES["image"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key."/".$_FILES["image"]["name"]); } } else { echo "Filetype not allowed: ".$_FILES["image"]["name"]; }} //xbst file if (($_FILES['settings']['error'] == 0) && ($settings == true)) { $ext = substr(strrchr($_FILES["settings"]["name"], '.'), 1); if (($ext == "xbst") || ($ext == "XBST")) { if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755); } else { move_uploaded_file($_FILES["settings"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/".$_FILES["settings"]["name"]); } } else { echo "Filetype not allowed: ".$_FILES["settings"]["name"]; }}//lua file if (($_FILES['script']['error'] == 0) && ($script == true)) { $ext = substr(strrchr($_FILES["script"]["name"], '.'), 1); if (($ext == "lua") || ($ext == "LUA")) { if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key , 0755); } else { move_uploaded_file($_FILES["script"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key."/".$_FILES["script"]["name"]); } } else { echo "Filetype not allowed: ".$_FILES["script"]["name"]; }} Thank you for your time!
  11. Ustag

    sorting arrays

    Hi, I am generating a bunch of arrays but I would like to change the order of these. This is my code now: $players_killed['time'] = strtotime($time);$players_killed['name'] = ': '.$player;arsort($players_killed, SORT_NUMERIC);echo var_dump($players_killed) .'<br>'; And this is the output: array(2) { ["time"]=> int(1334027580) ["name"]=> string(106) ": Brbasher" }array(2) { ["time"]=> int(1334029860) ["name"]=> string(102) ": Dynext" }array(2) { ["time"]=> int(1334029260) ["name"]=> string(110) ": Kronigrass" }array(2) { ["time"]=> int(1334036580) ["name"]=> string(108) ": Poliminia" } How can I make them order by the time value? My attempt with arsort($players_killed, SORT_NUMERIC); sure failed.
  12. Ustag

    htmldom + substr()

    Thank you all but my solution will be to break this down and add substr($td2->nodeValue, 0, 3) and substr($td2->nodeValue, 5, 2) in to variables that will give me "Apr" and "08". Thanks !
  13. Ustag

    htmldom + substr()

    var_dump(substr($td2->nodeValue, 0, 3)); = string(3) "Apr"var_dump(substr($td2->nodeValue, 0, 4)); = string(4) "Apr´┐Ż"var_dump(substr($td2->nodeValue, 0, 5)); = string(5) "Apr "var_dump(substr($td2->nodeValue, 0, 6)); = string(6) "Apr 0"var_dump(substr($td2->nodeValue, 0, 7)); = string(7) "Apr 08" Does this tell me anything? ^^
  14. Ustag

    htmldom + substr()

    Adding "Killed" and using substr($td2->nodeValue, 0, 6) == "Apr 08" did not work eather. And how come echo substr($td2->nodeValue, 0, 7) = "Apr 08" and echo substr($td2->nodeValue, 0, 6) = "Apr 0"? I just noticed in their source code it says "Apr& #160;08", what is "& #160;" (without the whitespace)?
  15. Ustag

    htmldom + substr()

    Hi, I am scraping a game page in order to grab certain info about a player. What I scrape is the info under "Character Deaths" for example on this page: http://www.tibia.com...s&name=Brunkarn This code will print all killed players in April: if((substr($td2->nodeValue, 0, 3) == "Apr") && (substr($td2->nextSibling->nodeValue, 0, 6) == Killed)){echo $player.': '.substr($td2->nodeValue, 0, 7).'<br>';} It prints "Brunkarn: Apr 08". now if I replace this: substr($td2->nodeValue, 0, 3) == "Apr") with this: substr($td2->nodeValue, 0, 7) == "Apr 08") I get no result anymore, why? When I echo substr($td2->nodeValue, 0, 7) I get "Apr 08". Sorry if I post in wrong section, please move this.
×