Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13
  1. #11
    Senior Member
    Join Date
    Jul 2004
    Are you still having this issue?

    What error is tossed?

    I'm assuming the from variables were stripped by you, and that they are ALL right?

    Can you have a variable, update_error_reasons, thats the same name as a function?

    Is this perl btw?

    You use plural and singular in spots. Verify those are all correct.

    I'd probably add some screen output statements to verify that the input variables are good.

    Its been a while for me and mysql/perl, but do you need to execute the statement or does it do that inside the mysql_query function?

  2. #12
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    I'm assuming PHP? I see a couple of potential problems...try this:
    1) Picky thing for me, when you are doing SQL, make the SQL key words in ALL CAPS, it makes it easier to read
    2) I think your query might be failing due to quoting...regardless, the code i gave you will tell you why it is failing
    3) I hope you sanitized your input before calling that...

    function update_error_reasons ($hostid, $hostname, $error_reason)
    $db_server = '';
    $db_user = '';
    $db_pwd = '';
    $db_name = '';
    $db_link = mysql_connect($db_server, $db_user, $db_pwd);
    $result = mysql_query($error_reason, $db_link);
    if(! $result) {
        echo mysql_error();
    // Note, don't do above in a production environment, I usually surround this with debugging code, but am trying to keep it simple here
    } //end if
    } // end function
    $query = "UPDATE server_error_reasons SET error_reasons = '" . $error_reason . "WHERE hostid = '" . $hostid . "' AND hostname = '" . $hostname . "'";
    $update_error_reasons("foo2", "foo", $query);
    Not really groking what you were doing at the end, but I did the best I could with what you had...
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  3. #13
    Senior Member
    Join Date
    Apr 2004
    Quote Originally Posted by SirDice
    One thing I can think of.. Perhaps there's no entry with that particular $hostid and $hostname. Then there would be nothing to update because the where clause fails.
    That was the problem I found. There were no values inserted in the table. I made a mistake in another query, which was supposed to automaticaly insert the necessary values from another table.

    I guess the fact that I haven't touched PHP in almost 2 years might have something to do with me being slopy

    Thanks everyone for their replies though
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

Posting Permissions

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.