Need Help in PHP MySQL?

Discussion in 'PHP' started by AimyThomas, Aug 14, 2012.

  1. #1
    PHP MySQLI code not workingPHP MySQLI code not working

    $q = "UPDATE users SET password = '6c55803d6f1d7a177a0db3eb4b343b0d50f9c111' WHERE id = '1';";
    mysqli_query($dbc, $q);


    Dot knows but some cause it keeps giving me the following error:

    Warning: mysqli_query()

    Expects parameter 1 to be mysqli, null given


    Can anyone help me

    Thanks in advanc
     
    AimyThomas, Aug 14, 2012 IP
  2. afstanislav

    afstanislav Greenhorn

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    16
    #2
    If you used functional coding you need add global var in your function

    Fo example:

    $DataBase = mysqli_connect("localhost", "test", "illusions", "test");

    function test()
    {
    global $Database;
    }
     
    afstanislav, Aug 14, 2012 IP
  3. afstanislav

    afstanislav Greenhorn

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    16
    #3
    It's hard to help with your problem without code.

    You need check $dbc, - it's must be MySQL resource id but not null
     
    afstanislav, Aug 14, 2012 IP
  4. artus.systems

    artus.systems Well-Known Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    103
    #4
    Maybe due to extra semicolon after 1
     
    artus.systems, Aug 14, 2012 IP
  5. shubhamm

    shubhamm Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Post code for Link => $dbc

    i think the Prob. is in your $dbc variable check it again or Post Code
     
    shubhamm, Aug 14, 2012 IP
  6. SitesTen

    SitesTen Active Member

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    75
    #6
    For sure you missed to define $dbc before you execute the actual query.
     
    SitesTen, Aug 16, 2012 IP