Jump to content

jnymris

Members
  • Posts

    16
  • Joined

  • Last visited

jnymris's Achievements

Newbie

Newbie (1/7)

1

Reputation

  1. Firstly, Sorry about the lack of detail in the title, i'm not sure how to describe what i'm trying to achieve without going into detail. So I have a table: mysql> SELECT * FROM notes; +----+---------+-----------------+---------------------+----------+ | id | user_id | note | datetime | order_id | +----+---------+-----------------+---------------------+----------+ | 1 | 7 | Update Please? | 2018-02-16 22:22:18 | 1 | | 2 | 6 | Update Provided | 2018-02-16 22:25:18 | 1 | | 3 | 7 | test | 2018-02-17 10:03:20 | 2 | +----+---------+-----------------+---------------------+----------+ I'm trying to get the most recent row for each order_id. from the data above it result would be: Rows 2 and 3. I thought using a subquery would be the best way to go but i'm getting unexpected result: If i run the first part of the query I do get ID row 2 and 3 (which is a good sign). SELECT DISTINCT (order_id) FROM notes; If i run the second part of the query: I do get one result. SELECT user_id FROM notes WHERE order_id=1 ORDER BY datetime DESC LIMIT 1; When I combine both queries together I get an odd result. SELECT DISTINCT (order_id), user_id = (SELECT user_id FROM notes tbl2 WHERE tbl2.order_id=tbl.order_id ORDER BY datetime DESC LIMIT 1) FROM notes tbl; RESULT: +----------+------------------------------------------------------------------------------------------------------------+ | order_id | user_id = (SELECT user_id FROM notes tbl2 WHERE tbl2.order_id=tbl.order_id ORDER BY datetime DESC LIMIT 1) | +----------+------------------------------------------------------------------------------------------------------------+ | 1 | 0 | | 1 | 1 | | 2 | 1 | +----------+------------------------------------------------------------------------------------------------------------+ 3 rows in set (0.01 sec) Could anyone point me where i am going wrong? If it helps i'm actually only interested in getting the last row matches a specific value (7), but i just planned on doing this match with PHP if($user_id==7) //echo Will Display Data;
  2. Hi, I am currently using a webbrowse from within vb.net and have been able to navigate to a website login successfully. I am now looking to be able to download a .tar.gz and specific where to save this file to. (In order to get access to the download you have to login to create a cookie hence why i have logged in) When attempting to load the page (http://mysite/admin/backup.tar.gz) this then returns a dialog box. I am looking to see if i cane save this file automatically and not prompt the user? Example code to populate the username section For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input") If element.Name = "sessionUser" Then Dim i = 0 Dim strLine = "admin" element.InnerText = strLine End If Next and here is when prompts to save the file as: WebBrowser1.Navigate("http://85.189.65.77/admin/backup.whtm/update/backup.tar.gz") Thanks Johnny
  3. JustSomeGuy pcntl_fork appears to require *nix?
  4. Thanks JustSomeGuy I'm not sure i'm understanding pnctl_fork 100% from the examples it appears to return back to the user who 'created' the fork? I'm wanting the system to run script 'without the users knowledge which might take up to 15 minutes to run' Quick example how i'd call c:/inetpub/wwwroot/backgroundtask.php to be run in the background and the user can continue to browse pages? Thanks! Johnny
  5. are the current websites using php? have you tried a simple phpinfo to see what it showing? is php installed? in IIS you know you need a handler for php right? <?phpphpinfo();?>
  6. Hello, I've come across the need to run a background task after a user has submitted a form. Which i am having problems running. the php script calling the backup task does not need to wait for the response from the task. When i run the following command from cmd from within windows it runs fine: "c:program files (x86)phpv5.3php.exe" c:/inetpub/wwwroot/backgroundtask.php > c:/inetpub/wwwroot/backgroundtask.log however when running: exec('"C:Program Files (x86)PHPv5.3php.exe" C:/inetpub/wwwroot/Honours/bgprocess.php > C:/inetpub/wwwroot/Honours/bgprocess.log'); It fails to do anything (At the moment it is just creating and writing data into a text file as a proof of concept) I have also granted cmd.exe access to anyone in case this was an issue. Thanks Johnny
  7. I have updated the code to be more readable. Regards
  8. I'm attempting to upload files using Ajax. With the following code it will upload the first file correctly (and return the ID of that file) After changing the file to another file it will upload the second file again fine however it also re-uploads the first file thus generating two copies of the file. it is like the data is appended. I have attempted to remove the if (formdata){formdata.append("images[]",file);} which does not resolve this i have printed the value of len and it is always set to one. no matter how many files are being uploaded. (this is the problem for FireFox, Chrome and IE. Suggestions?: Javascript Code: var input = document.getElementById("files"),formdata = false;if(window.FormData){formdata = new FormData();document.getElementById("btn").style.display = "none";} function showUploadedItem (source){var list = document.getElementById("image-list"), li = document.createElement("li"),img = document.createElement("img");img.src = source;li.appendChild(img);} if(input.addEventListener){input.addEventListener("change", function (evt) {var i = 0, len = this.files.length, img, reader, file;document.getElementById("response").innterHTML = "Uploading . . ."for ( ; i < len; i++){ file = this.files[i]; if ( window.FileReader ){ reader = new FileReader(); reader.onloadend = function (e) { showUploadedItem(e.target.result); }; reader.readAsDataURL(file); } if (formdata) { formdata.append("images[]",file); }}if (formdata){$.ajax({url: "<?php echo base_url().index_page(); ?>meetings_ajax/upload_file",type: "POST",data: formdata,processData: false,contentType: false,success: function (res){document.getElementById("response").innerHTML = res;}});}}, false);}[/codeBOX]
  9. jnymris

    Soap

    Morning/Afternoon/Evening all I've been using SOAP for around 3 months without any issues. Recently it has came to light that these SOAP requests (Currently have one request which is being called on two separate pages). To try and debug this i have try the same website on my machine (Copying the source files and config)(using phpinfo) SOAP if enabled on both my machine and the server along with all the SOAP configs being the same. It runs successfully on my machine yet fails to run on the server. To investigate this further i then created a 'internal soap' which again works successfully on my machine and fails on the server. the Server is currently in a DMZ which hasn't changed as far as I'm aware but to rule any changes out i disabled my Network card to ensure the soap on my machine still runs to find it does not? What would be the reason for this? and if it is possible, how can I remove this dependency? i can see reference to http://schemas.xmlsoap.org/... and http://www.w3.org/2001, would it be possible to download these files? (I'm assuming this isn't like HTML where it's a Document Type?) If this has been working so far and the DMZ has changed what may have caused this? What would be the best way to ensure everything is working. I've just replaced the .php files and again it is working on my machine and not on the server. Any Suggestions?
  10. jnymris

    MySQL If statement

    Thanks justsomeguy How would I go about creating a function and then calling the function? I've never created a function in MySQL. any suggestions/tutorials?
  11. jnymris

    MySQL If statement

    Morning/Afternoon All, I'm trying to create a simple if statement in SQLThis has been casuing me so much trouble since yesterdayHere's what i'm trying to achieve. IF((SELECT COUNT(*) FROM computers WHERE name='PC-01' AND domain='mydomain.local')==1)SELECT ComputerID FROM computers WHERE name='PC-01' AND domain='mydomain.local'ELSE IF((SELECT COUNT(*) FROM computers WHERE name='PC-01' AND domain='mydomain')==1)SELECT ComputerID FROM computers WHERE name='PC-01' AND domain='mydomain'ELSE IF(SELECT COUNT(*) FROM computers WHERE name='PC-01')==1)SELECT ComputerID FROM computers WHERE name='PC-01' I have tried: IF((SELECT COUNT(*) FROM computers WHERE name='PC-01' AND domain='mydomain.local')==1)BEGINSELECT ComputerID FROM computers WHERE name='PC-01' AND domain='mydomain.local'ENDELSE IF((SELECT COUNT(*) FROM computers WHERE name='PC-01' AND domain='mydomain')==1)BEGINSELECT ComputerID FROM computers WHERE name='PC-01' AND domain='mydomain'ENDELSE IF(SELECT COUNT(*) FROM computers WHERE name='PC-01')==1)BEGINSELECT ComputerID FROM computers WHERE name='PC-01'END Along with other suggests which google returned. to no luck. How can a simple IF statement be so complicated? (Side Note: using phpmyadmin i cannot do print/echo/prompt commands is that normal?)
  12. Scott, When to use the username and first name is totally down to you. When you log into W3school at the top you can see your full name. However i logged in with my username. But W3schools wish to display my first and second name to me rather than the username which they could have done. You could use a firstname, surname and password as a login action but of course more than one person exsist in the world with the same name and if they both have the same password what happens then? It's NOT Recommended but it's possible.
  13. Hello GuysI'm currently running this script inside MS Excelnow this works (may have typos below) however when using this line ".body1:_id3:Number.Value=Range("B1")" it returns an error due to the _ However this is the Name & ID of this field. this CANNOT be change is their anyway i can still reference this field without changing the name and id of this field? If it's any use i know its the 3rd input box down? Dim ObjIE as objectSet ObjIe = createobject ("internetExplorer.Application")with ObjIe.Navigate = "http://localhost/test.php"Do While .busy:DoEvents:LoopDo While .ReadyState<>4:DoEvents:Loop.Visible = Truewith .Documents.forms("myForm").body1:_id3:Number.Value=Range("B1").SubmitEnd WithEnd WithSet ObjIe = Nothing Second Question is:on a second form (no relation to the first form)to submit the form the button is <input type="submit" name="test" value="Search" /> that needs to be clicked however their is also another submit button which has the value of <input type="submit" name="test" value="Clear" />i have tried this..test.Value="Search"but with no joy so i triedwith .Documents.forms("myForm").value="Search".submitbut again with no joyanyone able to help with either of these questions?thanks Very MuchJonathon Morris
×
×
  • Create New...