0

First off i'm not sure if this post goes in mysql or php so if this is the wrong place please move this post for me.

I am setting up a page with a list of commands that are pulled from a mysql database. I have the page that displays all the commands setup and am working on setting up a page to add new commands to the database. I have followed the same syntax that i've used on several other pages for inserting a new row into the database but it's not working and I am unsure why.

I have pasted my query into phpmyadmin and it works fine directly from the database. When clicking submit to add the new command it executes the section of code that is suppose to insert to the database but the new info does not go in the database. I know this because I have the values of the fields in my form printed on the screen right after it adds the info the db. I know it is connected to the db because it pulls the command list from the db with no problems. I thought it didn't have write permissions so I tried using the same file and db on a different server and db where i knew the db user has write permissions but i still get the same result.

Here is the code. Attached is my sql file in case there is something in my db with a problem.

}else{

$Syntax = $_POST[Syntax];
$Description = $_POST[Description];
$Instructions = $_POST[Instructions];
$category = $_POST[cat];

mysql_query("INSERT INTO `command` SET active='0' Syntax='$Syntax',  

Description='$Description', Instructions='$Instructions', 

cat='$category'");


echo $Syntax;
echo $Description;
echo $Instructions;
echo $category;

echo 'The command has been created.';
}
Attachments
-- phpMyAdmin SQL Dump
-- version 2.11.6
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 18, 2008 at 09:26 PM
-- Server version: 5.0.51
-- PHP Version: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `helpdesk`
--

-- --------------------------------------------------------

--
-- Table structure for table `comcat`
--

CREATE TABLE `comcat` (
  `ctid` int(3) NOT NULL auto_increment,
  `catname` varchar(24) NOT NULL,
  `active` varchar(1) NOT NULL,
  `catdesc` varchar(504) NOT NULL,
  PRIMARY KEY  (`ctid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `comcat`
--

INSERT INTO `comcat` (`ctid`, `catname`, `active`, `catdesc`) VALUES
(1, 'General', '0', 'These are general linux commands not specific to the nobles software but still commonly used in our environment. This is the onl'),
(2, 'System', '0', 'These are commands that make system wide changes but are not specific to the host or dialer software.'),
(3, 'User', '0', 'These are commands for viewing and managing users.'),
(4, 'Host', '0', 'These are commands used specifically for managing the host software.'),
(5, 'Dialer', '0', 'These are commands used specifically for managing the dialer software.'),
(6, 'End of Day', '0', 'These are commands used only for the end of day process.');

-- --------------------------------------------------------

--
-- Table structure for table `command`
--

CREATE TABLE `command` (
  `cmid` int(3) NOT NULL auto_increment,
  `cat` int(3) NOT NULL,
  `active` int(1) NOT NULL,
  `Syntax` varchar(24) NOT NULL,
  `Description` varchar(128) NOT NULL,
  `Instructions` varchar(250) NOT NULL,
  PRIMARY KEY  (`cmid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--
-- Dumping data for table `command`
--

INSERT INTO `command` (`cmid`, `cat`, `active`, `Syntax`, `Description`, `Instructions`) VALUES
(1, 1, 0, 'rlogin server', 'Remotely login to another server.', 'Replace server with the server name'),
(2, 2, 0, 'halt', 'Shuts down the server.', 'type halt'),
(3, 3, 0, 'w', 'Shows the users logged in and what they are doing.', 'type w'),
(4, 4, 0, 'mgr', 'Settings manager for the host.', 'type mgr'),
(5, 5, 0, 'udr', 'Dialer information software.', 'type udr'),
(6, 6, 0, 'chkhours', 'Run the check hours script.', 'type chkhours'),
(7, 1, 0, 'date xxxxxxxxxx', 'Change the date on the nobles system.', 'Monthx2 dayx2 timex4 yearx2 Don''t change during production.'),
(8, 5, 0, 'isql', 'Opens dialer database.', 'Type isql');
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by pritaeas
0

cat is an integer, so it doesn't need the quotes. But if you do

mysql_query(..) or die(mysql_error());

you can see what's wrong.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.