Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsZymic Free Web HostingDatabases & MySQL right
  Closed Topic Start new topic
left right
50cals
post Apr 30 2010, 04:22 AM
Post #1


Newbie
*

Group: Members
Posts: 6
Joined: 8-April 10
Member No.: 137,700



Hello, I have this website with database you can enter items into. This is the insert code for the page and works great, items can be added to the database with no problem.

Now if i go into sqlbuddy and add a new column before my "name" column, then I add a new $*** = $_POST['***']; line right above the $iname line , it comes up with the die message. Again this webform works great with just the 4 columns , I can add and search my database from my website. When i try to add new columns before first column or add to end of table , it errors out. Is there something i need to do to the table ? Is the new column i created in the front of the table not actually the first column? I even created a new table with 6 columns, added the 6 $_POST's and still get the error. When i try with the original table it works fine, just when i try to add new columns and add the colums to the code.... it doesnt work. Any ideas?

Thx

50cals


*****Code below works fine*****
<?php
if (isset($_POST['submitted'])) {

include('*.php');

$iname = $_POST['iname'];
$imlvl = $_POST['imlvl'];
$itype = $_POST['itype'];
$idescription = $_POST['idescription'];


$sqlinsert = "INSERT INTO rc (name, mlvl, type, description) VALUES ('$iname', '$imlvl', '$itype', '$idescription')";

if (!mysqli_query($dbcon, $sqlinsert)) {
die('error inserting new record');
}
$newrecord ="New Inventory Added";

}
?>


*****Code below errors*****
<?php
if (isset($_POST['submitted'])) {

include('*.php');
$inewcolumn = $_POST['inewcolumn']; ****newcolumn column created before first column*****
$iname = $_POST['iname'];
$imlvl = $_POST['imlvl'];
$itype = $_POST['itype'];
$idescription = $_POST['idescription'];


$sqlinsert = "INSERT INTO rc (newcolumn, name, mlvl, type, description) VALUES ('$inewcolumn', '$iname', '$imlvl', '$itype', '$idescription')";

if (!mysqli_query($dbcon, $sqlinsert)) {
die('error inserting new record');
}
$newrecord ="New Inventory Added";

}
?>
Go to the top of the page 
 
  + Quote Post
uncled1023
post Apr 30 2010, 05:11 AM
Post #2


Super Duper Ninja
*****

Group: Members
Posts: 423
Joined: 24-February 08
Member No.: 11,718



you haver VALUES('inewcolumn', ..... when it should be VALUES('$inewcolumn', .... since its a variable.
Go to the top of the page 
 
  + Quote Post
50cals
post Apr 30 2010, 06:37 AM
Post #3


Newbie
*

Group: Members
Posts: 6
Joined: 8-April 10
Member No.: 137,700



QUOTE(uncled1023 @ Apr 30 2010, 05:11 AM) *
you haver VALUES('inewcolumn', ..... when it should be VALUES('$inewcolumn', .... since its a variable.



sry that was typo in my post........ I have it as '$inewcolumn' ...... still errors

Again , with the original table and the first code chunk of just name, mlvl, type, description....... it works just fine

Now i go to sqlbuddy , and CREATE a new column before the first column which is name , and i add the new column to the code in the right places.... and it gets to the error inserting new data

If i take that new column out of the code..... the page works fine

It is like it is not seeing the new column created and it is listed in the INSERT INTO as the first column

This should not be doing this.
Go to the top of the page 
 
  + Quote Post
50cals
post Apr 30 2010, 06:51 AM
Post #4


Newbie
*

Group: Members
Posts: 6
Joined: 8-April 10
Member No.: 137,700



Here is the submit and the entry code........ this works perfect as is , table has 5 columns. Now i go to sqlbuddy add a new column before "name" . Now all i do is just add the new column name above the first $_POST['iname'] , and then before name in INSERT INTO , and before name in VALUES (column name and a comma) , and one new line in the LEGEND portion with the new column name. Without the addition of new columns this code works fine , its just when i add a new column....... any more ideas? thx for you time

<?php
if (isset($_POST['submitted'])) {

include('connect.php');

$iname = $_POST['iname'];
$imlvl = $_POST['imlvl'];
$itype = $_POST['itype'];
$idescription = $_POST['idescription'];
$ibound = $_POST['ibound'];

$sqlinsert = "INSERT INTO rc (name, mlvl, type, description, bound) VALUES ('$iname', '$imlvl', '$itype', '$idescription', '$ibound')";

if (!mysqli_query($dbcon, $sqlinsert)) {
die('error inserting new record');
}
$newrecord ="New Inventory Added";

}
?>
<html>
<head>
<title>Insert your Inventory</title>
</head>
<body>

<h1>Insert your Inventory</h1>
<form method="post" action="self.php">
<input type="hidden" name="submitted" value="true" />
<fieldset>
<legend>Inventory</legend>
<label>Item Name: <input type="text" name="iname" /></label>
<label>Min lvl: <input type="text" name="imlvl" /></label>
<label>Item type: <input type="text" name="itype" /></label>
<label>Description: <input type="text" name="idescription" /></label>
<label>Item bound?: <input type="text" name="ibound" /></label>
</fieldset>

<br />
<input type="submit" value="add" />
</form>
<?
echo $newrecord
?>
Go to the top of the page 
 
  + Quote Post
 Closed Topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 22nd May 2013 - 08:12 AM