Jump to content

php_begins

Members
  • Posts

    259
  • Joined

  • Last visited

Everything posted by php_begins

  1. I am running an old version of php. Can a cookie be secure and httponly at the same time? Also is it important to set the domain field? If so how can i dynamically get a domain in php? header( "Set-Cookie:". $Name."=".$Id."; expires=".$expires."; path="/"; domain="";Httponly; secure"); I noticed IE has some occasional issues with setting the cookie with the above code. Also the page breaks in IE if i add either secure or httponly or both. it works when i remove both.
  2. So I am using this legacy application which is in php 4. I am trying to set the httponly flag and secure flag on. This is my code: header( "Set-Cookie:". $cookieName."=".$sessId."; expires=".$expireSeconds."; sessionID=".$sessId.";path=".$path."; domain=".$domain."; httponly; secure"); When I test it, The secure flag is set on but the httponly is not. Could it because the URL uses https protocol? Also, does the expire field take seconds. right now, $expireSeconds=14400; How do I modify the code to rectify this if it doesnt expect seconds as a parameter.
  3. My function returns a bunch of attribute ids and it's corresponding names in json format. For eg: { "DETAILS": [ { "ATTR_ID": "522", "ATTRIBUTE_ID": "4222", "ATTRIBUTE_TYPE": "email", }, { "ATTR_ID": "523", "ATTRIBUTE_ID": "4006", "ATTRIBUTE_TYPE": "interest", } ] } I need to store it in an array which i need to cache .( I'll be probably using $_SESSION) Now another function returns me set of attribute ids: $val_array = $subarray[arrayOfAttributes]; foreach ($val_array as $val) { print "Attrib Value: $val\n"; //This will print ids 4222,4223,etc } what I need to do is correspond the ids with the type from the cache nad print out the respective Types. I am unable to formulate this logic into code.
  4. Anybody familar with tcl ? I have a select query that returns an out put like {HD 208 {} 2012-04-13 25 21 4} {SD 208 {} 2012-04-13 100 97 3} {HD 2072 {} 2012-04-13 5 4 1} {SD 2072 {} 2012-04-13 50 45 6} Now I want to set to store them in a variable and display one by one so that i can display it using html tables the records are returned in $get_record. So here's what i am doing foreach record $get_record { foreach item [lindex $record 0] { set event_name [ lindex $item 0] puts $event_name set event_date [ lindex $item 1] put $event_date set attempts_cnt [ lindex $item 2] put $attempts_cnt set success_cnt [ lindex $item 3] put $success_cnt } } Unfortunately this doesnt work..
  5. But I would still want to update the whole number. For eg. If i have a number 786661234. Its should be dispalyed in the form as XXXXX1234. When I click and submit the form, it should be decoded and updated in the database as 786661234.
  6. I need to display a number(the number is retrieved from the db) in the form input field such that only the last 4 digits is visbile, the remaining can be masked as * or X or whatever is applicable. I know the last 4 can be obtained as follows: $number=substr($number,-4,4); But when i hit the submit button the form validates the input field and checks if the number is a valid number of a specific format. Therefore when I click on the submit button then I should still be able to unmask the masked numbers or do something similar that would help me validate the whole number. <input type="text" name="no" value="<?php if(!empty($number)){ echo $number;} ?>">
  7. Never mind..here is what i did. $split_date=explode("/",$date); echo "0: ".$split_date[0]."<br>"; echo "1: ".$split_date[1]."<br>"; echo "2: ".$split_date[2]."<br>";
  8. I have a date of the following format: $date='04/09/2012'; How can i split it so that I can each one of them separately to use it in a JS function. var myDate = new Date(2012, 4, 9); NOTE: javascript months run from 0 to 11 for Jan to Dec.
  9. <script type="text/javascript"> $(function() { $('#dp_date').datepicker({ dateFormat: 'm/d/yy', minDate: 1, beforeShowDay: $.datepicker.noWeekends }); }); </script> I have the following script which gets date in the future and does not show weekends. I need to modify the above code as follows: I have one more date stored in the php variable $ef_date which is greater than or equal to current date. I want my datepicker to pick only dates that are greater than the $ef_date variable. It can be equal to $ef_date only if $ef_date is greater than today's date. Else it always has to be greater than $ef_date.
  10. Thanks..but i do not want to trim all the spaces. If there are multiple white spaces between 2 words, I want to reduce them to one space..
  11. <label for="first_name">* First Name </label> <input type="text" name="first_name" maxlength="64" value=<?php echo formatPhone(clean_input($_POST['first_name']); ?>> I have a form where I want to enter a first name. I want the fields to take only alphabets(no numbers). Also when a user enters something like John Doe separated by multiple white spaces, I want it to separate the two words only by a single space. I am not sure how this is done in php.
  12. I have a code where i can edit or delete certain details from the database. Right now, if the user clicks on the edit button it takes him edit page where he can edit the details. But, I am not able to Incorporate a Delete button such that, when the user clicks on a delete button, it should ask for a confirmation box. If the user clicks YES, then do the following: DELETE from emp WHERE emp_id='$emp_id'; When there are multiple entries and I click on delete it deletes everything from the database. how can i make it to delete only the entry that is besides the delete button? if(mysql_num_rows($emp_query) > 0){ echo "<table border='1'>"; echo "<th>Employee Id </th>"; echo "<th>Employee Name </th>"; while($get_emp = mysql_fetch_assoc($emp_query)){ $emp_id = $get_emp['emp_id']; $emp_name = $get_emp['first_name']." ".$get_emp['last_name']; echo "<tr>"; echo "<td width='100'>"; echo $emp_id; echo "</td>"; echo "<td width='400'>"; echo $emp_name; $edit_path = 'edit_employee.php?id='.$emp_id; ?> <INPUT TYPE="button" style="display:inline;" value="VIEW / EDIT" onClick="location.href='<?php echo $edit_path; ?>'"> <form style='margin: 0; padding: 0; display:inline;' method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" onSubmit="return confirm('Are you sure this is correct?');"> <input style='display:inline;' name="delbutton" type="submit" value="DELETE"> <?php if(isset($_POST['delbutton'])){ $del_emp = mysql_query("DELETE from employee WHERE emp_id = '$emp_id'") or die(mysql_error()); //header('Location:view_employee.php'); } echo '</form>'; echo "</td>"; echo "</tr>"; } }
  13. I actually I ll have to reframe my question. I dont think I can use NOW() with the way I am writing my code now. $qcData = Array( "date_time" => NOW(), "note" => $note ); $qcNotes = new App_Model_DbTable_QCNotes(); $qcNotes->insert($qcData);
  14. oh yes..The code that I reposted works for me.
  15. oh ok. So just do: "INSERT INTO (datetime) VALUES (NOW())"; ?
  16. I have a field called date_time in the database which is of type datetime. I have a form which on submit needs to enter the current date and time in the date_time field. I know I can get the current time using time() $time=time(); Can do I do some kind of manipulation using strtotime() and store in the database in datetime format?
  17. My bad..That was a database access problem in the ZEND framework. I had to modify my code according to the settings in my framework. $hidden_client_id_query = $this->db->query("SELECT id FROM pdp_client_info WHERE lead_id='$post_lead_id'"); $hidden_client_id=$hidden_client_id_query->fetch(); $this->view->hidden_client_id=$hidden_client_id['id'];
  18. I have the following code $hidden_client_id_query = mysql_query("SELECT id from `pdp_client_info` WHERE lead_id='$post_lead_id'"); $hidden_client_id=mysql_fetch_assoc($hidden_client_id_query); $this->view->hidden_client_id=$hidden_client_id['id']; I get the following error for the above code. I wonder where I am wrong. I am getting the $post_lead_id as expected. Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean
  19. I wrote this j query script which works fine in the jsfiddle.net but does not work in the server at www.cs.txstate.edu/~sr1388. In firebug it says $ not defined. Am i Missing any file? <script type="text/javascript"> $(document).ready(function() { $("#credit_pay").hide(); $("#downpayment_method").change(function() { if ($("#downpayment_method").val()=='credit_card') { $("#credit_pay").show("fast"); } else { $("#credit_pay").hide("fast"); }; if ($("#downpayment_method").val()=='e_check') { $("#e_pay").show("fast"); } else { $("#e_pay").hide("fast"); }; }); }); </script>
  20. Thanks both of you. My soultion worked fine with the changes suggested by Dan.
  21. I need parse the JSON string below into an associative array, sort it by the 'age' field and output the sorted array as an HTML table. Here is what I have done so far but it just returns me 'Array': <?php $json='[{"name": "John","age": 23},{"name": "jim","age": 19},{"name": "jason","age": 34}]'; $array = json_decode( $json, true); function cmp( $a, $b){ if( !isset( $a['age']) && !isset( $b['age'])){ return 0; } if( !isset( $a['age'])){ return -1; } if( !isset( $b['age'])){ return 1; } if( $a['age'] == $b['age']){ return 0; } return (($a['age'] > $b['age']) ? 1 : -1); } usort( $array, 'cmp'); foreach ($array as $key => $value) { echo $key.":".$value."\n"; } ?>
  22. I need to store lot of errors separately like $_SESSION['client_error'],$_SESSION['state_error'] etc. According to zend documentation do I have to store it like this for each error? $client_error = new Zend_Session_Namespace(''client_error); $state_error = new Zend_Session_Namespace('state_erro'); and so on? This is my code in the controller. $this->view->state_error_message=$state_error; After I echo $this->state_error in the view I want to unset it.
  23. I thought I had a decent bit of knowledge on PHP/MYSQL, but then I was asked these questions in an interview and I didn't know how to answer them. Googling them didnt give me a satisfactory question. What is one reason someone might choose to use $_SERVER['QUERY_STRING'] instead of $_REQUEST to retrieve URL parameters passed to a page? Let's say you have a page that is making a service call, parsing the response and producing HTML. Your manager is complaining that the page takes 3 seconds to come back. How might you go about troubleshooting this?
×
×
  • 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.