Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. I am building a web app where the user will select booking slots/hours. The question is what column type the db table will have that is going to accept those entries. My understanding is that since we ARE NOT RECORDING an instance of time, that it should be just VARCHAR. I mean the user, in essence, will select strings(because the time slots depicted) will be just strings, as such, I think that as strings these must be passed to the db. What do you think?

    • Like 1
  2. CrId is the primary key and what I get is very very weird. If in the form I update only the phone everythingis OK(I must stress hear that I am updating phone and email). But the weird begins when I go to update the e-mail.I get an empty array back-I need to say also that the results of the query are passed to an array-see the code to understand what I am talking about:Here is the update function:

    function update_contact_details($post,$email,$conn)	    {   	   		 $updatecont=array();		 $phone=mysql_real_escape_string($_POST['phone']);		 $email= mysql_real_escape_string($_POST['e-mail']);		   		 $conn->set_charset("utf8");		 $result = $conn->query('update busines_users,credentials								    set phone="'.$phone.'",email="'.$email.'"								    where busines_users.crID=credentials.crID								    and credentials.email="'.$email.'"');				 if (!$result){		 throw new Exception('Aδυναμία σύνδεσης με την βάση.');		 return false;		  }		 else{ $result1 = $conn->query('select busines_users.phone,credentials.email										    from busines_users,credentials										    where busines_users.crID=credentials.crID		 and credentials.email="'.$email.'"');				 }		  if (!$result1){		 throw new Exception('Aδυναμία σύνδεσης με την βάση.');		 return false;		  }		 elseif( $result1->num_rows>0)		 { $updatect=$result1->fetch_object();	   		  $updatecont['email']=$updatect->email;		  $updatecont['phone']=$updatect->phone;				 }		  return $updatecont;		 				 }

    And here is the code that calls the function:

    if(isset($_POST['contactupdt']))//this here means that the user just pressed the update/save form button-it has name="'contactupdt"					   {					   $updatecont=update_contact_details($_POST,$_SESSION['valid_user'],$conn);					    var_dump($updatecont);					   foreach ($updatecont as $contactdls)					    {echo $contactdls.'<br>';}					   }

    Thanks

  3. You can use any unique column to identify the record to update.
    to understand precisely what I am talking about here is the query-sorry for not showing it earlier:
    update busines_users,credentials                                     set phone="'.$phone.'",email="'.$email.'"                                    where busines_users.crID=credentials.crID                                    and credentials.email="'.$email.'"'

    Just tell me your opinion if the above "makes sense"-focus on the email part.

  4. Let us suppose the username wants to change the e-mail he has given-which means updating the e-mail in the database. As I see one way to target the specific email of the specific user is the password And another is with the e-mail itself. IS my second statement correct? meaning targeting with a query the e-mail in order to update it the same time.

  5. That's not weird. Like the documentation for next_result says, it returns a boolean value. True prints as 1, so it is returning true just like the documentation says. It doesn't return the result, it moves the internal result pointer. Look at the examples on the documentation page for multi_query, it shows how to use store_result to get the current result and loop through it.
    first of all thanks for anwsering.2nd, you are right in what you say. 3rd. I did something else after all-I think it does not worth it using multi_query for only 2 queries-unless you have different opinion about it.
  6. If you go to to the jquery site you will see in the header 3 big icons,lightweight footprint, css3c compliant,cross-browser The last icon on hover rotates. Is this css3?- Because I cannot find any indication that it is-by watching in the code(chrome developers toools)

  7. I am trying to use the mutli_query method and the problem is that I am having difficulty in retrieving the results from the db. We are talking here about 2 queries, an update and a select, with the latter being the last performed. Αs I see it I will have ti use more_result and next_result to get the results from the db. But my main question is how am I going to pass the result from next_result to an array of my choice? So far I used something like this:

    if( $result3 ->num_rows>0)			 {$wwwaddress=$result3->fetch_object();			$updateaddrs['wwwaddress']=$wwwaddress->wwwaddress;

    How next_result can be used in accordance with the above? And here is the code I am trying to implement:

    if ($conn->multi_query($query))    { if ($conn->more_results())    {	    $updateaddrs['wwwaddress']=$conn->next_result();    }   }

    The above prints 1...weird

  8. Null is not the same as an empty string. Both null and an empty string are valid values to use in a query as long as you set up your field to allow those values.
    Then it comes down to the question:Use NULL or an empty string in the database?
  9. Ok I understand about the printing-if it is empty no printing. But what about the db? Can there be any complication if the property has an empty string?Can NULL be set on a property during UPDATE(in the case the user does not fill age as I state in the post above)?

  10. It all depends how you wrote the code whether or not an empty string is going to cause an error in your code.
    can you be more specific?Currently I do not get an error. When I select the age from the database and pass it to an array(along with other data fron the same table)so as to be printed in the browser, age is not shown-no errors appear. What happens is that empty string occupies some space in the HTML element,nothing more. What do you suggest after saying the above?
  11. you can update the age directly. you can set it as NULL to represents user has not entered anything or deleted age data.
    You mean I will set it to NULL when the table is first created or with the UPDATE query? But most importantly if I update directly the db will end up having an empty string in the age column. I do not know if this is good or bad for the db. WHat do you think?
  12. If the user decides he wants to delete some data about him in the database-his age for example. And the above being done through a form. What is the strongest indication that indeed he wants to delete info? From my experience so far I have seen that this is achieved(from a user point of view) by deleting the corresponding entry in the form field. Programmatically speaking am I going to search for an empty string in the corresponding field(age in our example) andif true make a DELETE query? Is this the way?

  13. I just noticed-by running tests- that in order for a web address to pass the php validation url filter it MUST be accompanied by the "http" in the beginning of the url. That said www.xxxx..com will not PASS the filter. From my point of view I think I must write extra checks because the user might write the web address without the "http". What do you do in a similar situation like this?

  14. Diff what was submitted vs. what is in the DB and dynamically build the UPDATE query?
    How am I going to dynamically build the update query? Can you give a code example using array_diff?My current method is to update all the fields again regardless if all of them actually have been updated by the user.The form fields that were not updated/edited by the user will be re-entered(updated) in the db as they were. Unless you have to propose a different method.
  15. This is a javascript code example:

    var object = {    'foo': 'bar'},num = 1;

    Does num has anything to do with the object creation above?The brackets(I think) mean the end of the declaration of the objectbut the comma after the closing bracket manages to confuse me. So...I little help is needed here.Thanks

  16. You can deploy a fallback without much of effort if you plan it well. so why not give a chance to user for graceful degradation. your user still can use the app even if they don't have JS (like mobile users). you can set a warning message though to notify user that they are using degraded version of your site.
    Υοu have a point in what you say. I did not know mobile does not support JS. Meaning that I must also build a native app for such platforms.Of course the only issue, is the extra effort, it took me a lot of time to build the server side validation functions of my form(which is not smal)-now I have to do it also in js. But that is inevitable... So, concluding, IS this the workflow for a form with both js and php validation.
    1. JS client validation
    2. AJAX call to the server to transfer the data
    3. Server-side validation

    Are the above correct?

  17. Since I am building a web app me to I am thinking seriously if I should follow the same route such as facebook or other sites that DO NOT work with Js disabled. My app is NOT such interactive like facebook but it is a single page app(which means heavy use of javascript) and many features will loose the user friendliness if they are done with server code also. Overall, with server code , my app will lose much of its responsiveness.For example it contains a calendar and imagine the user picking/creating eventswith server code...it will be sluggish. What do you think now I gave you some more details about my app.

  18. THIS IS WHAT I WAS EXPECTING TO LISTEN. Writing all these queries is NOT efficient programming.I might post again about it since I have never used array_diff and some help might be required. And something else...in what case we would want to see the difference between what is submittedand what is in the db? Just give me an example-nothing more. Thanks

×
×
  • Create New...