SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member wulf's Avatar
    Join Date
    Jul 2006
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    database trouble

    for some reason my MySQL database wont update. I believe all the coe is right... I'm 100% sure the connection info is correct because I have it in an include file that has worked thus far across my entire site.

    I have tried about 4 different ways to type in the UPDATE string... I got 0 errors on all of them but like I said the field never updates

    HEEEEEEEEELLLPPPP!!!

    Code:
    $conn = mysql_connect($host, $user, $password) or die ("Problems connecting:" . mysql_error());
    $select = mysql_select_db($host, $conn) or die ("Problems connecting:" . mysql_error());
    
    $query = ("UPDATE $database SET exp = $value WHERE username = $username");
    mysql_query($query,$conn);

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In your query string you have Update $database where its probably supposed to be Update $table
    PHP Code:
    <?php
    $dbhost 
    'localhost';
    $dbuser 'root';
    $dbpass 'password';

    $conn mysql_connect($dbhost$dbuser$dbpass) or die                      ('Error connecting to mysql');

    $dbname 'petstore';
    mysql_select_db($dbname);
    $table "users";
    $query = ("UPDATE $table SET exp = $value WHERE username = $username");
    mysql_query($query,$conn);

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    familiarize yourself with this function:
    mysql_error()


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
  •