Results 1 to 9 of 9

Thread: [RESOLVED] mysql Update code not working

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    Resolved [RESOLVED] mysql Update code not working

    hi i am trying to run an update command but it keeps failing

    Code:
    <?php
    $updatetext = $HTTP_POST_VARS['welcomeinfo'];
    
    $conn=@mysql_connect("localhost", "ckids_ckids1", "christiankids")
    or die("MYSQL Connection Error");
    
    $rs = @mysql_select_db("ckids_wcms1", $conn)
    or die("Database Error");
    
    
    
    $sql = "UPDATE `hompage` SET `welcome` = '$updatetext' WHERE `id` = 1 LIMIT 1";
    
    mysql_query($sql) 
    or die("Error: Update Failed");
    
    echo "Updated";
    
    
    
    ?>
    its keeps showing error update failed
    i have tried many things and cant get it to work, i know that $updatetext contains a value as i have echoed this in trying to fix it
    Richard <><

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: mysql Update code not working

    Try the below. HTH

    PHP Code:
    $sql "UPDATE hompage SET welcome = '$updatetext' WHERE id = 1 LIMIT 1"

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: mysql Update code not working

    Back ticks ` should only be used for table names. Not field names.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: mysql Update code not working

    You can also display the error from mysql by using the mysql_error()
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    Re: mysql Update code not working

    nope still doesnt work
    Richard <><

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: mysql Update code not working

    What is the error mysql is giving you?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    Re: mysql Update code not working

    the mysql_error() wouldnt work, but have fixed it now, it was a spelling error in the table, thanks everyone
    Richard <><

  8. #8
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: [RESOLVED] mysql Update code not working

    If the table name was incorrect then mysql_error() should have told you that

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    Re: [RESOLVED] mysql Update code not working

    yes i know it should have, and i set it up like it showed, but for some reason it didnt like it, might try it again one day when my code goes wrong
    Richard <><

Posting Permissions

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



Click Here to Expand Forum to Full Width