Results 1 to 2 of 2

Thread: extreme newbie questions. please help

  1. #1
    Join Date
    Mar 2007
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default extreme newbie questions. please help

    hey everyone. i am trying to set up a news form for a client. i have used php before, but in a very limited way with help of others. this is the first time out on my own trying to use it. what i need is first how to send information from a html for over to a database. i have looked at a couple tutorials and dont seem to be getting it right. i have a database called newsbd and a table called news with three fields set up. my fields are ID which is set to autoincrement, title, and news. seems like i need coding like this on the php part but it didnt do anything

    PHP Code:
    <?php
    $title
    =$_POST['title']; 
    $news=$_POST['news'];  
    mysql_connect("localhost""user""pass") or die(mysql_error()); 
    mysql_select_db("newsdb") or die(mysql_error()); 
    mysql_query("INSERT INTO `news` VALUES ('$title', '$news')"); 
    Print 
    "Your information has been successfully added to the database."
    ?>

    can anyone please straighten me out. i would appreciate it.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    The only thing I can see is this line:

    Code:
    mysql_query("INSERT INTO `news` VALUES ('$title', '$news')");
    needs to be this:

    Code:
    mysql_query("INSERT INTO `news` VALUES (null, '$title', '$news')");
    or:

    Code:
    mysql_query("INSERT INTO `news` (`title`,`news`) VALUES ('$title', '$news')");
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •