SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Not updating database

    Hi people,

    I've got a few lines of code that check a user's id, then update a field in the database to '1'. Unfortunately its not working and wondering if someone can help troubleshoot:

    Part 1 (in confirmaccount.php)
    PHP Code:
    $this->usersmodel->updatePremiumCC($account["id"]); 
    Part 2 (in usermodel.php)
    PHP Code:
    public function updatePremiumCC($userid)
        {
            
    $sql "UPDATE users SET ccdetails = '1' AND featured = '1' WHERE id = $userid";
            
    $this->db->query($sql);
        } 
    Cheers

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    The code looks fine (sorta), do you receive any errors? What framework are you using? CodeIgniter ?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Anthony,

    Yep using the codeigniter framework. There are no errors shown either in logs or on screen. I've also made sure I have error messages on:

    PHP Code:
    error_reporting(E_ALL); ini_set('display_errors','On'); 
    Is there something I can 'print' before the sql query goes off to check the $userid is there or something along those lines?

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Possibly, try ...
    PHP Code:
    log_message('debug''Executing: ' $sql); 
    Then check your logs.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

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