Results 1 to 7 of 7

Thread: Guestbook (MySQL and Values)

  1. #1
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Guestbook (MySQL and Values)

    Hi everybody

    I can't get my guestbook to work. I think it might be something with my values.
    The date works fine, but name and message is just blank.

    Is this right.. (working in dreamweaver)


    $insertSQL = sprintf("INSERT INTO guestbook (`date`, name, message) VALUES (now(), '$name', '$message')",
    GetSQLValueString($_POST['date'], "date"),
    GetSQLValueString($_POST['name'], "text"),
    GetSQLValueString($_POST['message'], "text"));

    Hope you will help me

  2. #2
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am not sure if you have this somewhere and just didn't show it but, the first thing I see is that you need to define $message and $name. To do this, just add this at the top of your code:
    PHP Code:
    $name $_POST['name']; // Gets the value submitted for $name
    $message $_POST['message']; // Gets message 
    I hope that helps, I'll look into it further when I get home.
    EDIT: Looking at it again, it seems that you did have something like that, but I am not sure if that way works, someone should know and post if it is right or not
    Last edited by Titan85; 01-11-2007 at 12:07 PM.

  3. #3
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you, thank you, thank you!!
    It's working now..

  4. #4
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    By the way..

    To begin with, Dreamweaver wrote it like this but then the date didn't work.

    VALUES (%s, %s, %s)

    Why is that and what does %s meen?

  5. #5
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmm, I am not familiar with how dreamweaver generates php code, but I would guess that the %s in VALUES (%s, %s, %s) are where you place your variables. Like VALUES ('$value', '$value', '$value').

  6. #6
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Okay.. but I still don't understand how the name and message could work with this, and not the date.

    $insertSQL = sprintf("INSERT INTO guestbook (`date`, name, message) VALUES (%s, %s, %s)"

  7. #7
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    O, I didn't see that you said the date stopped working, you need to define what the date is in the same way:
    PHP Code:
    $date date('F j, Y'); 
    Now your sql code should be like this
    PHP Code:
    mysql_querry("INSERT INTO `guestbook` (date, name, message) VALUES ('$date', '$name', '$message')"); 
    Hope this helps out

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
  •