SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mysql update not working

    Hi Guys,

    i have a problem with this mysql update, it says its working but it's not then id auto increments fine but the "biography" row is blank:

    PHP Code:
    <?php
             
    // Includes... /////////////////////////////////////////////////////////////////////
             
    include("db_connection.php");
         
             
    // Include the navigation bar...////////////////////////////////////////////////////
             
    include("navbar.php");
             
             
    // Edit/delete the bio page...//////////////////////////////////////////////////////   
             
    if(isset($_POST['submit'])) {
                                    
             
    $query "UPDATE biography SET biography='$biography' WHERE biography='8'";
             
    $result mysql_query($query);
             
             
    // Error checking...////////////////////////////////////////////////////////////////
             
    if($result) {
             
                  echo 
    "IT WORKED";
             
             } else {
             
                  echo 
    "IT DIDN'T WORK";
             
             }
             
             } else {      
           
             echo 
    "<center>";
             echo 
    "<table width=\"500\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">
                   <form action=\"biography_edit.php\" method=\"POST\">
                   <tr>
                   <td align=\"center\"bgcolor=\"#E2E2E2\" /><p>Update Biography</td>
                   </tr>
                   <tr>
                   <td align=\"center\"bgcolor=\"#E2E2E2\" /><textarea rows=\"20\" cols=\"60\" name=\"biography\"></textarea></td>
                   </tr>
                   <tr>
                   <td align=\"center\"bgcolor=\"#E2E2E2\" /><input type=\"submit\" name=\"submit\" value=\"Update\"></td>
                   </tr>
                   </table></form>"
    ;
             }        
    ?>
    i know the where clause is wrong but i wasn't sure what to put there i onlu have 2 rows in mysql

    id
    biography

    thanks for nay help

    Graham

  2. #2
    Non-Member
    Join Date
    Feb 2006
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hi

    check your sql query condition where
    Code:
     WHERE biography='8'
    PHP Code:
    $query "UPDATE biography SET biography='$biography' WHERE biography='8'"
             
    $result mysql_query($query); 

  3. #3
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is the datatype of biography column hold, string or integer? Though, it might well be correct but I smell something fishy out there. Also, where is $biography defined? Most likely it comes from the form, but you don't seem to be using $_POST['biography'].

    Also,

  4. #4
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot guys, i never defined the POST variable.

    Graham


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
  •