SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: damn you SQL!!!

  1. #1
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    damn you SQL!!!

    ok i keep getting a message to tell me that my SQL command has been carried out successful but when i check nothing has been done.

    I am trying to update a row but nothing seems to be happening...

    the code in my php is as follows:

    PHP Code:
    // Edit

    if ($action == "edit" ) {

    $result mysql_query("SELECT * FROM diary WHERE id = '$id'");
    while ( 
    $row mysql_fetch_array($result) ) { 

    echo (
    "
        <form name=addentry method=post action=editdiary.php?action=change>
          <div align=center>Title: 
            <input type=text name=title value=
    $row[title]>
            <br>
            <br>
            <textarea name=entry cols=50 rows=9>
    $row[entry]</textarea>
            <br>
            <br>
            <input type=reset name=Submit2 value=Reset>
            <input type=submit name=Submit value=Submit>
          </div>
        </form>
        "
    ); } }

    // Change

    if ($action == "change") {

    $xid $id;

    $sql "UPDATE diary SET title='$title', entry='entry' WHERE id='$xid'";

    if ( 
    mysql_query($sql) )
    { echo(
    "<div align=center><b>Updated</b><br><br>Title: $title<br><br>Entry:<br><br>$entry<br><br><a href=editdiary.php>edit more</a></div>"); } else 
    { echo(
    "Error editing news to database: " mysql_error() . ""); } } 
    hmm...

  2. #2
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    entry='entry'

    Should be...

    entry='$entry'

    -Peter

  3. #3
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see how you are passing the $id varible when you hit submit? You need to add a hidden input field to form or add &id=$id to the form action.


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
  •