gilpster Posted September 18, 2007 Share Posted September 18, 2007 Sorry to start another post. One of the difficulties with my problem is that searching for '#' produces a million results. I am now beta testing a php/ajax/MySQL database for my hospital. When the user completes field on a search page the page will send an ajax request which will then display the current returns for the users search criteria. When the user presses the 'submit' button, most of the time the search data has already been returned and the table of results is created dynamically rather than through a nasty page-refresh. (boo!) The javascript sends a GET request to a php page, something like: dataAjaxPreFetch?Procedure=[variable] where [variable] might be a field on the search page. The php page then cleans the $_GET[procedure] variable, does an SQL search, and returns the data either with xml or JSON. So far so good it works very well. The problem is that people often use the character '#' as part of a procedure name. E.g. '# femur' means 'fracture femur' in medical terminology. When this is send via ajax to my php script then all the variable after the '#' character is ignored, as the php is treating the '#' as a comment character. I really can't for the life of me work out how to fix the problem, and i can't stop users from using the character. Any ideas? many thanks guys kenneth Quote Link to comment https://forums.phpfreaks.com/topic/69756-solved-using-as-part-of-a-string-in-get/ Share on other sites More sharing options...
effigy Posted September 18, 2007 Share Posted September 18, 2007 urlencode Quote Link to comment https://forums.phpfreaks.com/topic/69756-solved-using-as-part-of-a-string-in-get/#findComment-350468 Share on other sites More sharing options...
gilpster Posted September 18, 2007 Author Share Posted September 18, 2007 thanks that was just the job. I used the javascript escape() function: // fmProcName is the form variable var url = "dataProcPreSearch.php"; var mark = "?"; var encodevar = escape(fmProcName); //encodes nasty things like '#' url += mark + "ProcName=" + encodevar; Then the php script automatically decoded it! thanks a bunch. Quote Link to comment https://forums.phpfreaks.com/topic/69756-solved-using-as-part-of-a-string-in-get/#findComment-350593 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.