Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been over the code all day now and can simply not see why it is not inserting.
any ideas ?

form.php
HTML
<form method="post" action="insert.php">

	Name Of Band:</br>
	<input type="text" name="Name" /><br />

	Show Name:</br>
	<input type="text" name="show" /><br />

	Venue:</br>
	<input type="text" name="Venue" /><br />

	Category:</br>
	 <input type="text" name="Category" /><br />

	 Stock:</br>
	 <input type="text" name="Stock" /><br />

	 Time And Date:</br>
	 <input type="datetime-local" name="time" /><br />

	 Price:</br>
	 <input type="text" name="price" /><br />

	 Infomation:</br>
	 <textarea cols="50" rows="4" name="infomation" /></textarea></br>

	<input type="submit" value="Add Band"/>

	</form>


insert.php
PHP
require 'core/init.php';

$Name = $_REQUEST["Name"];
$show = $_REQUEST["show"];
$Venue = $_REQUEST["Venue"];
$Category = $_REQUEST["Category"];
$Stock = $_REQUEST["Stock"];
$time = $_REQUEST["time"];
$price = $_REQUEST["price"];
$infomation = $_REQUEST["infomation"];

$query = "INSERT INTO bands (Name, show, Venue, Category, Stock, time, price, infomation)
VALUES ('$Name', '$show', '$Venue', '$Category', '$Stock', '$time', '$price', '$infomation')";
mysql_query ($query, $linkme)
header("location:admin.php");


Table
SQL
CREATE TABLE IF NOT EXISTS `bands` (
  `Band_id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(20) NOT NULL,
  `show` varchar(22) NOT NULL,
  `Venue` varchar(20) NOT NULL,
  `Category` varchar(20) NOT NULL,
  `time` datetime NOT NULL,
  `price` float NOT NULL,
  `Stock` int(11) NOT NULL,
  `infomation` text NOT NULL,
  PRIMARY KEY (`Band_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;
Posted
Updated 22-Jan-14 13:15pm
v2
Comments
E.F. Nijboer 22-Jan-14 18:49pm    
What does the error log say?
Ben Oats 22-Jan-14 19:09pm    
if i echo out the query, nothing it shows the data in the correct places.
Ron Beyer 22-Jan-14 19:04pm    
Can you post the table structure?
Ben Oats 22-Jan-14 19:10pm    
yes no problem, I will add id to the question.

1 solution

You should not be inserting the Price, Time, or Stock items as text with the single quotes. Also make sure that the date is properly formatted to be inserted.

Try printing out the raw insert and trying it in your management tool.
 
Share this answer
 
Comments
Ben Oats 22-Jan-14 19:32pm    
ok so on the value ('$Name', '$show', '$Venue', '$Category', '$Stock', '$time', '$price', '$infomation')";

use double " ?
Ron Beyer 22-Jan-14 19:41pm    
No, single quotes for string values, no quotes for things that are integers/numbers. The time I think still uses single quotes but it has to be in a format that the database can parse.
Ben Oats 22-Jan-14 19:57pm    
Ok il try your advice then accept your answer thank you Ron.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900