Jump to content

funbinod

Members
  • Posts

    501
  • Joined

  • Last visited

Everything posted by funbinod

  1. i'm trying to set actionbar on my android studio project. while debugging, android studio doesn't show any error but when i run my app, it stops at this line. please suggest me the perfect way of working with toolbar on android studio. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); thank you all in advance.
  2. Hello everyone! I'm very new to JAVA coding and trying to make a simple app using Android Studio V4.1.2. But when I try to debug my app, I encounter an unexpected error. I searched the web for the solution and tried almost everything (like changing gradle version, invalidating cache, etc) that was suggested for others, but my problem was not solved. So I'm here to ask for help. Here are the environments I'm using. build.gradle (app level) plugins { id 'com.android.application' } apply plugin: 'com.google.gms.google-services' // Google Services plugin android { compileSdkVersion 30 buildToolsVersion '23.0.1' defaultConfig { applicationId "app.samaya" minSdkVersion 21 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'com.android.support:support-v4:30.0.0' implementation 'com.android.support:design:30.0.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'com.android.volley:volley:1.1.1' implementation 'com.google.android.gms:play-services-location:18.0.0' implementation 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' implementation platform('com.google.firebase:firebase-bom:26.6.0') implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.firebase:firebase-analytics' } build.gradle (project level) buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:4.1.2' classpath 'com.google.gms:google-services:4.3.5' // Google Services plugin } } allprojects { repositories { google() // and here jcenter() } } apply plugin: 'com.android.application' repositories { mavenCentral() maven { url 'https://maven.google.com' } jcenter() } android { compileSdkVersion 30 buildToolsVersion '30.0.3' defaultConfig { applicationId 'app.samaya' minSdkVersion 21 targetSdkVersion 30 versionCode 1 versionName "1.0" } lintOptions { abortOnError false } } dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'com.google.android.material:material:1.3.0' } Syncing project with gradle file completes successfully but when I try to debug this, I get some error relating to a file in cache folder. Here is the screenshot of the error. I tried almost everything suggested on other forums. But remained unsolved. Please help me to resolve this problem.
  3. hello! is here any discussion forum for android application development? or can i just share my problems on JAVA forum??
  4. thank you for the reply. i already tried to put the position of selected row using "index". but that also returned same problem. but now i solved the problem with a slight change on the above code. i just replaced ------------ .data("selected", 'Y') to .attr("data-selected", 'Y')
  5. hello all i am trying to use 'keydown' function to move through html rows. but i could not succeed. here is what i tried-- $("body").on("keyup", function(e) { if ($("#mid").find(".maintable tr[data-selected='Y']").length == 0) { $("#mid").find(".maintable tr").first().data("selected", 'Y').addClass("thisrow"); } else { if (e.which === 40) { $("#mid").find(".maintable tr[data-selected='Y']").next().data("selected", 'Y').addClass("thisrow"); $("#mid").find(".maintable tr[data-selected='Y']").first().data("selected", 'N').removeClass("thisrow"); } else if (e.which === 38) { $("#mid").find(".maintable tr[data-selected='Y']").prev().data("selected", 'Y').addClass("thisrow"); $("#mid").find(".maintable tr[data-selected='Y']").last().data("selected", 'N').removeClass("thisrow"); } } }) in the above code, '#mid' is a div that holds data retrieved from jQuery.ajax function. below is the backend code data from which is attached to the '#mid' div. $data = "<table class='maintable'>"; $sn = 0; while ($r = $q->fetch_object()) { $sn++; $name = $r->name; $aid = $r->aid; $ac_id = $r->ac_id; $ob = $r->ob; $data .= " <tr data-target='acregister.php?aid=$aid&m=e' data-selected='N'> <td>$name</td> <td style='width: 150px;'>$ac_id</td> <td style='width: 150px;'>$ob</td> </tr>"; } $data .= "</table>"; echo $data; here i want to use up and down arrows to move through the rows retrieved from ajax function. on the rows i've attached 'data-selected' value to know which row is selected. and on each keydown function i want change the 'data-selected' value of next row to 'Y' and change its value to 'N' for the previous one. the above code worked only once. it changed the value for new row but didnot change the value for the previous one and hence when i press down arrow, it selects first row but does not move to next row on another down arrow press. please guide me, what i missed?
  6. thank u for the replay. it worked. its great suggestion. thank u again.
  7. hello all! i'm trying something for binding parameters to a prepared statement like below. $tbl = 'stock'; $cols = 'icode=?, item=?, catid=?, description=?, unitid=?, pprice=?, sprice=?, oqty=?, oprice=?, oamt=?, bcode=?'; // $vals = "'101', 'ASUS H61M-E', 'abcde', '2', '1', '5300.00', '6500.00', '11', '5300', '55528', '101'"; $vals = "101, ASUS H61M-E, abcde, 2, 1, 5300.00, 6500.00, 11, 5300, 55528, 101"; $uq = $mysqli->prepare("UPDATE $tbl SET $cols WHERE $whcol='$whval'"); if (!$uq) { $msg = "Error1: $mysqli->error!"; } else { $uq->bind_param('sssssssssss', $vals); // this doesn't work. // $uq->bind_param('sssssssssss', 101, ASUS H61M-E, abcde, 2, 1, 5300.00, 6500.00, 11, 5300, 55528, 101); // but this works well. if (!$uq->execute()) { $msg = "Error3: $uq->error!"; ///// this says "No data supplied for parameters in prepared statement." } else { $msg = "UPDATED successfully!"; } } here i'm trying to put all the update values into a string and then bind it to the statement. but this says "No data supplied for parameters in prepared statement". but when i use individual values, it works fine. please suggest me something. thanks in advance.
  8. i found that what i learnt so far is also wrong. i corrected the aforementioned code like this $cuidstmt = $pgsql->prepare("SELECT cid, uid FROM user WHERE name=?"); if(!$cuidstmt) { echo "Error: " . $pgsql->errorInfo()[2]; } else { $cuidstmt->execute(array($u)); $cuidstmt->execute(); $cuidstmt->fetch(); } but i still couldn't understand how can i get the result(s). where can i get the data from 'cid' and 'uid' columns mentioned in the prepared statement. thank u all in advance.
  9. hello all! i'm learning postgresql. i was just trying to fetch some data using prepared statement. but found that it is quiet different than mysql. the all i learnt searching on the web is this. $cuidstmt = $pgsql->prepare("SELECT cid, uid FROM user WHERE name=?"); if(!$cuidstmt) { echo "Error: " . $pgsql->errorInfo()[2]; } else { $cuidstmt->bindParam('i', $u); $cuidstmt->execute(); $cuidstmt->fetch(); } but i could not understand how can i print the required data. where the data is stored. just like in mysqli we can bind result on a string, how can i do that in pgsql? can u please help me?
  10. hello all. i was just wondering between these two versions of PHP - 5 & 7. right now i'm practicing on if PHP 5. and now i'm thinking of upgrading to PHP 7. and i want to know if my current code works with the new version or not. if i upgraded my PHP to 7, should i need to change all or some parts of the codes? thank you in advance.
  11. funbinod

    mysql audit trial

    hello all! i was wandering through web to learn about audit trial. but could not find anything from where i can understand this clearly. can anyone please tell me in details about this??? for nowm i want to know two things: 1) is this automatically done by mysql as it's feature or this is my job to maintain the complete activity??? 2) if this is a mysql feature, is this available on all versions??? thank you in advance...
  12. this hint solved my problem. i cheated the code like below. .......... AND projtype IN (SELECT id FROM projcat WHERE under=1 UNION SELECT id FROM projcat WHERE id=1 UNION SELECT id FROM projcat WHERE under IN (SELECT id FROM projcat WHERE under=1)) thank u very very much...
  13. thank you for the reply. but it banged my head. this is beyond my practice and is very tough to understand. can't it be done with a simple modification to my code???? like........ .......... AND projtype IN (1, SELECT id FROM projcat WHERE under=1 UNION SELECT id FROM projcat WHERE under IN (SELECT id FROM projcat WHERE under=1)) thank u again.
  14. hello all! i am struggling with a problem in mysql. i want to select all rows from a table with an id and its child ids. i tried the following ............... AND projtype IN (SELECT id FROM projcat WHERE under=1 UNION SELECT id FROM projcat WHERE under IN (SELECT id FROM projcat WHERE under=1)) it works. But this selects rows that matched the child ids only. i want to select all the rows which use the parent id also (i.e. '1' on the given example). please help me with some hints. thanks in advance....
  15. hi all! after long time i'm back here with a problem. i want to select all data attributes from a div with its name and value using jquery each function use that elsewhere. here is the html for the div. <div class='EW' data-rowid='1' data-unit='' data-workdesc='description' data-vby='2' data-distanceTot='50' data-AVcutTot='500' data-VcutTot='25000'></div> and i tested the following to get my result. var datas = $(".EW").attributes; $.each(datas, function(i,item) { $("#msg").text(item.name + ":" + item.value); }) but i could not get any result. can u please guide me what is wrong? or suggest me any other best method to achieve this. thank you in advance.
  16. thank u. this suggestion solved the problem var remove = []; for (i=enclass; i<=12; i+=enclass) { remove.push(i); } if ($.inArray(parseInt($(this).parent("td").attr("class")), remove) == -1) { $(this).remove(); }
  17. hello all! i was trying to do a for loop to remove all elements that does not meet the for loop. following is the code i tried. $("#feetable input").each(function(e) { var thisvalue = $(this).val(); var enclass = 3; var i; for (i=enclass; i<=12; i+=enclass) { if ($(this).parent("td").attr("class") == i && $(this).val() == thisvalue) { $(this).remove(); } } }) and here is the html <td class='1'><input type='checkbox' /></td> <td class='2'><input type='checkbox' /></td> <td class='3'><input type='checkbox' /></td> <td class='4'><input type='checkbox' /></td> <td class='5'><input type='checkbox' /></td> <td class='6'><input type='checkbox' /></td> <td class='7'><input type='checkbox' /></td> <td class='8'><input type='checkbox' /></td> <td class='9'><input type='checkbox' /></td> <td class='10'><input type='checkbox' /></td> <td class='11'><input type='checkbox' /></td> <td class='12'><input type='checkbox' /></td> this removes the exact elemetns that the for loop finds (i.e. inputs under <td>s with class 3, 6, 9, 12). but my aim is to keep those inputs and remove others. and when i try to reverse the code as below it removes all the inputs. if ($(this).parent("td").attr("class") != i && $(this).val() == thisvalue) { $(this).remove(); } please guide me. thanks in advance.
  18. wow! this solved the problem. i checked for all the tables and found some columns be empty that led to this problem. i corrected them and found that the above code is working properly. thank u for the idea.
  19. thank u for the reply. and sorry for the undefined table screenshots. here i'm again posting the screenshot with some markings. my purpose of this practice is to change the underlined part of the data before copying and the calculation (math) is for that purpose. i'm copying the bordered 4 rows and the math should be applied for all the rows. but it inserted all the rows but only one row with data and rest NULL. and one more thing. i tried to shorten the code and found some interesting results. the following code inserted all the rows with data INSERT INTO projectra (projid, nermid, name, code, per, unitper, description, materials, manerials, macerials) SELECT '$projid', fullid, name, code, per, unitper, description, REPLACE (materials, SUBSTRING_INDEX(materials, ';', -1), ( (SELECT (lurate) FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) ) ), REPLACE (manerials, SUBSTRING_INDEX(manerials, ';', -1), '0'), REPLACE (macerials, SUBSTRING_INDEX(macerials, ';', -1), '0') FROM nerms WHERE fullid='$nid'"); and the following code inserted 2 rows with data and 2 rows NULL INSERT INTO projectra (projid, nermid, name, code, per, unitper, description, materials, manerials, macerials) SELECT '$projid', fullid, name, code, per, unitper, description, REPLACE (materials, SUBSTRING_INDEX(materials, ';', -1), ( (SELECT (lurate) FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) + ( (SELECT uweight FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) * (SELECT rate FROM transport WHERE name=(CONCAT((SELECT ctype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)), '-BLACK TOPPED')) AND cid='$cid' AND active='Y') * (SELECT SUBSTRING_INDEX((SELECT IF ((SELECT itype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1))='L', Ldistance, Fdistance) FROM projects WHERE fullid='$projid'), ';', 1)) ) ) ), REPLACE (manerials, SUBSTRING_INDEX(manerials, ';', -1), '0'), REPLACE (macerials, SUBSTRING_INDEX(macerials, ';', -1), '0') FROM nerms WHERE fullid='$nid'"); the second part of the addition could be any one among the three on the main code. thank u again.
  20. thank u for the reply. but if my explanation above was unclear i again explain - columns with data also converts to NULL except one row. you can check those two screenshots.
  21. i was trying to insert rows from one table to another and edit values before inserting. for that i did the following INSERT INTO projectra (projid, nermid, name, code, per, unitper, description, materials, manerials, macerials) SELECT '$projid', fullid, name, code, per, unitper, description, REPLACE (materials, SUBSTRING_INDEX(materials, ';', -1), ( (SELECT (lurate) FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) + ( (SELECT uweight FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) * (SELECT rate FROM transport WHERE name=(CONCAT((SELECT ctype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)), '-BLACK TOPPED')) AND cid='$cid' AND active='Y') * (SELECT SUBSTRING_INDEX((SELECT IF ((SELECT itype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1))='L', Ldistance, Fdistance) FROM projects WHERE fullid='$projid'), ';', 1)) ) + ( (SELECT uweight FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) * (SELECT rate FROM transport WHERE name=(CONCAT((SELECT ctype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)), '-GRAVELL')) AND cid='$cid' AND active='Y') * (SELECT SUBSTRING_INDEX(SUBSTRING_INDEX((SELECT IF ((SELECT itype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1))='L', Ldistance, Fdistance) FROM projects WHERE fullid='$projid'), ';', 2), ';', -1)) ) + ( (SELECT uweight FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)) * (SELECT rate FROM transport WHERE name=(CONCAT((SELECT ctype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1)), '-EARTHEN')) AND cid='$cid' AND active='Y') * (SELECT SUBSTRING_INDEX((SELECT IF ((SELECT itype FROM items WHERE fullid=SUBSTRING_INDEX(materials, ';', 1))='L', Ldistance, Fdistance) FROM projects WHERE fullid='$projid'), ';', -1)) ) ) ), REPLACE (manerials, SUBSTRING_INDEX(manerials, ';', -1), '0'), REPLACE (macerials, SUBSTRING_INDEX(macerials, ';', -1), '0') FROM nerms WHERE fullid='$nid'"); this works very good - calculates and replaces the exact point as expected. but the problem is it calculates only one random row and lefts other to be NULL. for example, if there are 4 rows that meet the condition, all the 4 rows are copied but only one row contain the expected data and others are left to be NULL. i've submitted 2 screenshots of phpmyadmin showing 2 tables - first one is from which i am coping data (there you can see data on cells) and another is of next table after the copying data (there you can see NULL on cells). thanks in advance...
  22. PHP error is enabled. and there is nothing added on error log of my cpanel. the only thing happens when i post the csv file is - "Aw, Snap" page. its so much confusing. it works very fine when i use LOAD DATA method.
  23. i've posted the screenshot. it just displays "Aq, Snap!" DEV TOOLS also disconnects. and yes! the file upload is done through jQuery ajax. when i check manually, the file uploads but the mysql inserting part is not executed. and i found some mistakes on my code. i corrected it as following. but it still is not performing the action. $q = $mysqli->prepare("INSERT INTO projects (name, ctrtype, budhead, code, wardno, govallo, startdate, enddate, fy, cid, uid) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); if (!$q) { echo "<div id='success'>NO</div>"; echo "<div id='msg'>Error: $mysqli->error</div>"; } else { $q->bind_param("siisidssiii", $prjname, $ctrtype, $data[2], $data[3], $data[4], $data[5], $data[6], $data[7], $ay, $cid, $uid); if (!$q->execute()) { echo "<div id='success'>NO</div>"; echo "<div id='msg'>Error: $q->error</div>"; } else { echo "<div id='success'>YES</div>"; echo "<div id='msg'>SUCCESSFULLY INSERTED DATA IN FILE!</div>"; $_SESSION["msg"] = "SUCCESSFULLY INSERTED DATA IN FILE!"; } }
  24. because i want to filter data supplied in the csv file.
  25. hello all! i am trying to upload and insert data on a csv file to mysql. it uploads but could not insert data to mysql. following is the work i've done. $handle = fopen($targetpath, 'r'); $firstline = true; while (($data = fgetcsv($handle, 5000, ',')) !== FALSE) { if (!$firstline) { $continue = true; if ($data[0] == "" && $data[1] == "" && $data[2] == "" && $data[3] == "" && $data[4] == "" && $data[5] == "" && $data[6] == "" && $data[7] == ""){ $continue = false; } if (strlen($data[0]) != strlen(utf8_decode($data[0]))) { $prjname = ($data[0]); } else { $prjname = strtoupper($data[0]); } if ($data[1] == "CONTRACTOR") { $ctrtype = 1; } else if ($data[1] == "USER COMMITTEE") { $ctrtype = 2; } else { $continue = false; } if (!is_numeric($data[2])) { $continue = false; } if ($continue == true) { $q = $mysqli->query("INSERT INTO projects (subdate, name, ctrtype, budhead, code, wardno, govallo, startdate, enddate, fy, cid, uid) VALUES ('$subdate', '$prjname', '$ctrtype', '$data[2]', '$data[3]', '$data[4]', '$data[5]', '$data[6]', '$data[7]', '$ay', '$cid', '$uid')"); if (!$q) { echo "<div id='success'>NO</div>"; echo "<div id='msg'>Error: $mysqli->error</div>"; } else { $q->bind_param("siisidssiii", $subdate, $prjname, $ctrtype, $data[2], $data[3], $data[4], $data[5], $data[6], $data[7], $ay, $cid, $uid); if (!$q->execute()) { echo "<div id='success'>NO</div>"; echo "<div id='msg'>Error: $q->error</div>"; } else { echo "<div id='success'>YES</div>"; echo "<div id='msg'>SUCCESSFULLY INSERTED DATA IN FILE!</div>"; $_SESSION["msg"] = "SUCCESSFULLY INSERTED DATA IN FILE!"; } } } } $firstline = false; } unlink($path); can u please guide where i did mistake??? thank u in advance..
×
×
  • Create New...