Jump to content

phppup

Members
  • Posts

    863
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by phppup

  1. If the second UPDATE is to ADD, then it CANNOT be $sql_1 ALSO because you already have a variable of $sql_1. So, perhaps that should be variable $sql_add throughout the second UPDATE. Revert to the code that was working with the subtraction and then work out the kinks for the addition.
  2. It's very possible, but this is a clumsy methodology. Mac_gyver has the right idea. I'm also running out of free time. Have you tried replacing user_updated_token with a hardcoded number (like 20) just to validate that addition will occur?
  3. OOPS! Just realized the code error I made. I made $gname = 20 which is WRONG. $gname is a user name, I meant to add an increase of value by 20 for easy verification. Sorry.
  4. I like to test one item at a time. This let's you know where problems originate. If the subtraction is working, then now get the addition to adhere. I would think the two updates should be in the same loop, this way all criteria is the same.
  5. I'd try this for starters: ////$gname = $row["fname"]; $gname = 20; //this will give you an easy way to spot the added value and see that it increases $user_updated_token = ($user_token) + 1; $sql_l = "UPDATE users SET token='$user_updated_token' WHERE id=$gname"; I don't use PDO, some in not sure about if ($conn_l->query($sql_l) === TRUE) //would == be more accurate than === And are you repeating this query? You already have it once, don't you?
  6. I guess the first question is what exact code you added and where to trigger these errors. You are getting no errors prior to these added lines?
  7. Did you get it working? (If it's good please mark the solution) PS: you may want to review and consolidate your tables to eliminate redundancy. Streamlining is good.
  8. It seems to me that you may want to restructure your process (especially if your learning) because it's easier to learn to code correctly than to learn bad habits. And it's easier to find and resolve issues on smaller projects than large. What @mac_gyver is providing you may be advanced information, but it is accurate. If a user of your small group tells you that their balance is incorrect, you currently have no recourse but to shrug your shoulders and respond that your code is full-proof (not very reassuring to a disgruntled user). Mac's method would offer an additional table for transactions that would allow you to say, " You had this many tokens on DATE and you received X many on these dates from user 1, use 2, etc. You also gave to these people on these dates, and this is my evidence to support the inquiry." More advanced, but much more useful.
  9. Well, you cannot ADD to a column that does not exist, right? So at some point, you need to tell the SQL statement that $gname = fname so that the correct for value is increased by 1.
  10. Does the row have a column for gname?? Or does gname = fname at that point? After you get out working, I would suggest a review of @mac_gyver comments.
  11. I only see ONE statement for UPDATE. You need one for ADDING and ANOTHER to subtract.
  12. If I'm following this, it seems that as long as the fname donor has > 0 tokens, you would UPDATE the row WHERE fname is found and decrease the number of tokens by 1. Then, do the same for the gname to increase the token quantity by 1
  13. You should not use the asterisk * to select EVERYTHING unless you NEED everything pulled from each row of the table. Only SELECT what is required for reaching your goal. SELECT merely pulls data. UPDATE will overwrite columns. WHERE will tell the table which SPECIFIC cells should be effected. You can search for helpful tutorials for SELECT, UPDATE and WHERE online.
  14. Legal advice is not provided here, but you can always contact an attorney or do you own research with an emphasis on your LOL locality. Beyond my disclaimer, I do not think that gathering the information should cause a problem. How you use it could be a different issue. In other words, collecting email addresses to use to contact your customers/users would be a reasonable business activity. Collecting the information to coordinate malicious activity would likely be frowned upon. Divulging the personal data on a billboard by a highway would probably be unwise. But again, this would be a good reason to have some kind of notification that informs users of what you are doing and your intentions. If the do not agree with the terms, then they can decline.
  15. I think requinix was trying to point out, in a sarcastic tone, that any protection is better than none. Also, I don't see why it would be illegal to collect email addresses. If you are in a region that does not permit this, perhaps a notice or terms of service stating: "This website saves all applicable data during usage" will be beneficial (but I cannot provide legal advice on this).
  16. You did not ask a question. You didn't post your code within the designated coding < > template. Nonetheless, it appears your mail function mail($to,$subject,$email_body, $headers); is directing your outbound emails to the variable $to (which appears to be equated to xyz@gmail.com) Either check the inbox of xyz@gmail.com or change the email address connected to $to
  17. I just discovered that my domain's built-in email will no longer be included in my hosting package. Any recommendations for code solution or third party providers for an inbox with useful options?
  18. UPDATE: Took a troubleshooting approach to this and managed to obtain an INSERT using a good 'ole fashioned SELECT statement WITHOUT any binding or prepared statements. I suppose that indicates that, as stated, all connectivity is valid. Now I'll move forward and count my commas, quotes, and variables to try to get to the full resolution. Unless there are more suggestions, I'll just say THANKS for everyone's help.
  19. @ginerjm Stalled as in the top of the page loaded perfectly, but other PHP lines that I had an echo'ed output during development (ie: print_r or echoes from a function) simply did not display beyond a certain point; as if the code simply stalled or derailed; froze or died. Note that while it did seem suspicious, I have reviewed my code and none of these items seems like it should interfere with an INSERT statement or the table, as they are unrelated. I'm not entirely sure of the effects of MYSQLI_REPORT_STRICT, and really don't have the time to investigate them.
  20. Changed the INI code to error_reporting(E_ALL); ini_set('display_errors', '1'); Same issue. No error information generated, but still no insertion occurring. @mac_gyver The stalled page did not affect the form, only the portion below it where processing would be taking place.
  21. @Barand Already got that resolved. There are 5 columns: ID, a, b, c, and TIMESTAMP (which has a default) @mac_gyver I replaced my ini_set('display_errors', 1); ini_set('display_startup_errors', 1); with your suggested code. After doing that, the form page stalled at a midpoint while loading.
  22. I am trying to insert from a form into a table with an auto increment primary id and a default TIMESTAMP $sql = "INSERT INTO $table (a,b,c,TIMESTAMP) VALUES ( ?,?,?,? )"; if($stmt = mysqli_prepare($conn, $sql)){ mysqli_stmt_bind_param($stmt, 'ssss', $w,$x,$y,$z); mysqli_stmt_execute($stmt); echo "Records inserted.<br>"; } else{ echo "ERROR". mysqli_error($conn);; $last_id = mysqli_insert_id($conn); echo "Last inserted ID is: " . $last_id; I have eliminated all ERRORS that indicated Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables However, I am still receiving the same code generated message Records inserted. Last inserted ID is: 0 No data is visible when I open the actual database and view the table. @ginerjm Actually made that correction after the posting, but same issue persists. But thanks. PS: checked all db connectivity and everything seems to be fine from that side.
  23. I am trying to insert from a form into a table with an auto increment primary id and a default TIMESTAMP $sql = "INSERT INTO $table (a,b,c,TIMESTAMP) VALUES (NULL, ?,?,?,? )"; if($stmt = mysqli_prepare($conn, $sql)){ mysqli_stmt_bind_param($stmt, 'ssss', $w,$x,$y,$z); mysqli_stmt_execute($stmt); echo "Records inserted.<br>"; } else{ echo "ERROR". mysqli_error($conn);; $last_id = mysqli_insert_id($conn); echo "Last inserted ID is: " . $last_id; I have eliminated all ERRORS that indicated Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables However, I am still receiving the same code generated message Records inserted. Last inserted ID is: 0 No data is visible when I open the actual database and view the table.
  24. Now I got it. Researched printf and made sense of it all.
×
×
  • 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.