Jump to content

[SOLVED] Cannot insert into table?


lt40

Recommended Posts

hi,

Could you tell me what is wrong with this code.

after the post data is submitted nothing changed in phpmyadmin.

Note: some of the post data will be blank will this still work?

 

 

<?php
include 'includes/header.inc';
include 'includes/config.php';

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");



mysql_query("INSERT INTO contact (app_code, name, sub, contact, what, email)
VALUES ('" . $_POST['app'] . "','" . $_POST['name'] . "','" . $_POST['subject'] . "','" . $_POST['contact'] . "','" . $_POST['info'] . "','" . $_POST['email'] . "')");


include 'includes/footer.inc';

?>

 

Thanks

 

Link to comment
Share on other sites

Thanks for the quick response i used the code.

 

if (mysql_affected_rows() != 1) die ('Query failed: '.mysql_error());

 

Found the problem Incorrectly named column  email was actually labeled e-mail.

Now i feel stupid  :D

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.