Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Everything posted by jimfog

  1. let me explain... Ajax based solution: The result of the select statement is returned from the server as JSON....and js cript handles the rest-DOM manipulation. PHP-based solution: PHP is embedded in the markup to handle the result of the SELECT statement. I opted for the second solution for simplicity sake despite the fact that much code in my app is js(backbone)
  2. They are relevant...not the same.
  3. There is one thing that bothers me though...do you think the implementation should be JS based or PHP based?
  4. you were right...instead I tried this.... SELECT holid_date from holidays WHERE holid_date >=(?)and holid_date <=(?)' I specify a column... The only problem is that instead of getting all the dates I should be getting(within the interval specified by beg_date and end_date) I get only the first one. probably the problem will be solved if I use a while loop...what do you think?
  5. I have the following query SELECT * from holidays WHERE holid_date >=(?)and holid_date <=(?)' I just want to select a range of dates from a table between the two dates given(beg_date and end_date) Here is some code related to the prepared statement I try to use for it: $stmt->bind_param('ss',$beg_date,$end_date); $stmt->execute(); $stmt->bind_result($dates); $stmt->fetch(); trying to run the above I get this error: Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:Apache24htdocsAppointmentsAdministratoradmin_db_code.php on line 398 I assume I get this error cause a range of values get passed to dates....anyway...how can I write a prepared statement for such a query...I use mysqli.
  6. This is what I had in my mind too...thanks
  7. I have created a calendar table where it contains all the dates of 2015 plus the holidays and I want to do the following: I want to find if holidays exist for the current week...is this possible...using the date object maybe? And obviously I will have to use SELECT statement for the calendar.... I hope you understand what I mean.
  8. Suppose I have a page with some input elements...some are disabled some other are non-visible. What conditional should I write to test for the above case...based on this fact I want to perform an action. Saying it with another words....how am I going to test that the page DOES NOT have visible and non-disabled input elements An example https://jsfiddle.net/fiddlehunt/weveks9f/32/ ...one input is disabled and the other is hidden. I tried to use the code in line 32 but it does not test for that....
  9. I have an array like this one: $weekdays_all=['monday'=>NULL,'monday_b'=>NULL,'tuesday'=>NULL,'tuesday_b'=>NULL.etc]; I want to extract all the _b days from it and push them into a new array... $b_days=['monday_b'=>NULL,'tuesday_b'=>NULL]; How I am going to do it?
  10. I have these 2 arrays: array(5) { [0]=>string(6) "sunday"[1]=> string(6) "monday" [2]=>string(7) "tuesday"[3]=>string(6) "friday"[4]=> string(8) "saturday"}$hidd_days=[0=>'sunday',1=>'monday',2=>'tuesday',3=>'wednesday',4=>'thursday',5=>'friday',6=>'saturday']; I want somehow to merge these two arrays but in the following manner: In this 3rd array there will only be the weekdays mentioned in the first array but their keys will be the one corresponding in the second array...such as this: $third_array=[0=>'sunday',1=>'monday',2=>tuesday,5=>friday,6=>'saturday'];
  11. yes..that is the cause of the problem..thanks.
  12. here is the var_dump...again...you were I right I had not included a member(my mistake)...and probably this is causing the problem...but I am not sure...I want your opinion too. If this 8th member is causing the issue....I would like to here some explanation: array(8) { ["sunday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["monday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["tuesday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["wednesday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["thursday"]=> array(2) { ["open"]=> string(5) "10:30" ["close"]=> string(5) "16:30" } ["friday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["saturday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["id"]=> int(8)}
  13. I am trying to create a prepare statement where multiple rows will be updated(7). I am using a foreach loop to do that where I am accessing the contents of an array(these contents are to be inserted to the DB). here is the loop: foreach ($times as $day => $hours) { $stmt->bind_param('ssis',$hours['open'],$hours['close'] ,$id,$day); $stmt->execute(); } here is the output of $times...it is a multidimensional array: array(8) { ["sunday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["monday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["tuesday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["wednesday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["thursday"]=> array(2) { ["open"]=> string(5) "11:00" ["close"]=> string(5) "17:00" } ["friday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } ["saturday"]=> array(2) { ["open"]=> NULL ["close"]=> NULL } the above is to show we are dealing with an array indeed. And here is my problem: I get this message: Cannot use a scalar value as an array in the bind_param statement regarding $hours['open'],$hours['close']... it does not make any sense...what do you think?
  14. you were absolutely correct...there was a query pending...I just used stmt->close to close the connection there...once done there was no problem any more. It is the first time I encountered such an issue.
  15. below is a function that updates a user's phone: function update_phone($connection,$phone,$sessioneml){ $connection->set_charset("utf8"); if($stmt = $connection->prepare( 'UPDATE business_users SET phone=(?) WHERE (SELECT users.user_ID FROM users WHERE users.user_ID=business_users.crID and users.email=(?))' )) { $stmt->bind_param('ss',$phone,$sessioneml); $stmt->execute(); if($stmt->errno!==0) { error_log("error message for ajax_update-phone()-execution failed:".$stmt->error."for buser:".$sessioneml.",time of error:".date('d F Y h i')." n", 3,"error_log.log"); mail_error($sessioneml,'941');return false; } } else { error_log("error message for ajax_update-phone()-prepare failed:".$connection->error."for buser:".$sessioneml.",time of error:".date('d F Y h i')." n", 3,"error_log.log"); mail_error($sessioneml,'948');return false; } return true; } it seems though that the connection to the dbase never takes place... I get error executing query at $connection->set_charset("utf8")....even if I remove this line...the update query beneath never takes place... var_dump $connection gives this: object(mysqli)#1 (19) { ["affected_rows"]=> int(-1) ["client_info"]=> string(79) "mysqlnd 5.0.11-dev - 20120503 - $Id: 1514feb3700aa52d513182fcdc87f2c66f06d152 $" ["client_version"]=> int(50011) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(2) ["host_info"]=> string(20) "localhost via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(6) "5.6.15" ["server_version"]=> int(50615) ["stat"]=> NULL ["sqlstate"]=> string(5) "HY000" ["protocol_version"]=> int(10) ["thread_id"]=> int(149) ["warning_count"]=> int(0)} I do not see any error above.... Lastly the function you see above is contained in another function....I do not want to include it yet...so as to avoid complexity. I just want you to tell me what can you make out of the var_dump output?
  16. Thanks...actually I was using times in another version of the code....something I had forgotten to do for the code you see in my post. That other version of course is not what is displayed in your post....meaning my code was wrong either with times in it or without it.
  17. I am using a foreach loop within foreach to iterate through a multi-dimensional array. foreach ($content as $key=>$v1) { foreach ($v1 as $times) { print_r($v1['day'].$v1['open'].$v1['close'].'<br>'); }} this array is the seven weekdays and each weekday is another array containing the the open/close times of a store(13:00-14:00 for example) It looks something like that...the first member for example ['monday']=>['day'=>'monday','open'=>'13:00','close'=>'14:00'] there are occasion where the store is closed and in the place of open/close there are empty strings.... despite though having the browser printing an empty string......the browser just prints the key name...Monday for example why this happens?
  18. jimfog

    logging

    I assume that mean using the ordinary php mail function.
  19. jimfog

    logging

    What do you use in order to send an email to notify about an error.
  20. jimfog

    logging

    yes...this is what I was thinking...I have a question though. Cause I want to write to a file and send an email I am calling error_log twice.like this: $headers = 'Content-type: text/html; charset=iso-8859-1' . "rn"; error_log("error message for insert appt()-execution failed:".$stmt->error."for buser:".$email.",time of error:".date('d F Y h i')." n", 3,"error_log.log"); error_log("error message for insert appt()-execution failed:".$stmt->error."for buser:".$email.",time of error:".date('d F Y h i')." n", 1,"...@...r",$headers); Nonetheless....I do not get any email(which is hidden here for obvious reasons)...is there anything wrong with the syntax here? If nothing is wrong with the syntax then there must be something wrong with my e-mail configuration in my local machine
  21. jimfog

    logging

    If there is one thing I have not considered so far is logging. So,first,take a look at this code: if ($stmt = $connection->prepare('INSERT into appoint_servi_chosen (app_ID,service_ID) VALUES( ?, ? )')) { $stmt->bind_param('ii',$lastid,$value); $stmt->execute(); if($stmt->errno!==0) {printf("Error-execution failed appoint_servi_chosen table: %s.n", $stmt->error); return false; } $stmt->close(); } else {printf("Error-prepare statement failed appoint_servi_chosen table: %s.n", $connection->error); return false; } } there are 2 cases above where an error is printed in the browser. I think that this code must be replaced by code that does logging but I have no idea from where to start. Do you know any library for example? Is there something else I need to consider?
  22. I have the following prepared statement json_encode error checking code: ...$stmt->bind_param('siisi',$name,$start,$end,$origin,$staf,$bookedfor); $stmt->execute(); if($stmt->errno!==0) {printf("Error-execution failed : %s.n", $stmt->error); return false; }... How I could possibly json_encode the above error? The point here is that a conditional "waits" in the client to evaluate such an error. I cannot do that with the way the code is above. I do see the warning message being sent from the message but it is worthless...I want to take a specific action based on it.
  23. I want to concatenate a string with an INT...if I do that...the result is a string...for example: $int=5;'john'.$int;//this will output 'john5' I want this though: $int=5;'john'.$int;//this will output 'john'5 In other words...the integer remains an integer...no casting taking place.Is that possible?
  24. I want to a comment regarding this piece of code: $result = $stmt->execute(); if($result) { // The query was successful // Make a variable $serviceID for the result $stmt->bind_result($serviceID); Instead of the above I use this: $stmt->execute(); if($stmt->errno!==0) {printf("Error-execution failed-GET appt_failed: %s.n", $stmt->error); return false; } And another thing is that I do not see anywhere the code for closing the connection....stmt->close
  25. It seems you are right....I created a global variable for testing above the code where it is supposed to be used and it worked without problems. So the problem now is how to execute parse...if you go at line 181 at the jsbin you will see var events = new Events(); maybe the above code nust go above the model where package is to be used...I am not sure...I am just thinking.
×
×
  • Create New...