Jump to content

DaveEverFade

Members
  • Posts

    56
  • Joined

  • Last visited

    Never

Everything posted by DaveEverFade

  1. Oh... And please don't suggest SELECT DISTINCT * from Orders... etc etc....
  2. I have 2 tables as follows: Customer: cust_id cust_name Orders: order_id cust_id I need to have a distinct select of the these but to only bring back one result per customer. This is what I have SELECT DISTINCT * from Customer LEFT JOIN Orders on (Customer.custid = Orders.cust_id) The only problem is that I get more than one result for each customer if there is more than one entry for said customer in the Order table. The above is only a simplified example to try to explain my issue. Essentially I need the sql structure to remain as it is but need some kind of way of getting the LEFT JOIN to be distinct.... Any ideas? Dave
  3. This should be a nice easy one for you lot. I need a function that can get data from a string between 2 points. For example: If I wanted the data between BEGIN and END in the following string: 0123 BEGIN456789END 0123 BEGIN10111213END Ideally what would be returned would be an array of $data[0]=456789 $data[1]=10111213 Any ideas?
  4. If I'm understanding you right then it sounds like it might be easier to get the id and dates you need to update from the table first then use UPDATE instead. ie "UPDATE whiteboard_dates SET ad_copy_rec = $new_dates WHERE rest_id=$table_id" where $new_dates is the previous data stored in ad_copy_rec concatenated with ", ".$_POST['ad_copy_rec'] ....
  5. Ta! I totally forgot about the http_request.status duh! Many thanks
  6. Hopefully you won't need example code for this. Does anybody know how to change the default file upload temp area on a IIS server (not using .htaccess or php.ini) using PHP? Many thanks, Dave
  7. Does anyone know if there is a way of checking if the response from an ajax request is a valid page? To explain more: I have a site that uses ajax heavily for multiple refreshes for example, a msn style shoutbox. This is my stateChanged function function stateChanged(Div) { //alert(request.readyState) if(request.readyState<4) { window.status="Loading"; document.body.style.cursor = 'wait'; } if (request.readyState==4 || request.readyState=="complete") { document.getElementById(Div).innerHTML=request.responseText window.status="Done"; document.body.style.cursor = 'auto'; } } Now what i want to be able to do is identify if the page cannot be displayed (but I don't mean a 404 error or such like). I mean if the server has gone down or something because if that is the case I get a hideous "Web Server Temporarily Unavailable" displayed where my page should be. Any ideas? ???
  8. I'll take a look, not met JSON before... He sounds lovely...
  9. Hmm, don't quite follow you... Do you mean make the requests unique in someway? Think I tried that but got stuck...
  10. Ah but the problem I faced before with that was that the responses were getting mixed up. Which is why I blocked multiple requests by changing window.status (and checking it at the start)
  11. Ok, so here's the ajax file I've built up (seems to lose all the tabbed formatting on here...). All the Ajax requests go through the Ajax() function... function Ajax(GetPage, Params, Div, Type, Secondary) <!-- { document.body.style.cursor = 'auto'; if(window.status=="Loading") { //Perform secondary request }else { if (Params!="") { var str=null; if(Params.indexOf("=")==-1) { str=eval(Params+"();"); }else { str=Params; } //alert("We're debugging, please ignore this \n\n Get Page="+GetPage+"\n Params="+Params+"\nDiv="+Div) } var url=GetPage+".php?" url+=str url+="&id="+Math.random() //Random string after the url to avoid caching on newer machines request=GetXmlHttpObject(); if(request==null) { alert("Your browser will not run AJAX requests") return } request.onreadystatechange=function(){stateChanged(Div)} if(Type=='post') { request.open('POST', GetPage+'.php', true); request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.setRequestHeader("Content-length", str.length); request.setRequestHeader("Connection", "close"); request.send(str); }else { request.open("GET",url,true) request.send(null) } } } function stateChanged(Div) { if(request.readyState<4) { window.status="Loading"; document.body.style.cursor = 'wait'; } if (request.readyState==4 || request.readyState=="complete") { document.getElementById(Div).innerHTML=request.responseText window.status="Done"; document.body.style.cursor = 'auto'; } } function GetXmlHttpObject() { var objXMLHttp=null if (window.XMLHttpRequest) { objXMLHttp=new XMLHttpRequest() } else if (window.ActiveXObject) { objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") } return objXMLHttp }
  12. I've thought I had the answer to this but turns out I didn't: Does anyone know how to have mulitple Ajax requests running? For example having one request getting something from one page and another getting something from a different page at the same time (using the same javascript function)? At the moment I have it so that when a user requests something, the window.status changes to "Loading" so if they request something when it's in that state it simply does nothing, now I'd like to accomodate the multiple request... Any ideas?? Dave
  13. Well, before your query could be somthing like this: $sql="SELECT stuff FROM DB where a=".escape_for_mysql($_POST['stuff']); If you see what I mean? Just call the function with the POST data...
  14. From what I understand it escapes nasty things like ' by putting a \ in front of them (so MySQL ignores them)
  15. Well the you're putting the password straight from $_POST in the database! Big no no... Somebody could enter the password as somthing' or password <> 'somthing or similar, gaining access to the site. You might want to read up on some articles about this. There are a few ways to do it, I tend to use mysql_real_escape_string()
  16. No worries, just noticed tho, you don't need that value='$edit' in there...
  17. echo " <select name='editbox' value='$edit'> <option ".($edit==1?"selected":"")." value='1'>1</option> <option ".($edit==2?"selected":"")." value='2'>2</option> <option ".($edit==3?"selected":"")." value='3'>3</option> etc.... </select> ";
  18. I'd go with Eugene's as mine is restricted to that exact layout..
  19. Ok, well if the format doesn't change (ie it's the same amount or characters) you can use this: $text="1d35m37.7s"; $d= substr($text, 0, 1); // gets the first char $m=substr($text, 2, 2); // gets the 3rd and 4th chars $s=substr($text, 5, 4); // gets the rest
  20. Ignore this comment... Turns out I don't know PHP
  21. If you can't find a webpage you can do it yourself using microtime() ie $time_start = microtime(true); //Do some stuff... $time_end = microtime(true); $time = $time_end - $time_start; echo "Stuff took $time seconds"; (ps - this was yoinked off php.net)
  22. I don't know much about shell_exec but you might wanna try my favourite bit of code (before the command) to help diaganose the problem error_reporting(E_ALL); ini_set('display_errors', '1');
  23. Ok the first error is because you are checking the value of something before it even exists ($searchstring does not exist until the page is submitted) Your action is incorrect. Try just hard coding it to searchtest.php for now: action="searchtest.php" and on line 39 change it to if( (isset($_POST['searchstring]')) && ($_POST['searchstring']=="yes") )
  24. Can you post the error please?
  25. if you have a lot of results or arrays in arrays I find it a lot easier to read when you do this: echo "<pre>"; print_r($result); echo "</pre>";
×
×
  • 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.