SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Saving data to database

    Hey guys,

    I have 2 problems.

    1st, when I want to update multiple values, I tried:
    $sqlRequest = "UPDATE gvntools_msg SET title = '$title' AND body='$body' AND videoID='$videoID' WHERE username = '$username'";

    What would be a correct syntax? Because it wont save the results.

    Also, I wanna store a private message in database. As its plain text I decided to go simply with VARCHAR(1000). Saves fine, but I have a problem getting it inside textarea.
    Messagebr /><textarea name=\"body\" cols=\"40\" rows=\"10\" maxlength=\"1000\" value=\"$body\"></textarea>

    It won't display a thing. Here is how I get $body var:
    $body = mysql_result($result, 0, 'body');

    Help, thanks

  2. #2
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello jan1024188,



    Try to echo following query and see what you are getting

    PHP Code:
    $sqlRequest mysql_query("UPDATE gvntools_msg SET title = '$title' AND body='$body' AND videoID='$videoID' WHERE username = '$username'"); 

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $sqlRequest "UPDATE gvntools_msg SET title = '$title' AND body='$body' AND videoID='$videoID' WHERE username = '$username'"
    Should be :
    PHP Code:
    $sqlRequest "UPDATE gvntools_msg SET title = '$title', body='$body',videoID='$videoID' WHERE username = '$username'"
    And with textarea, try as follows:
    PHP Code:
    echo '<textarea name="body" cols="40" rows="10" maxlength="1000">' $body '</textarea>'
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    $sqlRequest = "UPDATE gvntools_msg SET title = '".$title."', body='".$body."', videoID='".$videoID."' WHERE username='".$username."'";

    Edit:

    Stop typing so fast!
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajug View Post
    PHP Code:
    $sqlRequest "UPDATE gvntools_msg SET title = '$title' AND body='$body' AND videoID='$videoID' WHERE username = '$username'"
    Should be :
    PHP Code:
    $sqlRequest "UPDATE gvntools_msg SET title = '$title', body='$body',videoID='$videoID' WHERE username = '$username'"
    And with textarea, try as follows:
    PHP Code:
    echo '<textarea name="body" cols="40" rows="10" maxlength="1000">' $body '</textarea>'
    Oh, dumb me, OC textarea value isnt as value parameter but inside ><. Also, comma should do the job.

    Thanks a ton


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
  •