SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    update not working

    Please i am trying to update a db, and its not working, the code is below, any clue will be appreciated


    PHP Code:
                                     <tr>
        <th>OUTSTANDING</th>
        <th><?php
        $pplresult 
    mysql_query("SELECT * FROM outstanding WHERE Uname = '{$_SESSION['username']}'") or die(mysql_error());
      
    $row mysql_fetch_assoc($pplresult); 
        
    //echo $obal;
       // echo $row['obal'];
    if($totalprice=0){
     
    $queryreg mysql_query("
    UPDATE outstanding 
        SET obal = '
    {$row['outstandingbal']}
                WHERE obal='
    {$row['obal']}
            AND 
                Uname = '
    {$_SESSION['username']}'
     "
    ) or die(mysql_error());
          
    $queryreg2 mysql_query("
            UPDATE outstanding 
                    SET outstandingbal='0' 
                        WHERE outstandingbal='
    {$row['$outstandingbal']}
                                AND Uname = '
    {$_SESSION['username']}'
       "
    ) or die(mysql_error());
     }
      echo 
    $row['obal'];
      
    ?></th>                
               </tr>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    What does "is not working" mean? Do you get an error?

  3. #3
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,904
    Mentioned
    93 Post(s)
    Tagged
    0 Thread(s)
    @lostty84 ; Please be aware that the mysql_* extension is now deprecated as of the current version of PHP and will very likely be removed from the next 5.x version and will likely not be in PHP 6.x (when it eventually is released). You should migrate over to either the mysqli_* extension or to PDO. PDO is a better choice as it doesn't tie you down so much to a particular database server software.

    Also your 2nd and 3rd queries ony make use of the obal field, so in the first you should just list that field only as the SELECT * returns every field irrespective of which ones are actually needed.
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  4. #4
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    @spacephoenix, please can you direct me to an article on how to migrate over as i have warned severally on this forum to move, and i have not been able to do that(sorry if i sound like a weak programmer)


    in the code above i found that 'if($totalprice=0)' was supposed to be if($totalprice==0) whereby it equals not assigned to as i was doing

  5. #5
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,904
    Mentioned
    93 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lostty84 View Post
    @spacephoenix, please can you direct me to an article on how to migrate over as i have warned severally on this forum to move, and i have not been able to do that(sorry if i sound like a weak programmer)
    http://www.sitepoint.com/migrate-fro...ension-to-pdo/

    That should explain it all, if you have any problems with the migration that start a fresh thread in the PHP forum
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  6. #6
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    thanks


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
  •