Jump to content

[SOLVED] use of '&' in string breaks the rest of the string!!!


rsammy

Recommended Posts

if i receive an '&' sign in my string via a POST variable, i lose all of the remainder of the string after that symbol. is it a php thing. i send this in a free form text field and the string breaks when it encounters the '&' sign and stores the info preceding it.

 

any workaround for this? any help/suggestions?

Link to comment
Share on other sites

actually, this field comes from a mobile device. i receive it and then insert it into the database. it takes in all other special characters except for this '&' sign.

 

for example, this is my code(where i receive the info from the device):

<?PHP

	ob_start();
	print ("InstiComm");
	// set log file
function writeLog($msg)
{
	// set file to write
	$filename = "error.log";

	// open file
	$fh = fopen($filename, "a") or die("Could not open log. ENDOFMESSAGE");

	$size=ob_get_length();

	// create the data string to be written
	$str = date("[Y-m-d h:i:s] ", mktime()) . $msg .  $size. "\r\n";

	// write to log
	fwrite($fh, $str) or die("Could not write to log. ENDOFMESSAGE");

	// close file
	fclose($fh);
}

$phy_pin=$_POST["phy_pin"];

if (!isset($phy_pin))
{
	echo "Access Denied";
	print ("ENDOFMESSAGE");
	exit;
}
$tid=$_POST["TRAN_ID"];
if (!isset($tid))
{
	echo "No Data Received 112";
	print ("ENDOFMESSAGE");
	exit;
}
$pid=$_POST["PATIENT_#"];
if (!isset($pid))
{
	echo "No Data Received 111";
	print ("ENDOFMESSAGE");
	exit;
}

function FncShowHTTPVars ($array)
{
		$varString ="";

	 if (count($array))
	 {
		while (list($key, $val) = each($array))
		{
		   if (is_array($val))
		   {
				while (list($key2, $val2) = each($val))
				$varString.= "$key [$key2] = $val2<br>";
		   }
		   else
				$varString.= "$key = $val<br>";
		}
	 }
	 return $varString;
}


//File for database information
require_once ("../config.php");

//Open connection to Database

mysql_connect ($database[hostname], $database[username], $database[password])
		or die("Unable to connect to the database. ENDOFMESSAGE");

mysql_select_db ($database[dbname])
		or die("Unable to open the database. ENDOFMESSAGE");

$my_vars = "Post vars: <br>";

$my_vars .= FncShowHTTPVars ($_POST);

$my_vars .= "Get vars: <br>";

$my_vars .= FncShowHTTPVars ($_GET);

if (isset ($my_vars))
{

	$message = "";

	$pat_fname=$_POST["PATIENT_FNAME"];
	$pat_lname=$_POST["PATIENT_LNAME"];

	if ( isset( $pat_fname, $pat_lname ))

		$message .= "PATIENT NAME: " . $pat_fname . " " . $pat_lname. "\n";		
                         $location=$_POST["LOCATION"];

	if ( isset( $location ))

		$message .= "LOCATION: " . $location . "\n";

	$room_no=$_POST["ROOM_#"];

	if (isset( $room_no))

		$message .= "ROOM NUMBER: " . $room_no . "\n";

	$dia=$_POST["DIAGNOSIS"];

	if ( isset( $dia ))

		$message .= "DIAGNOSIS: " .$dia . "\n";

	$pro=$_POST["PROCEDURE"];

	if ( isset( $pro ))

		$message .= "PROCEDURE: " . $pro . "\n";

	$med=$_POST["MEDICATION"];

	if ( isset( $med ))

		$message .= "MEDICATION: " . $med . "\n";

	$img=$_POST["IMAGING"];

	if ( isset( $img ))

		$message .= "IMAGING: " . $img . "\n";

	$fol=$_POST["FOLLOW_UP_NOTES"];

	if ( isset($fol ))

		$message .= "FOLLOW UP NOTES: " . $fol . "\n";

	$refer=$_POST["SEE_CONSULTANT"];

 

and then, this is where i insert it into the table:

				$queryl= ("INSERT INTO dcn (dcn_phy_id, dcn_pref_prov, dcn_pat_id, dcn_dov, dcn_img, dcn_foll, dcn_cons, dcn_doc, dcn_palm_db_id, dcn_visit_id, dcn_date_created, dcn_mr_num, dcn_client_id, dcn_approved_for_billing, dcn_posted_for_billing, dcn_tran_ID)
						VALUES ('$phy_id', '$pref_prov', '$pat_id',  '$dateofvisit', '$img', '$fol', '$refer','$see_doc', '$unqID', '$visit_id', '$visit_date_reformat', '$ref_no', '$client_id', 'No', 'No', '$unqID')");
				$resultl=mysql_query($queryl);
				if(!$resultl)
				{
					$error="Error 342";
				}

 

the problem is with the follow-up notes($fol) and procedure ($pro) fields!

Link to comment
Share on other sites

here it is:

If ReaddischargeRecord(DisRec) Then
        theMessage = theMessage & "&STATUS=" & DisRec.admit_status
        theMessage = theMessage & "&VISIT_DATE=" & DisRec.dateofvisit
        ' 10/9/06 Appended Time of the Visit as well to the VISIT_DATE
        theMessage = theMessage & "&VISIT_TIME= " & DisRec.timeofvisit
        theMessage = theMessage & "&ATTENDING_PROVIDER=" & DisRec.physician
        
        If Trim$(DisRec.location) <> "" Then
            theMessage = theMessage & "&LOCATION=" & DisRec.location
        End If
        If Trim$(DisRec.room_number) <> "" Then
            theMessage = theMessage & "&ROOM_#=" & DisRec.room_number
        End If
        If (Trim$(DisRec.diagnosis) <> "") And (Trim$(DisRec.diagnosis) <> "NONE") Then
            theMessage = theMessage & "&DIAGNOSIS=" & DisRec.diagnosis
        End If
            
        theMessage = theMessage & "&PROCEDURE=" & DisRec.procedures
        
        If (Trim$(DisRec.medications) <> "") And (Trim$(DisRec.medications) <> "NONE") Then
            theMessage = theMessage & "&MEDICATION=" & DisRec.medications
        End If
        If Trim$(DisRec.imaging) <> "" Then
            theMessage = theMessage & "&IMAGING=" & DisRec.imaging
        End If
        If Trim$(DisRec.follow) <> "" Then
            theMessage = theMessage & "&FOLLOW_UP_NOTES=" & DisRec.follow
        End If
        If Trim$(DisRec.con_name) <> "" Then
            theMessage = theMessage & "&SEE_CONSULTANT=" & DisRec.con_name & " in " & DisRec.con_days
        End If
        If Trim$(DisRec.doc_name) <> "" Then
            theMessage = theMessage & "&SEE_PROVIDER=" & DisRec.doc_name & " in " & DisRec.doc_days
        End If
    End If

 

im guessing the '&' in the variable name is causing it to think its a new variable from there on?

Link to comment
Share on other sites

No, the issue is when you are passing it, you need to put the & into an entity type code like a space is %20  If you can figure out which it is that would solve your problem.

 

Edit to the previous, you would need a url_encode function in VB instead of the html_entities.

Link to comment
Share on other sites

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.