Jump to content

ajoo

Members
  • Posts

    871
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ajoo

  1. Hi Ch0cu3r, Thanks for the hints and the tutorial. Much obliged. data_seek seems to be the way out I think. Thanks for the pointers.
  2. Hi vinny ! thanks for the response. OK so I was just trying to create a data entry form you know. Where an operator will key in entries to the data base via this form. He can do that one at a time. Then he may need to edit one of those entries at a later time. So he may need to search for a record and find the entry he wants to edit. The search can generate many entries in case he is not sure , say of the exact entry id or the name of the concerned person in that entry whose form he wants to edit. So a LIKE search query can generate many search entries and he may need to step thru each one before he finds the one he wishes to edit. I hope I am able to explain & make you understand the problem now. Thanks
  3. Hi trg, I am trying to use Session variables. Will let you know if i succeed. Thanks.
  4. Hi Trq, Thanks. Is that a no to static variables as well? If I cannot use static variables then the only option I see is to use $_SESSION variables. Would that be elegant? I am going back and forth between a form draw and the corresponding code depending upon one of the two buttons pressed. The count of the record is important for both the buttons. When i go thru one routine to the form and back to the routine, i lose variable values? I wonder if this is comprehensible. lol. So I am stuck Thanks
  5. Hi all, I want to know if PHP can handle button clicks like javascript. If i did not wish to use javascript in php is there a way for me to achieve it. Also I would like to know how I may define a static variable whose value 'sticks' unless incremented or decremented specifically . Thanks loads
  6. Thanks guys ! I'll try thr first 2 but i am not sure I understand pagination. Would be happy if Guru mac_gyver can explain that concept a bit in detail. Thanks loads
  7. Hi guys, I am stuck with this seemingly simple problem. I run a query on a MYSQL database and say it returns 4 rows of result. Now every where on the net I have found that this result can be stepped through using a while loop. But if i wanted to step through this loop one at a time and wait like at the end of each loop before proceeding further how can that be done? OR say I wanted to go to the 3rd result in the result set and display it and then GO BACK and display the 2nd result how can i do so. This would be a great help if someone can provide a solution Thanks all.
  8. Thank you sir !! In fact i found another method which I'll post here echo strtotime('2011-02-27 02:04:46'); // 1 SAME AS BARAND - THANKS $dt = new DateTime('2011-02-27 02:04:46'); // 2 echo $dt->format('U'); Thnaks loads. hope this will help some more like me.
  9. Hi guys, I found that this much asked question on the net has no real straight forward answer. So i ask this again. $date = ('2013-07-08 12:30:30'); how can i change this date to a Unix time stamp in the simplest possible manner just as it is possible to convert a timestamp to datetime in one line. Thanks to all again.
  10. How can I know what my timezone is ? I have apache server installed on my machine and the time that my Apache server gives me is different from the system time on my machine. To be exact. The time showing on my machine is 12.50 PM on 10th Aug, 2013. but the time given to me by the Apache server is 2013-08-10 09:20:45 where the time is 9.20 AM. So it shows a time difference of about 3.30 hours. How can I resolve this? Where should I make the changes to adjust the server time correctly? Ok nevermind this one, I got it. <?php $timezone = "Asia/Calcutta"; if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone); echo date('d-m-Y H:i:s'); ?> Next I'll do the time calculations. Thanks all !
  11. Hi guys, Thanks for the reply. I agree with cyber robot about the users who maybe able to cheat by changing the system clock so i prefer to use the server time instead. I am sure there would be ways in php, & yes I want to use only php and not java script ( having spent like 4 months to get the hang of php I don't wanna digress into javascript - nothing against javascript otherwise !! ), to make adjustments for the local time of the user. So can you or anyone suggest how i can do this in php. I need the code for time bcos i find the timestamp and conversions a lil tuff to program, there being so many ways to do a thing like this. I know it has to be sth like as is suggested by denno020: In terms of php $lastLogout = date("Y-m-d H:i:s"); if (task over) {$nextValidLogin = date(Y-m-d 24:00:00);} $diff = $nextValidLogin - $LastLogout; I hope I am correct and if I am then please some Guru may help me code this. Thanksssssss !
  12. Hi all code Gurus I am writing a small user login routine. It checks when a user has logged in and finished a task. The user can login multiple times before the task is over. However once its over the user can login only the next day. That is only once a new day begins. But when the user tries to login again after the task is over, it needs to tell the user after how many hours and minutes the user may login again. I am storing the login time as datetime formatted (Y-m-d H:i:s). So suppose the user logged in today at 4.00 PM and finished the task , the user can then login after say 00.01 AM or after its 1 minutes past the new day. Since that time, if the user logs in again, he / she needs to be told after how much time the new login can occur. Please can someone help me with this. Thanks.
  13. Hi guys and let me say this that i desperately need help on this seemingly no problem at all !! Ya so I am back again with another head swirler, at least for me. Needless to say I have been trying to figure it out for 2 days now and I was sure I cud do it without help but guess it was I was totally wrong & this is proving to be a most sly problem, one that refused to budge. So i have a Flash layer called TIMER where I have the code to display the timer and this layer also processes the time code where it uses variables like myMinute and mySeconds to hold minutes and seconds. It uses these two to store the time and then uses these to find the time elased till a BUTTON is pressed. This BUTTON triggers the handler (onPress()) which has a function say send_values() to create a set of values to send to the php. The function send_values() is described / written in the Actions Layer. Inside this layer, the two variables mySeconds and myMinutes are used to send the time to php using a variable lv1.time_in_seconds = myMinites*60+mySeconds; like this lv1.send(path+"data.php", "_blank", POST" ). ======= DEFINED IN FLASH======== var mysec:Number=mySeconds; // 20 var mymin:Number=myMinute; // 2 var vTimNsec=mymin*60+mysec; // 140 ========= SENT TO PHP =========== lv1.v_time_in_seconds = mysec; lv1.v_sums_correct = mymin; lv1.v_delay_digit_ms = vTimNsec; If I run this in the Flash (2.0) IDE and trace the values (DEFINED IN FLASH) OR display the values in a dynamic text box, I am shown the correct values. Then I send these values to PHP thru the array lv1 using the command lv1.send(path+"data.php", "_blank", POST" ); Now if i run this from a localhost with the flash embedded in the HTML file I get values vis_sum_corr = undefined // This is mymin vis_sum_tme = undefined // This is mysec vis_dig_dely = NaN // This is (mymin*60+mysec) Ok another thing that I did was that i checked the values of the variables in Flash with isNaN function and it gave me FALSE !! So the values displayed in Flash are displayed absolutely correct and the moment I send them to PHP they are changed to undefined and NaN. Has me totally zapped. Ok another thing that i checked. If i replace the variable values by numeric constants as below, ======= DEFINED IN FLASH======== var mysec:Number= 20; var mymin:Number= 2; var vTimNsec= 140; and send these to PHP, IT DISPLAYS THE CORRECT VALUES !!!!!!!!!! Can someone please guide me what is going on here and what could be going wrong. I have gone nuts trying. Desperately need some gurus to sort this out. Please help !!! Thanks all.
  14. Hi guys back again with another head swirler, at least for me. Needless to say I have been trying to figure it out for 2 days now. And I was sure I cud do it without help but guess it was a very sly one who refused to budge. So i have a Flash layer called TIMER where I have the code to display the timer and this layer also processes the time code where it uses variables like myMinute and mySeconds. It uses these two to store the time and then uses these to find the time elased till a BUTTON is pressed. This button triggers the handler (onPress()) which has a function say send_values() to create a set of values to send to the php. The function send_values() is described / written in the Actions Layer. Inside this layer, the two variables mySeconds and myMinutes are used to send the time to php using a variable lv1.time_in_seconds = myMinites*60+mySeconds; like this lv1.send(path+"data.php", "_blank", POST" ). ======= DEFINED IN FLASH======== var mysec:Number=mySeconds; var mymin:Number=myMinute; var vTimNsec=mymin*60+mysec; ========= SENT TO PHP =========== lv1.v_sums_correct = mymin; lv1.v_time_in_seconds = mysec; lv1.v_delay_digit_ms = vTimNsec; If I run this in the Flash (2.0) IDE and trace the values OR display the values in a dynamic text box, I am shown the correct values. BUT if i run this from a localhost with the flash embedded in the HTML file I get values vis_sum_corr = undefined // This is mymin vis_sum_tme = undefined // This is mysec vis_dig_dely = NaN // This is (mymin*60+mysec) So the values displayed in Flash are displayed absolutely correct and the moment I send them to PHP they are changed to undefined and NaN. Can someone please guide me what could be wrong here. I have gone nuts trying. Desperately need some gurus to sort this out. Thanks all.
  15. Hi Mac, I got it working. Since I am using Flash 2.0 its publishing the swf file and things is very confusing. The issue lay with the path. Once i got that correct ( its different for flash IDE and as an HTML invoked by localhost, it worked. Thanks loads since you had that in mind and you gave that pointer to me. Grateful and Thanks again.
  16. hmmm ! well thats where i came from to where I am now. This code was a part of a larger program where the flash was embedded in the html/php. I was facing this issue there ( in the embedded movie page) so i created this separate bit of code to find the problem in the actual program. But since you ask I'll try this now. It wont take any time since flash creates the HTML too. So here i go to flash and will revert the results. OK so like in the actual code movie this movie also returns the absolute same result. The output is the variable $db_val1"; As you can see flash / HTML outputs the variable wid the ending quotes and the semi-colon, whose value it should actually be outputting which in my case should be 4 since thats the value I have sent to the code. The lines which outputs the flash / HTML are these :- lv1.sendAndLoad(path+"testdata.php",lvIn1,"POST"); // sends data values of lv1 variabless and GETS lvIn1 value /////////// for display on a webpage (_blank) /////////////////// lvIn1.onLoad = function(success){ if(success){ w_WS = lvIn1.db_w_var1; w_WT = lvIn1.db_w_var2; w_ST = lvIn1.db_w_var3; w_end = lvIn1.db_w_end; written_data = " WT = "+w_WT; } where written_data is a variable attached to a dynamic textbox. and thats where the value is displayed. Can you detect any problem wid this code here ? Syntax or logic ?? I don't think so but still just in case. Another interesting observation is that if i change on line 34 34. $db_val1=$db_val[0]; to $db_val1=4; the result is still the same !! i.e. $db_val1"; and if I force the value on line 52 as below echo "&db_w_var1=4"; i.e. equate the value to 4 the out put is 4"; !! Isn't that strange ? If that is any help in providing a clue to this one. Thanks again. Please help me solve this.
  17. Hi ! I am not sure what you are asking but I'll say what i am doing now. As of now I am using it through the flash IDE on my machine. I have xamp installed and so a local server exists on my machine. But for this example I am using the flash IDE and running my flash file and trying to get the variables into the flash, In fact thats all I am trying to do as of now in this example. Just to get the right variables loaded and displayed in flash. Part of the flash code is given by me in the first message of this thread. Once i get the flash variables correct I do intend to embed the flash in HTML and host it on a server. Still far from there. I hope I have answered your question. If not please ask more. Thanks Mac n all else who would be interested in taking this on.
  18. Hi, Glad to receive a reply. It is encouraging to know that flash is receiving exactly what php is sending to it. Before I post the code i would like to post the output of my php code. hmmm ok this does not permit me to paste a picture( snapshot) of my output so i'll just write it below: =========== Output of the php file =============== var11=4 var12=4 wsc=4wtt=4 Val1=4 Val2=4 Val3=written &db_w_var1=4&db_w_var2=4&db_w_var3=written&db_w_end=0 ====================================================== The last line of the output shows the correct values but when i check the first value in flash w_WS = lvIn1.db_w_var1; and display this one value in a text field in flash I get $db_val1"; as the output. OK so here is the php file <?php $dt = "data1"; //$_POST["dataType"]; // switch ($dt) { case "data1": $var11 = 4; // $_POST["f_var1"]; // 2; debug 4 $var12 = 4; // $_POST["f_var2"]; // 3; debug 5 $var11 = $var11 * 1; $var12 = $var12 * 1; $send_val = array($dt,$var11,$var12); $db_val = get_val($send_val); // break; case "data2": $var21 = 5; //$_POST["f_var1"]; // 2; debug 4 $var22 = 5; //$_POST["f_var2"]; // 3; debug 5 $var21 = $var21 * 1; $var22 = $var22 * 1; $send_val = array($dt,$var21,$var22); $db_val = get_val($send_val); break; default: echo " Bad Choice - cannot identify $datatype"; } // end switch $db_val1=$db_val[0]; $db_val2=$db_val[1]; $db_val3=$db_val[2]; $d_end='0'; //$dbw_WS = $dbw_WS*1; //$dbw_WT = $dbw_WT/1; //$dbw_ST = $dbw_ST; echo "Val1 =".$db_val1; echo "<br>"; echo "Val2 =".$db_val2; echo "<br>"; echo "Val3 =".$db_val3; echo "<br>"; echo "&db_w_var1=$db_val1"; echo "&db_w_var2=$db_val2"; echo "&db_w_var3=$db_val3"; echo "&db_w_end=$d_end"; ////////////////////////////////////////////////////////// function get_val($vals) { $db = "test"; $table = "testdata"; $con = mysqli_connect("localhost","root","",$db); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $dtype = $vals[0]; echo " VALS = ".$dtype; $query = "SELECT * FROM $table WHERE status IS NULL || status = '0' "; mysqli_query($con,$query) or die (mysqli_error($con)); if(mysqli_affected_rows($con)==1) { //a // $result = mysqli_query($con, $query); $row=mysqli_fetch_assoc($result); mysqli_free_result($result); $id = $row['id']; switch($dtype) { case "data1": $var11 = $vals[1]; $var12 = $vals[2]; echo "---------------UPDATEing VAR1---------------"; echo"<br>"; echo " ID = ".$id; echo"<br>"; echo "var11 = ".$var11; echo"<br>"; echo "var12 = ".$var12; echo"<br>"; $query = "UPDATE $table SET var11 = '$var11', var12 = '$var12' WHERE id = '$id'"; $result = mysqli_query($con, $query); // if($result) // { $query = "SELECT * FROM $table WHERE id = '$id'"; $result1 = mysqli_query($con,$query); // // if($result1) { $row=mysqli_fetch_assoc($result1); mysqli_free_result($result1); // $wsc = $row['var11']; $wtt = $row['var12']; $var_result =array($wsc,$wtt,"written"); // echo "wsc = ".$wsc; echo "wtt = ".$wtt; echo " Record VAR1 Inserted. <br>"; } } else{ echo " NOT INSERTED";} break; case "data2": $var21 = $vals[1]; $var22 = $vals[2]; echo "---------------UPDATEing VAR2---------------"; echo"<br>"; echo " ID = ".$id; echo"<br>"; echo"<br>"; echo "var21 = ".$var21; echo"<br>"; echo "var22 = ".$var22; echo"<br>"; $query = "UPDATE $table SET var21 = '$var21', var22 = '$var22' WHERE id = '$id'"; $result = mysqli_query($con, $query); // if($result) // { $query = "SELECT * FROM $table WHERE id = '$id'"; $result1 = mysqli_query($con,$query); // // if($result1) { $row=mysqli_fetch_assoc($result1); mysqli_free_result($result1); // echo " Row = ".$row; $vsc = $row['var21']; $vtt = $row['var22']; $var_result =array($vsc,$vtt,"written"); // mysqli_close($con); echo "vsc = ".$vsc; echo "vtt = ".$vtt; echo " Record VAR2 Inserted. <br>"; } } else{ echo " NOT INSERTED";} break; default : " Cannot recognise the data"; break; } // end switch } // end if else { $query = "SELECT * FROM $table ORDER BY id DESC LIMIT 0,1"; if($result = mysqli_query($con,$query)) { // j $row=mysqli_fetch_assoc($result); $id = $row['id']; } // j end else die(mysqli_error($con)); // $id = $lastrow+1; echo " Before INSERT "; echo " var11 = ".$var11; echo "<br>"; echo " var12 = ".$var12; echo "<br>"; $query = "INSERT into $table ( var11, var12) VALUES ('$var11','$var12')"; $result=mysqli_query($con, $query) or die(mysqli_error($con)); // echo " After INSERT "; echo " id = ".$id; if(!$result){ die( 'Error: ' . mysqli_error($con)); } else { // k // $query = "SELECT * FROM $table WHERE id = '$id'"; $result1 = mysqli_query($con,$query); // or die (mysqli_error($con)); if($result1) { // l $row=mysqli_fetch_assoc($result1); mysqli_free_result($result1); // echo " Row = ".$row; $wsc = $row['var11']; $wtt = $row['var12']; $var_result =array($wsc,$wtt,"written"); echo "wsc = ".$wsc; echo "wtt = ".$wtt; echo " Record Written Inserted. <br>"; } // l end else { die( 'Record not inserted. ERROR: ' . mysqli_error($con)); } } // k end echo " UPDATING SESSION STATUS "; $query = "SELECT * FROM $table WHERE id = '$id'"; $result1 = mysqli_query($con,$query); // or die (mysqli_error($con)); if($result1) { $row=mysqli_fetch_assoc($result1); mysqli_free_result($result1); $WS = $row['var11']; $VS = $row['var21']; } if($WS==1 && $VS==1 ) // { $query = "UPDATE $table SET status = '1' WHERE id = '$id' "; } $result = mysqli_query($con, $query); // or die (mysqli_error($con)); if($result) // { echo " Updated SessionStatus <br>"; } else echo " Could not Update SessionStatus <br>"; } // end get_val return ($var_result); } ?> Hope someone can help me figure this one. I do feel this is a typecast issue but have no idea how to deal with it. Thanks loads for any help which i desperately need here.
  19. loading variables into flash from a php file. Hi guys. I wonder this has been discussed many times & having gone through many such answers I still seem not to get a reply to my problem. So i have a program in flash, which generates a button which when clicked gets a set of variables from a php file called testdata.php. Now this tesfile.php when run standalone generates correct values of variables & displays them. However when i change it to be able to send it to a flash file ( make changes in echo "&db_w_var1=$db_val1"; ) like this. the values I receive in flash are odd. in fact i get this $db_val1";exactly this for the first variable. I get this string instead of receiving an integer value 4 or maybe even a string value '4'. So can anyone looking at this tell me what could be going wrong. The following is a part of code which calls the php file to get the value of variables: var w_WS; // Database returned Written Sums var w_WT; // Database returned Written Time var w_ST; // Database returned Sum Type ( written or visual or oral) var w_end; lv1.dataType = "written"; lv1.w_sums_correct= w_sums_correct; lv1.w_time = w_time; /////////// for localhost /////////////////// lv1.sendAndLoad(path+"testdata.php",lvIn1,"POST"); // sends data values of lv1 variabless // and GETS lvIn1 value /////////// for display on a webpage (_blank) /////////////////// // lv1.send(path + "sessdata1.php", "_blank", "POST"); // or GET lvIn1.onLoad = function(success){ if(success){ w_WS = lvIn1.db_w_var1; w_WT = lvIn1.db_w_var2; w_ST = lvIn1.db_w_var3; w_end = lvIn1.db_w_end; written_data = " WT = "+w_WT; // " WS = "+w_WS + " Type = "+w_ST + "End = "+w_end; } // end success Thanks to all for any help. This has me losing my brains. please help the gurus.
  20. Thanks Mac for your valuable tips. I will keep that in mind as well as the one regarding connecting to the database time n again. I saw my code and indeed there are instances where i close the database connection and then reconnect at another place. Will change those too. Thanks.
  21. ok i did this $result = mysqli_query($con,$query); $row=mysqli_fetch_assoc($result); $lastrow = $row['id']; echo "Last Row found = ".$lastrow."<br>"; and got the result. All i want to know now is that if there's a shorter way to extract the value of the 'id'. Hope this will help many like me who would like to know how to do this. Thanks.
  22. OK !! Thanks guys. You guys were right ! I found the error and the mistake. There were 2 calls to the function. One was called using the correct table name, while there was a typo mistake in the table name in the 2nd call to the function. Thank you all. Jazzman actually pointed out that I should check the table name and i did without realising that there was a typo in the table name in the 2nd call to it. Then I changed as Mac suggested and there it showed me the typo to the table name. Thanks loads. You guys are fantastic and i hope to learn loads from you. Thanks.
  23. Thanks Mac, I'll try this out and revert. Thanks also for the suggestions regarding the opening of databases. I'll keep that in mind. Will revert with the results of your suggestions. Thanks
  24. SELECT id FROM tbl ORDER BY id DESC LIMIT 1 Kindly show How I might extract the value of id into a variable. Thanks.
  25. hmmm well in what i have in mind, no entry in my table is getting deleted. It kind of proceeds linearly. so the last ID would be the same as the number of rows in this case. I must admit that I am very new to mysql and so my questions might be awkward and possibly there may be better solutions. So i am very open to any ideas that i can get. Again chances of crossed linking is zero because each user has a unique table that can only be manipulated by that very person. I hope that in the light of this reply, the questions that I asked are correct. if there is any way to better to do the same I'ld be happy to learn. Thanks I'll try as suggested by trq.
×
×
  • 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.