Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Can't find an error in the code

Hybrid View

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    228

    Can't find an error in the code

    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);
    $database = @mysql_select_db($db_name, $db_link);

    $update_error_reasons = mysql_query ("
    update server_error_reasons set error_reasons = $error_reason
    where
    hostid = $hostid
    and
    hostname = $hostname;");
    }


    Hi guys I don't seem to be able to find an error in this function, yet it doesn't update the table

    Any ideas?
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

  2. #2
    AOs Resident Troll
    Join Date
    Nov 2003
    Posts
    3,152
    here ???

    hostname = $hostname;");

    2 semi colons??

    MLF
    How people treat you is their karma- how you react is yours-Wayne Dyer

  3. #3
    Senior Member
    Join Date
    Apr 2004
    Posts
    228
    The first semicolon is a part of a SQL statement
    "update server_error_reasons set error_reasons = $error_reason
    where
    hostid = $hostid
    and
    hostname = $hostname;"

    The problem is that this function is supposed to update a table but it doesn't
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

  4. #4
    AOs Resident Troll
    Join Date
    Nov 2003
    Posts
    3,152
    Usually I can figure out where to look by the error it spits out when I run the script...

    Could be a misspelled username\passowrd\server\db....could be a permissions error...could be a link problem...

    do any other updates work??


    Personally I dont use MYSQL....

    MLF
    How people treat you is their karma- how you react is yours-Wayne Dyer

  5. #5
    Senior Member nihil's Avatar
    Join Date
    Jul 2003
    Location
    United Kingdom: Bridlington
    Posts
    17,188
    I seem to recall from years ago that the hostname had to be mysqlhost for some reason or other?

  6. #6
    Senior Member
    Join Date
    Apr 2004
    Posts
    228
    Quote Originally Posted by nihil
    I seem to recall from years ago that the hostname had to be mysqlhost for some reason or other?
    It's different hosts And theres only a couple of thousands of them
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

  7. #7
    Senior Member
    Join Date
    Apr 2004
    Posts
    228
    Seems there was another error in another part of the system. Took me half an hour to explain it to my boss as well

    Wouldn't have noticed it if it wan't for him though
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

  8. #8
    rebmeM roineS enilnOitnA steve.milner's Avatar
    Join Date
    Jul 2003
    Posts
    1,021
    Does it need a "commit;" ?

    Steve
    IT, e-commerce, Retail, Programme & Project Management, EPoS, Supply Chain and Logistic Services. Yorkshire. http://www.bigi.uk.com

  9. #9
    rebmeM roineS enilnOitnA steve.milner's Avatar
    Join Date
    Jul 2003
    Posts
    1,021
    Oooooo could this be it (I'm not familiar with the prog language but this rang a bell:

    $update_error_reasons = mysql_query ("
    update server_error_reasons set error_reasons = '" || $error_reason ||
    '" where
    hostid = '" || $hostid ||
    "' and
    hostname = '" || $hostname || "';");

    Where || is the concatenate operator. Note the singe quote ' next to the double quotes " to ensure your SQL read correctly
    IT, e-commerce, Retail, Programme & Project Management, EPoS, Supply Chain and Logistic Services. Yorkshire. http://www.bigi.uk.com

  10. #10
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    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.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

Posting Permissions

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