SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2004
    Location
    Texas
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Really new to MySQL

    I'm trying to create a user review script (for other people to add on their own reviews/comments to my site's review), and I just can't seem to get this to work. I'm first just trying to get it to display one row, so if there are any major mistakes in here, be gentle. I'm new to this.

    Code:
    <?php
    $name = $_POST["name"];
    $email = $_POST["email"];
    $animation = $_POST["animation"];
    $characters = $_POST["characters"];
    $music = $_POST["music"];
    $plot = $_POST["plot"];
    $review = $_POST["review"];
    
    $user = "myuser";
    $pass = "mypass";
    $db = "mydatabase";
    
    mysql_connect(localhost,$user,$pass);
    @mysql_select_db($db) or die("The database could not be connected.");
    $query = "INSERT INTO review VALUES ('','$name','$email','$animation','$characters','$music','$plot','$review')";
    $result = mysql_query("SELECT * FROM review");
    
    while ($row = mysql_fetch_array($result)) 
    {
    echo "$row['name']";
    }
    ?>
    This POST info comes from a different page where it is entered into fields. Can anyone tell me what's wrong with this? I pieced it together from various tutorials/topics on displaying MySQL info, and I really don't know what's wrong with it.

    EDIT Nevermind, I figured it out. The problem was with this line:
    Code:
    $query = "INSERT INTO review VALUES ('','$name','$email','$animation','$characters','$music','$plot','$review')";
    After that line, I didn't run
    Code:
    mysql_query($query);
    Works now, though. I'll probably be having more problems with it, though, and I'll post them in this topic.

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instead of posting the entire script, post only where you think the problem is.

    Also you may only want to post relevant mysql part of your script here and more of the php in the php area of the site (though not simultaneously of course).

  3. #3
    SitePoint Member
    Join Date
    Apr 2004
    Location
    Texas
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I didn't know where the problem was; it could have been anywhere in the script, so to be safe, I posted all of it.


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
  •