Page 4 of 4 FirstFirst 1234
Results 76 to 99 of 99
  1. #76
    Join Date
    Aug 2004
    Location
    Colorado, US
    Posts
    427
    Quote Originally Posted by horizon
    I swear to 'always' use this command in the future for debugging (since I didn't even know what var_dump was useful for before now).
    That alone will be worth the whole thread to you.

    Now show us the rest of the PHP you are currently trying and we can most likely wrap this up.

  2. #77
    Join Date
    Mar 2006
    Posts
    984
    PHP Code:
    if ($action == "send_form") {

    if (isset(
    $HTTP_POST_VARS['user_id'])) {
    $user_id = (isset($HTTP_POST_VARS['user_id'])) ? $HTTP_POST_VARS['user_id'] : NULL;
    } else {
    $user_id NULL;
    }

    if (!
    is_array($user_id)) {
    die (
    'No permission.');

    } elseif (
    is_array($user_id)) {

    $date date("Y-m-d");
    $time date("H:i:s");

    $user_ids implode(","$user_id);
    $user_ids_array explode(","$user_ids);

    $remaining_array array_diff($user_ids_array$user_id);
    $remaining_string implode(","$remaining_array);

    /*var_dump($user_ids_array)."<br />";
    var_dump($user_id);*/

    $sql_update "

    UPDATE table
    SET user_id = '"
    .$remaining_string."'
    WHERE id = "
    .$_SESSION['user_id'];

    $result mysql_query($sql_update);
    }

    if (
    $result) {
    header("Location: myform.php");
    }


  3. #78
    Join Date
    Aug 2004
    Location
    Colorado, US
    Posts
    427
    OK, the trouble here is that my original code snippet was based on your post #9 where you were querying the database to get the current list of numbers, and then updating it. In post #77, your code only updates the database, but never finds out what the current list of numbers is, so it's not going to do what you want.

    Bringing back in a little bit of your original post #9 gives the following, which is more or less what you want. The important thing is not that this code works, but that you understand what it is doing. Then you know how to debug it if it isn't doing what you expect.

    PHP Code:
    if ($action == "send_form") {

    if (isset(
    $HTTP_POST_VARS[URL_USER_ID])) {
    $user_id = (isset($HTTP_POST_VARS[URL_USER_ID])) ? $HTTP_POST_VARS[URL_USER_ID] : NULL;
    } else {
    $user_id NULL;
    }

    if (!
    is_array($user_id)) {
    die (
    'No permission.');

    } elseif (
    is_array($user_id)) {

    $date date("Y-m-d");
    $time date("H:i:s");

    $user_ids implode(","$user_id);

    $sql "SELECT user_id FROM table WHERE id = '" $_SESSION['user_id'] . "'";

    $result mysql_query($sql);

    $row mysql_fetch_array($result))
    $user_id_field $row['user_id'];

    $current_user_ids explode(","$user_id_field);
    $remaining_array array_diff($current_user_ids$user_id);
    $remaining_string implode(","$remaining_array);

    /*var_dump($user_ids_array)."<br />";
    var_dump($user_id);*/

    $sql_update "

    UPDATE table
    SET user_id = '"
    .$remaining_string."'
    WHERE id = "
    .$_SESSION['user_id'];

    $result mysql_query($sql_update);
    }

    if (
    $result) {
    //header("Location: myform.php"); //comment this out until you get the code you already have to work.
    }

    Last edited by inimino; 09-09-2006 at 10:24 AM.

  4. #79
    Join Date
    Mar 2006
    Posts
    984
    Ok. Just tried your version and same results. It returns to it's original page after updating nothing (or perhaps it does update but keeps the exact same readings - can't say).

    Althought, this time, I have re-used the var_dump and here it is:

    PHP Code:
    NULL array(2) {   [0]=>   string(2"on"   [1]=>   string(2"on" 
    It's becoming hopeless.

  5. #80
    Join Date
    Aug 2004
    Location
    Colorado, US
    Posts
    427
    OK, but the most critical line of my post was this:

    The important thing is not that this code works, but that you understand what it is doing.
    Do you understand what the code I suggested is supposed to do, and how that's the same as what you are trying to do? If not, ask questions. Perhaps I misunderstood what exactly you are trying to do, or perhaps you didn't fully understand the code I suggested.

    Next, break the problem down into manageable chunks. Instead of trying to make everything work at once, just try to do this: create two arrays, $current_user_ids and $user_ids_to_delete. Put the values from the current row in the database into $current_user_ids, and the POST values into $user_ids_to_delete. You've had both of these parts working in the past, in other parts of your code. Use var_dump to figure it out.

    Currently it looks like there is a problem with the way you are interpreting the form data, and perhas you var_dumped the wrong variable in the case of the first NULL, else your SQL query is failing.

    Try to understand carefully what your code is doing, and take a break if you are feeling frustrated. Debugging is an acquired taste, and the less experience you have with it, the tougher it is.

    I will be otherwise occupied for the next 12-24 hours but sometime after that I will try to stop by this thread again. Perhaps you can solve this in the meantime.

  6. #81
    Join Date
    Mar 2006
    Posts
    984
    Do you understand what the code I suggested is supposed to do, and how that's the same as what you are trying to do? If not, ask questions. Perhaps I misunderstood what exactly you are trying to do, or perhaps you didn't fully understand the code I suggested.
    Yes, at least I understood it. I coded something similar before creating this topic but yours was more expanded. It appeared that some lines were missing comparing to your version but still results the same though.

    just try to do this: create two arrays, $current_user_ids and $user_ids_to_delete.
    No sorry. This would be beside what I'd be looking for to do. I'm only looking for to do this instantly - all at once.

    Currently it looks like there is a problem with the way you are interpreting the form data, and perhas you var_dumped the wrong variable in the case of the first NULL, else your SQL query is failing.
    Unfortunitely, I cannot see where NULL is coming from. However, what I can say is that the form looks pretty fine since each values are being captured properly. What's only missing is the proper way to call the SQL server properly and make the changes the right way. Otherwise, all seem to work fine (except for that NULL).

  7. #82
    Join Date
    Aug 2004
    Location
    Colorado, US
    Posts
    427
    Quote Originally Posted by horizon
    No sorry. This would be beside what I'd be looking for to do. I'm only looking for to do this instantly - all at once.
    I can't tell if you are being sarcastic, or if you misunderstood me? I am referring to the debugging process, not the code itself. Since it is already 82 posts in this thread without working code, I would say you must admit that your process of writing this code will not be instantaneous.

    Unfortunitely, I cannot see where NULL is coming from. However, what I can say is that the form looks pretty fine since each values are being captured properly. What's only missing is the proper way to call the SQL server properly and make the changes the right way. Otherwise, all seem to work fine (except for that NULL).
    That is a pretty big "except". Another big "except" is that you have an array of "on" and "on" rather than two numbers. This is quite different from the previous var_dump() output you posted. This is my last post in this thread for today, good luck.

  8. #83
    Join Date
    Mar 2006
    Posts
    984
    you must admit that your process of writing this code will not be instantaneous.
    Couldn't agree more there. I can't even remember the date this topic was ever created. Meaning - too long to get this issue resolved I might add.

  9. #84
    Join Date
    Mar 2006
    Posts
    984
    IT WORKS !!!!!!!

    @inimino:

    Thanks very much for your help. Your code responds perfectly well from the targeted action. All is deleting for each IDs from the same row !!!

    This is quite different from the previous var_dump() output you posted.
    Didn't even noticed it was different. Which is why, I took a look at the HTML form again, since it was obvious the mistake was there. I forgot to add the value content with the user_id (but only after you posted your corrections) since I wanted to test something but forgot to replace the value content after the test was done.

    Meaning,

    PHP Code:
    <input type="checkbox" name="user_id[]"
    should read :

    PHP Code:
    <input type="checkbox" name="user_id[]" value="<?php echo $_SESSION['other_id']; ?>">
    I can FINALLY rest !!! - Thanks again for your patience and kind help !

  10. #85
    Join Date
    Aug 2004
    Location
    Colorado, US
    Posts
    427
    Great! Congratulations on finding a solution, I am glad I could help.

  11. #86
    Join Date
    Mar 2006
    Posts
    984
    I guess I spoke a little too fast. Before I left my computer, I made one last test. Everything was fine. Althought, when I went back, the same behavior came back - two fields deleted for one selection for an unknown reason. It has changed behavior without knowing why ...

    Any inputs on why it does so ? I haven't modified scratch since I last reported here . . .

  12. #87
    A bit offtopic: horizon, did you read posts that referred to disfunctional database design and possibilities of innacurate row affection if you were to stay with your current db design or you just looked at posts with allready finished codes?

    I'd like to know since it seems like a waste of time trying to explain the importance of proper db design if you're not interrested.

    Edit: you are also eager to fix syntax errors of code(s) I provided, but it seems you didn't even try them out, nor did you fully understand what I was reffering to in my post. I'd like to know your standing on this, since this is the second thread you've made and you're again dealing with trivial problem and the thread has expanded to 5 pages due to your disinterrest in actually reading, understanding and giving feedback to people who are putting effort into helping you.

  13. #88
    Join Date
    Mar 2006
    Posts
    984
    @maxymizer:

    I totally beg to differ on all your last sentense. The reason why your solution was put aside, even though it was tried out, inimino did post an alternative solution which, first, responded to my needs. Since, I thought it would of remained a stable solution but would seem to have encountered, as mentionned from my last post, some unknown issues along the process. Hopefully, alternative solutions will be posted since I'm not discarding the fact that all of you are adding your inputs into this topic in order justify the best common solution to resolve this problem.

    With that all said, your solutions has not been rejected, as you believe it was from above, but simply reconsidered for alternative solutions, since your suggestions is not quite the solution I'm currently looking for and I have already mentionned it before. It is true to say that more than several posts under topics might be unexpected but, no matter which mount of posts a topic might have, it is always important to follow each posts in order to understand the topic creator's objective.

    Finally, I'm only considering the best solution to what I seek, like all other requesters on this forum. Meaning, even if you believe you're posting the best inputs, doesn't necessary means that the requester wishes to accept your recommendation directly. Decisions has to be considered first as evaluations needs to be made for each posted codes on this topic.

    In the mean time, I believe it is quite the case here - to state that you aren't the only one recommending strategies in order to finalize this subject.

    In other words, even if your inputs are still appreciated, it would be also helpful if you could recommend other subjects than single IDs from each rows, since I know my solution is typically possible to be achieved as I intend to maintain that objective. To be honnest, even if you post your inputs, it doesn't mean that the requester will use it - not because it might be a bad input but simply because it isn't the kind of answer she / he expecting for.

    Rather than arguing longer over this, I'd rather wish to wait for inimino's inputs on this. Of course, if no inputs has been posted for a while, it would still be great to receive answers to what I'm trying to accomplish - on the right track.
    Last edited by horizon; 09-09-2006 at 08:34 PM.

  14. #89
    You are jumping to conclusions. I never stated that my solution was the best and the only one, as you have concluded.

    I know what's your objective but you are just too stubborn to read + understand. I could have argumented the solution I proposed by explaning what normal forms are and why is it necessary and only right to use a lookup table the way I told you, since you are using the RDBMS in the wrong way and your software is misfiring and targeting wrong rows. On top of that, it's also slow (when it reaches a big row count your query will execute for a long time).

    It's just your attitude that's making me insulted. I am putting my effort and spending my time explaining the basics of good database design to you, who didin't even try to ASK why this system and not the one you tried / are trying to use.

    In the end, if you believe your approach to database design is within the aspect of good (proper) db design - why are you even trying to get answers from more experienced people?

    Finally, I'm only considering the best solution to what I seek
    I beg to differ. You are not even trying to understand anything, just to get done codes to accomplish your task which can be seen troughout this topic.
    That puts you in a different position - you're not a coder in the process of learning as you don't enquire about anything, you are just a person who wants to get premade codes without paying the price for the job.

    This is the first time I am actually insulted by someone who I tried to help to. You are inexperienced coder with a bad attitude and frankly, I suggest that you start reading and solving problems on your own. It's a trivial problem, your approach is wrong and start by reading up on what's database normalization, what are arrays and what are strings as you lack knowledge in those fields.

  15. #90
    Join Date
    Mar 2006
    Posts
    984
    No insults was intended. What's been said was simply about personal choices that I would rather make rather than reading multiples choices of yours which suggest to use 1 IDs per rows. Again, that is not to be considered. Sorry.

    I will wait for Inimino's codings since it seem to respond pretty well as I'm sure these last encountered issues were simply slight codings mistake which could be easily arranged.

    Thanks again for your concern maxymizer.

  16. #91
    Join Date
    Apr 2004
    Location
    Fullerton, CA
    Posts
    97
    Wow, is all I have to say, well, I'm glad I stepped out a while ago, anyways best of luck Horizon, but next time, come here with your ears open and ready to listen, we only are trying to give you tested and proven methods, and why not to do this, and why to do this, and so on and so forth, why? Because we have been there, we have done 'beginner' coding, everyone is a beginner, and the only way you will get better is by reading, studying, listening, and keep on writing code...

    Anyways best of wishes to everyone, good luck finding your solution.

    P.S. wow, you guys have patience.... 90 posts in, wow....

  17. #92
    Join Date
    Mar 2006
    Posts
    984
    Could you please stop posting your opinions ? It will only increase postings on this topic and this is NOT what I intend to receive. All I'm looking forward to read is the right technical answer to resolve this problem - period. It used to work and now it doesn't. It should be very easy to understand and hope to fix this issue pretty soon.

  18. #93
    Quote Originally Posted by horizon
    Could you please stop posting your opinions ?
    No.

    Quote Originally Posted by horizon
    All I'm looking forward to read is the right technical answer to resolve this problem - period.
    You allready recieved more than enough "technical" solutions. It's your own fault you cannot implement anything, after 90 posts.


  19. #94
    Join Date
    Mar 2006
    Posts
    984
    Your decision is totally respected. If you do not wish to post here and let someone totally qualified in order to resolve this issue, the choice is totally yours.

  20. #95
    Join Date
    Aug 2004
    Location
    Colorado, US
    Posts
    427
    Quote Originally Posted by horizon
    Although, when I went back, the same behavior came back - two fields deleted for one selection for an unknown reason. It has changed behavior without knowing why ...
    I would echo the SQL statement you are generating and var_dump() the arrays as before and then go from there...

  21. #96
    Join Date
    Mar 2006
    Posts
    984
    I'm totally sorry inimino. I have put the last var_dump results aside but forgot to post it to you. I will do so this afternoon.

  22. #97
    Quote Originally Posted by horizon
    Your decision is totally respected. If you do not wish to post here and let someone totally qualified in order to resolve this issue, the choice is totally yours.
    I am starting to develop telekinetic powers just in order to help you with the issue. Please, allow a few days until I evolve to the level on which we can communicate. I see you do refuse to read and understand what's been written, so we have to take another course in order to get your "issue" resolved.

  23. #98
    Join Date
    Mar 2006
    Posts
    984
    @inimino:

    I found it !!! I have reput the var_dump function and found a very slight issue. It was so small that I couldn't see it instantly.

    Thanks for your outstanding assistance. Everything's in order now !!

  24. #99
    Join Date
    Aug 2004
    Location
    Colorado, US
    Posts
    427
    Great!

Page 4 of 4 FirstFirst 1234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •