7

I fucking hate myself for having this bug in the first place, I thought I had it solved, committed and pushed to git but still, it persists.

I'm trying to check if the value I'm inserting into the database exists or not, this is my useless fucking way to do it...

What the actual FUCK.

I'm in my own existential pain trying to solve this shit and it's still not working

SEND HELP PLEASE

Comments
  • 1
    I don't know php but this is the first php code I see that is READABLE, seriously, I usually see php code as complicated mess that I just run away from, but this one is pretty clean! good luck fixing that bug :)
  • 1
    Basically $d=""; is string for PHP according to my assumption...an later I'm comparing it
  • 0
    Well, you try to insert $d into database...but you just assigned $d = ""; - what were you about to do?
  • 1
    @ElToastGrande no I'm not inserting $d; into the database, I took that variable as a dummy variable to compare, to check if the current user has submitted the required information in the database in order to proceed further...

    This is a snippet of the code.
  • 0
    And idk if this might be relevant to you, but isset checks for set variables, not null
    So if I go $_POST['stuff'] = null;
    isset($_POST['stuff']) returns true
  • 1
    Also note that your outer if is not closed.
  • 1
    @Stalker This is a snippet of the original code...core problem is $d=""; and my audacity to compare string with int without typecasting.
  • 0
    Ok, I'm lacking context with this one
    Shouldn't be that hard, but...what's the bug exactly like?
  • 0
    @dextel2 oh ok. As long as you figured it out. :-D
  • 1
    @ElToastGrande Okay, you see, I'm trying to check whether the user has entered the data which is required in order to proceed further, for that I took $d="" as a dummy variable. and that dummy variable is string rather than int.
  • 1
    There is a string to int function in PHP, also shouldn't bindValue(1, $d) be bindValue("s", $d) instead? 🤔
  • 1
    @ElToastGrande that is not correct. If a variable is null, isset returns false
  • 0
    What error u get
  • 1
    @Username987654 I successfully resolves it..

    I was checking in Table if the I'd exists or not..and on basis of those results I would further proceed..

    The error was the result from select wouldn't store in $d and if it would've store a variable it would be string instead of int eg $d="0" instead of $d=0... Which would lead to the error , meaning I cannot compare string with rowsCount()
  • 0
    Pls no php-closing tags
  • 1
    @Username987654 can't help it..quite used to it
  • 1
    @Username987654 Why not? My ocd kills me if I leave the script without it.
  • 2
    @olback The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include() or require(), so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files. - php manual
  • 0
    @olback causes more problems than it solves
  • 2
    @Username987654 Had no idea about this, I guess you learn something new every day. ☺️
Add Comment