Jump to content

[SOLVED] using '#' as part of a string in GET


Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/69756-solved-using-as-part-of-a-string-in-get/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.