Title: Failed Insert
Last modified: August 26, 2020

---

# Failed Insert

 *  Resolved [hsysgrp](https://wordpress.org/support/users/hsysgrp/)
 * (@hsysgrp)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/)
 * Am a novice, Attempting to insert data into a custom table.
 *     ```
       <?php
       			$link = mysqli_connect("localhost", "h8888", "88888", "h8888"); 
   
       			if($link === false){    
       			die("ERROR: Could not connect. " . mysqli_connect_error());
       			} 
       			$ID = $_POST('ID');
       			$FirstName = $_POST['FirstName'];
       			$Lastname = $_POST('Lastname');
       			$Address1 = $_POST('Address1');
       			$SQL = "INSERT INTO AAUW_MEMBERS(ID,FirstName,Lastname,Address1) VALUES ('$ID','$FirstName','$Lastname',$Address1')";
       			if(!mysql_query($link,$SQL))
       				(
       					echo "Not Inserted';
       			)
       			else
       				(
       					echo 'Inserted';
       				)
       			get header();
       ?>
       ```
   
 * This is a test site.
    insert.php is in the child folder, under functions.php,
   this connection has been tested. `<form method="post",action="insert.php">` when
   i click save, nothing happens, no error messages,debug in config.php is set to‘
   true’, no data appears in the table in phpMyAdmin no error in finding the file.
   Thank you for any help. Claudette
    -  This topic was modified 5 years, 9 months ago by [bcworkz](https://wordpress.org/support/users/bcworkz/).
      Reason: code fixed
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffailed-insert%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Samuel O.](https://wordpress.org/support/users/wpcoworker/)
 * (@wpcoworker)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13314103)
 * May I know the reason you are creating custom table and why you want to push 
   the data there this way? This can be done in a different way using set of plugins.
 *  Thread Starter [hsysgrp](https://wordpress.org/support/users/hsysgrp/)
 * (@hsysgrp)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13316262)
 * The page is [http://hsysgrp.com/new-member-test/](http://hsysgrp.com/new-member-test/).
   I know I can use plugins, I am learning, and do not know what is wrong, and also
   why no error messages.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13317963)
 * Your form’s action value should be a full URL to your file. Don’t try to use 
   relative paths in WP, there will be situations where they fail, no matter how
   well considered.
 * Your file does not utilize WP resources, so the WP_DEBUG definition has no bearing.
   Submitting the form should result in a 404 response. If you don’t get even that,
   there’s something wrong with your form.
 * I don’t know offhand if it matters, but you don’t need commas between HTML tag
   attributes. More like this:
    `<form method="post" action="http://localhost/wp-
   content/themes/my-theme/insert.php">`
 * BTW, when you post code in these forums, please use the code button or demarcate
   using backticks. When you don’t, the forum’s parser corrupts your code. I fixed
   you OP code for you.
 *  Thread Starter [hsysgrp](https://wordpress.org/support/users/hsysgrp/)
 * (@hsysgrp)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13318735)
 * Thank you for your response. My URL according to Bluehost doc guidance is
    <form
   method=”post” action=”[http://hsysgrp.com/wp-content/themes/twentytwelve-child/insert.php”&gt](http://hsysgrp.com/wp-content/themes/twentytwelve-child/insert.php”&gt);
   ID: <input type=”text” name=”ID”> FirstName: <input type=”text” name=”FirstName”
   > LastName: <input type=”text” name=”LastName”> Address1: <input type=”text” 
   name=”Address1″> <input type=”submit”> </form>That elicited This page isn’t working
   hsysgrp.com is currently unable to handle this request. HTTP ERROR 500
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13324074)
 * There’s an error on insert.php somewhere. Check you error log for clues or check
   the code with something like [https://phpcodechecker.com/](https://phpcodechecker.com/)
 *  Thread Starter [hsysgrp](https://wordpress.org/support/users/hsysgrp/)
 * (@hsysgrp)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13325620)
 * Making progress; php no errors now, thank you for the codechecker but got
    Connected
   successfully, Error, no record inserted.
 *     ```
       <?php
       			$link = mysqli_connect("localhost", "hsys99999", "De99999", "h99999"); 
   
       			if(!$link) {    
       			die ("ERROR: Could not connect. " . mysqli_connect_error() );
       			} 
       			echo "Connected successfully";
       			$ID = $_POST['ID'];
       			$FirstName = $_POST['FirstName'];
       			$Lastname = $_POST['Lastname'];
       			$Address1 = $_POST['Address1'];
       			$SQL = "INSERT INTO AAUW_MEMBERS(ID,FirstName,Lastname,Address1) VALUES ('$ID','$FirstName','$Lastname','$Address1')";
   
       			if(mysqli_query($link,$SQL)) {
       					echo " New Record Inserted" ;
       			} else
       			{
       					echo "Error: No record inserted" ;
       			}
       			mysqli_close($link) ;
       ?>
       ```
   
    -  This reply was modified 5 years, 9 months ago by [bcworkz](https://wordpress.org/support/users/bcworkz/).
      Reason: code fixed
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13329241)
 * Add `print_r( $_POST );` to ensure the forms values are transmitted correctly.
   I’ve no reason to believe they wouldn’t be, but lets make sure.
 * Get into the phpMyAdmin app and navigate to the database containing the table.
   Click on the SQL tab and execute this:
    `INSERT INTO AAUW_MEMBERS(ID,FirstName,
   Lastname,Address1) VALUES ('1234','Foo','Bar','123 sample st, city')` Edit this
   query’s values as needed for your data types before execution. The app should
   give you a clue to the problem if insertion fails. If insertion works, check 
   the DB permissions for the DB user your PHP code uses. It’s apparently restricted
   in some way.
 *  Thread Starter [hsysgrp](https://wordpress.org/support/users/hsysgrp/)
 * (@hsysgrp)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13329974)
 * Manual Insert in phpMyAdmin works fine.
    Added the print_r statements and found
   Firstname != FirstName DB user has all privileges like Admin`
 * Connected successfully 12 Jane 4 Lecco Lane Error: No record inserted
 * No errors from codechecker
 *     ```
       <?php
       			$link = mysqli_connect("localhost", "hsysgrpc_99999", "Desero999!", "hsysgrp999999"); 
   
       			if(!$link) {    
       			die ("ERROR: Could not connect. " . mysqli_connect_error() );
       			} 
       			echo "Connected successfully";
       			$ID = $_POST['ID'];
       			print_r($ID);
       			$FirstName = $_POST['FirstName'];
       			print_r($FirstName);
       			$Lastname = $_POST['LastName'];
       			print_r($LastName);
       			$Address1 = $_POST['Address1'];
       			print_r($Address1);
       			$SQL = "INSERT INTO AAUW_MEMBERS(ID,FirstName,LastName,Address1) VALUES ('$ID','$FirstName','$LastName','$Address1')";
   
       			if(mysqli_query($link,$SQL)) {
       					echo " New Record Inserted" ;
       			} else
       			{
       					echo "Error: No record inserted" ;
       			}
       			mysqli_close($link) ;
       ?>
       ```
   
 * So close.
 *  Thread Starter [hsysgrp](https://wordpress.org/support/users/hsysgrp/)
 * (@hsysgrp)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13340673)
 * Success. Turns out a http 500 error just means the table is AAUW_Members instead
   of AAUW_MEMBERS. Works fine, thanks for all the help.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Failed Insert’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 9 replies
 * 3 participants
 * Last reply from: [hsysgrp](https://wordpress.org/support/users/hsysgrp/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/failed-insert/#post-13340673)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
