46 users online (0 members and 46 guests)  

Thread: Help please


  Results 1 to 3 of 3
  1. #1
    wonick67's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2004
    Posts
    1

    Help please

    hello php/mysql pros...please help me figure out why this script is not inserting the data collected from and html form url removed by request to my mysql database tables called books. The script is driving me off tha wall. ANYONE?

    <html>
    <head>
    <title>Post Books</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <?
    $name=$_POST['name'];
    $email=$_POST['email'];
    $phone=$_POST['phone'];
    $title=$_POST['title'];
    $author=$_POST['author'];
    $isbn=$_POST['isbn'];
    $university=$_POST['university'];
    $description=$_POST['description'];
    $price=$_POST['price'];

    $location="My_IP_Address";
    $username="username";
    $password="mypass";
    $database="mydb";

    $conn = mysql_connect($location,$username,$password);
    if (!$conn) die ("Could not connect MySQL");
    mysql_select_db($database,$conn) or die ("Could not open database");

    $result = mysql_query("INSERT INTO books(name,email,phone,title,author,isbn,university,description,price VALUES(",'$name','$email','
    phone','title','author','isbn','university','condition','price')");

    if($result){
    echo "You Textbook and Contact Info Have Been Posted to url removed by request Database!<br><br>Thank You.";
    }else{
    echo "An Error has occured Trying to Process Your Request. Please Try Again";
    }

    mysql_close();

    </body>
    </html>
    ?>
    Last edited by HTML; 08-13-2005 at 11:36 PM.

  2. #2
    Nesper's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    9
    Assuming your server is php enabled, (if it's not then there's no way it's gonna work) change the extension of your file from post.html to post.php

  3. #3
    supertek's Avatar
    please contact admin

    Status
    Offline
    Join Date
    Aug 2004
    Location
    Wichita, KS
    Posts
    19
    Also looking at your code the HTML tags have no purpose so I would create the page as such and name the file post.php:

    Code:
    <?
    $name=$_POST['name'];
    $email=$_POST['email'];
    $phone=$_POST['phone'];
    $title=$_POST['title'];
    $author=$_POST['author'];
    $isbn=$_POST['isbn'];
    $university=$_POST['university'];
    $description=$_POST['description'];
    $price=$_POST['price'];
    
    $location="My_IP_Address";
    $username="username";
    $password="mypass";
    $database="mydb";
    
    $conn = mysql_connect($location,$username,$password);
    if (!$conn) die ("Could not connect MySQL");
    mysql_select_db($database,$conn) or die ("Could not open database");
    
    $result = mysql_query("INSERT INTO books(name,email,phone,title,author,isbn,university,description,price VALUES(",'$name','$email','
    phone','title','author','isbn','university','condition','price')");
    
    if($result){
    echo "You Textbook and Contact Info Have Been Posted to url removed by request Database!<br><br>Thank You.";
    }else{
    echo "An Error has occured Trying to Process Your Request. Please Try Again";
    }
    
    mysql_close();
    ?>
    If you are still having problems please post the code for the form as well.
    Last edited by HTML; 08-13-2005 at 11:36 PM.