Jump to content

Digitizer

Members
  • Posts

    46
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Barcelona
  • Interests
    PHP Development
  • Age
    29

Digitizer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for reply my friend, 1. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // is set as error check 2. If I run delete.php?delete=3 //for example, in browser directly, the script runs fine and deletes the corresponding row from table 3. I have not read the manual yet though
  2. Hello guys, I have been away for a couple of days. Its nice to be back Yesterday night I was practicing an AJAX/PHP delete tutorial and file "delete.php" was wrtiten in mysql* which I converted to PDO but it didnt seem to work after conversion. The three bits of code are as follows //I got the results using PDO::FETCH_ASSOC in following div getting ID of row in link while ($r = $getData->fetch(PDO::FETCH_ASSOC)){ echo (" <div class='record' id='record-".$r['id']."'> <a href='?delete=".$r['id']."' class='delete'>[x]</a> </div> "); } $(document).ready(function() { $('a.delete').click(function(e) { e.preventDefault(); var parent = $(this).parent(); $.ajax({ type: 'get', url: 'delete.php', data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''), beforeSend: function() { parent.animate({'backgroundColor':'#fb6c6c'},300); }, success: function() { parent.slideUp(300,function() { parent.remove(); }); } }); }); }); and delete.php contains include "inc.connect.php"; if(isset($_GET['delete'])){ $id = $_GET['delete']; $query = "DELETE FROM tempdata WHERE id=?"; $runThis = $db->prepare($query); $runThis->bindValue(1,$id); $runThis->execute(); } /*The problem I am facing is in delete.php. because If i run the same script in mysql_*, it works, which is as follows first (I had to write connect in mysql as original connection is written in PDO) ------------------------------------------------------ $con = mysql_connect('localhost','munni****','*******'); mysql_select_db('stockcontrol',$con); if(isset($_GET['delete'])) { $result = mysql_query('DELETE FROM tempdata WHERE id = '.(int)$_GET['delete'],$con); } mysql_close($con); */
  3. Hello, sorry for late reply, I have been busy yesterday. Well, as you pointed out, the checksum actually changed from LTR/RTL ... didnt notice.. lolz.. As luhn Algo says, After all the adittion/multiplication etc, you will come up with 2 digits which you will need to either, 1. Multiple by 9 (it will always give you 3 digits - and last digit is checksum) (e-g 45, 45*9 = 405, [5 is checksum]) 2. From those 2 digits, subtract the last from 10 and you will be left with 1 digit, which is check sum. (e-g 45, [10-5],[5 is checksum]) I used the first logic. And with your writen algo, I am going to try this too Lemme get back to you on this mate
  4. I shall watch a movie now

  5. Thanks for the tip @Jacques1, I am now going to try this as well, Its not about what the logic is about, what i am trying to do is to get the solution as simple way as possible. So I am going to try with different logics making it as short as possible, so I have completed first solution, as follows, if(isset($_POST['submitIMEI'])){ $imei = $_POST['imei']; $odd = $even = array(); $arr = str_split($imei); $oddFinal = array(); // Will hold addition of odd indexed numbers foreach ($arr as $k => $v) {if ($k%2) {$odd[] = $v*2;}else {$even[] = $v;}} // Add all 2 Numbered digits to make them 1 digit foreach($odd as $sepNo){ $first = substr($sepNo,0,1); $second = substr($sepNo,1,1); $total = $first+$second; $oddFinal[] = $total; } $oddSum = array_sum($oddFinal); $evenSum = array_sum($even); $totalAll = $oddSum+$evenSum; $totalFinal = $totalAll*9; $imeiSV = substr($totalFinal,2,1); echo "IMEI: " . $imei . "<br>"; echo "ChkSum: " . $imeiSV . "<hr>"; } echo (" <form name='imei' method='post' action='#'> <input type='text' name='imei' placeholder='IMEI' /> <input type='submit' name='submitIMEI' /> </form> "); I understand the style of writing may be very non professional, if it is so, I humbly request to please point out the mistakes I have done, this will be a great help for me to get me better on writing.
  6. ok, I cannot edit the post now, so this is a little solution I have come up with, getting the alternate numbers into another array using modulus. $imei = "356565451265856"; $lenOfString = strlen($imei); $myArray = array(); $alternateArray = array(); for($i=0;$i<$lenOfString;$i++){ $myArray[] = substr($imei,$i,1); } foreach($myArray as $key => $value){ if($key % 2 == 0){ $alternateArray[] = $value; } } print_r($alternateArray); //Array will get 36641686 So if there was a more convinient solution? if I can get such numbers from $imei directly??
  7. Hello Guys, You might have known about Luhn Algorithm, which is used to get checksum of IMEI of phones, credit cards etc etc. It is a public domain so it is not used for security but to ensure that client has passed the correct numbers etc etc. Anyway, I am trying to get my hands on this algorithm and I will build a logic based on luhn algo to get the checksum, where I am stuck is how can I get the alternate numbers from a numeric string, for example I have written the following code to get all the numbers one by one into the array. $imei = "356565451265856"; $lenOfStr= strlen($imei); $myArray = array(); //Get all numbers one by one in array for($i=0; $i < $lenOfStr; $i++){ $myArray[] = substr($imei,$i,1); } // Checking the array foreach($myArray as $seperatedNumbers){ echo $seperatedNumbers; } No the problem is that I want to select every 2nd number from right to left e-g 5,5,2,... or 6,8,6 How can I get it done? This logic may not be so good, there may be more brilliant solutions to write luhn algo, but I want to try myself once... Thanks.
  8. I am glad it worked mate any that fading out seems to be a JS problem, e.preventDefault() maybe? P.S: you got nice music on
  9. With respect, but I am unable to interpret your query.
  10. I didnt get this error, I tried this on my page and it works without errors $rules_column1 = array( "No prop pushing, or prop killing", "No building in the Skybox", "No prop spamming", "No thruster or turret noises" ); foreach($rules_column1 as $rule){ echo $rule . "<br>"; } /* The Result was No prop pushing, or prop killing No building in the Skybox No prop spamming No thruster or turret noises */ It should have told you which line of code is generating error, note if it is the same line where "No Pro..." exists or is it where you are getting values with a loop?
  11. I once wrote a login script, and put some modules to be displayed to authorized users only, I used cookies though, but to authorize specific users to those certain modules, (giving more control over app) I used another logic without using any OOP approach at all.. The logic was assigning a groupName to each user, "Standard" when user registers which can be changed by superAdmin (hardcoded in program) The pseudo logic I can write here, I know it was a bad practice // All this is just a hinting code, not proper code get_login_details ($username,$password); $query = mysql_query(select * from userTable where username='$username' AND password='$password'); // if a row is returned if(mysql_num_rows($query) == 1){ set_cookie_thing $row = mysql_fetch_array($query); $group = $row['group']; if($group == 'admin'){$isAdmin = true;}else{$isAdmin = false;} } else { die("The username or password is incorrect"); } if(isset($isAdmin)){// display the modules or whatever you want} I had issues at times with this code so dont use such logics, it is just as idea to get you going and may come up with a better idea
  12. are we talking about PHP6/7 here... lolzz... I beleive following thread must have shown up while goOgling... http://www.phpclasses.org/blog/post/242-PHP-7-Features-and-Release-Date.html
  13. something is forcing me to believe the fact that he doesnt have apache/mysqld services runnning, instead trying the files as html would open without any other services
  14. I thought to relax a bit and while i saw something and an idea came to my mind, lets play noobs, it will be fun... we ask noob questions here lolzzz so my question is Hello, I have seen that there are always 3 users /* I know these are bots */ Google, Yahoo and Bing always online and we cannot see their profiles. They must be very professional hackers who have known how to hide their identities.. right??
×
×
  • 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.