Announcement

Collapse
No announcement yet.

Need Help Resetting MSQL Table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need Help Resetting MSQL Table

    I want to run a cron to reset the count on who's viewed profiles. I set it up but keep getting a parse error can someone help me out with where in this code I' messing up?

    Code:
     // ###  Delete number of profileviews ###
    $vbulletin->db->query_write("
            UPDATE " . TABLE_PREFEX . "user" SET "profileviews = 0
    ");
    Take the party with you.

    http://www.htslifestyle.com

  • #2
    PHP Code:
    $vbulletin->db->query("UPDATE "TABLE_PREFIX ."user SET profileviews = 0"); 
    Try that =)

    Comment


    • #3
      If you are using the query within a vBulletin powered script and are requiring global.php, you can remove the $vbulletin-> bit from the query. As it stands, you just have an extra pair of " 's in the query from a quick glance.

      With that, either of the below should work:

      PHP Code:
       // ###  Delete number of profileviews ###
      $db->query_write("
              UPDATE " 
      TABLE_PREFEX "user SET profileviews = '0'
      "
      ); 
      or

      PHP Code:
       // ###  Delete number of profileviews ###
      $db->query_write("
              UPDATE " 
      TABLE_PREFEX "user SET profileviews = 0
      "
      ); 

      Comment


      • #4
        Thanks for the replys, however, now have a new problem:
        Maybe it would help if I inlcuded the whole script:
        PHP Code:
        <?php
        // ######################## SET PHP ENVIRONMENT ###########################
        error_reporting(E_ALL & ~E_NOTICE);
        if (!
        is_object($vbulletin->db))
        {
        exit;
        }
        // ####################### Who view profile reset #######################
        // ### Delete Profle Views ###
        $vbulletin->db->query_write("DELETE FROM " TABLE_PREFIX "profileviews"); 
        // ### Delete number of profileviews ###
        $vbulletin->db->query_write("UPDATE " TABLE_PREFEX "user SET profileviews = '0'");
        ?>
        When I run it now I'm getting this db error The first half of the script seems to run ok so I'm not sure where I've messed up.
        Code:
        Database error in vBulletin 3.5.3:
        Invalid SQL:
        UPDATE TABLE_PREFEXuser  SET profileviews = '0';
        MySQL Error  : Table 'houstontexass.TABLE_PREFEXuser' doesn't exist
        Error Number : 1146
        Date         : Thursday, March 2nd 2006 @ 06:44:35 AM
        Script       : http://www.houstontexass.com/vbullet...cron&cronid=19
        Referrer     : http://www.houstontexass.com/vbullet...incp/index.php?
        IP Address   : 
        Username     : admin
        Classname    : vb_database
        I'm sure it is a coding error on my part (very new at php and mysql). One thing I am sure of is table user does exist. Any suggestions ?
        Take the party with you.

        http://www.htslifestyle.com

        Comment


        • #5
          You didn't spell TABLE_PREFIX correctly in the second query. You spelled it "TABLE_PREFEX," not "TABLE_PREFIX."

          This caused PHP to parse it as a string, not a constant, because it does not exist.
          Bugdar: PHP bug tracking software that is beautiful, fast, and robust.

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X