SitePoint Sponsor

User Tag List

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

    $result = mysql_query...

    Below is a snip that I am playing with... everything appears to be working except:

    $result = mysql_query ($query);

    I get results from the $_POST and $query usig the print_r but nothing for the $results

    Am I coding something wrong?




    Code below:


    if (isset($_POST['submit'])) {

    require_once ('dbconnect.php'); // Connect to the database.

    $query = "INSERT INTO patients (firstname, initial, lastname, dob, ) VALUES ('$firstname', '$initial', '$lastname', '$dob', NOW())";
    $result = mysql_query ($query);

    echo '<pre>';
    print_r ($result);
    echo '</pre>';

    echo '<pre>';
    print_r ($query);
    echo '</pre>';

    echo '<pre>';
    print_r ($_POST);
    echo '</pre>';

  2. #2
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Parry Sound, ON
    Posts
    725
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by comtek
    PHP Code:
    $query "INSERT INTO patients (firstname, initial, lastname, dob, ) VALUES ('$firstname', '$initial', '$lastname', '$dob', NOW())"
    MySQL will be erroring out on this query, something like fields not matching parameters.

    You should issue queries with
    PHP Code:
     $result mysql_query($query) or die(mysql_error()); 
    while debugging

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Madison, WI
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    also, if you print_r on a query result, you'll only get a result ID

    if you want to actually see the data you'll have to fetch from the result


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
  •