Jump to content

[SOLVED] 8 field limit


mikebou

Recommended Posts

Hi, My name is Mike and I'm pretty green when it comes to programming of any sort. I have hit an interesting problem in creating a php form that enters data into a mysql table. If I create a table in mysql that has 8 fields or less, the form I create to enter the data works correctly. If though I create the table with 9 fields or more, the php form cannot enter the data successfully either with static entries or via variables. I can successfully enter data into the table via phpadmin with no errors reported.

 

I am using XAMPP 1.6.0a. This version runs Apache 2.2.4, MySql 5.0 and PHP 5.2.1

 

What could I be doing wrong? If the answer is blindingly obvious, the I appologise in advance.  :D Thank you for any suggestions as to what might be going on.

 

Mike B

Link to comment
https://forums.phpfreaks.com/topic/51302-solved-8-field-limit/
Share on other sites

Here is the form saved as weekly.php

 

<html>

<head>

 

</head>

<body>

 

<form name="schedule" action="schedule.php" method="post">

 

 

<table align="LEFT">

 

 

<tr>

        <td>Talk:</td>

        <td><select name="Talk"><?php include("weektalklist.php"); ?></select></td>

</tr>

<tr>

        <td>Speaker:</td>

        <td><select name="Speaker"><?php include("speakerslist.php") ?></select></td>

</tr>

<tr>

        <td>CIA:</td>

        <td><input TYPE="checkbox" NAME="CIA" VALUE="CIA" ></td>

</tr>

<tr>

        <td>COM:</td>

        <td><input TYPE="checkbox" NAME="COM" VALUE="COM" ></td>

</tr>

<tr>

        <td>Notes:</td>

        <td><input TYPE="text" NAME="Notes"></td>

 

 

</tr>

<tr>

        <td>Host:</td>

        <td><select name="Host"><?php include("hostlist.php") ?></select></td>

</tr>

<tr>

        <td><input type="Submit" value="Submit New Entry"></td>

       

</tr>

</table>

 

</form>

</body>

</html>

 

Here is the action page saved as schedule.php

 

<?php

$username="root";

$password="";

$database="ptschedule";

 

$link = mysql_connect(localhost,$username,$password);

 

 

$talk=$_POST['Talk'];

$speaker=$_POST['Speaker'];

$CIA=$_POST['CIA'];

$COM=$_POST['COM'];

$notes=$_POST['Notes'];

$host=$_POST['Host'];

 

@mysql_select_db($database,$link) or die( "Unable to select database");

 

$query = "INSERT INTO `weekly` VALUES ('', '', '$talk', '$speaker', '$CIA', '$COM', , '$Notes', '', '','$host', '', '')";

mysql_query($query) or die( "Unable to Enter Data");

echo 'New speaker successfully entered.';

mysql_close();

?>

 

Here is the dump of the table.

 

-- phpMyAdmin SQL Dump

-- version 2.9.2

-- http://www.phpmyadmin.net

--

-- Host: localhost

-- Generation Time: May 14, 2007 at 12:10 PM

-- Server version: 5.0.33

-- PHP Version: 5.2.1

--

-- Database: `ptschedule`

--

 

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

 

--

-- Table structure for table `weekly`

--

 

CREATE TABLE `weekly` (

  `Wid` int(6) NOT NULL auto_increment,

  `Date` date NOT NULL COMMENT 'Date of Talk.',

  `Talk` smallint(4) unsigned NOT NULL COMMENT 'Talk Number to be given.',

  `Speaker` varchar(30) NOT NULL COMMENT 'The speaker to give the talk.',

  `CIA` enum('no','yes') NOT NULL COMMENT 'Confirm a month in advance.',

  `COM` enum('no','yes') NOT NULL COMMENT 'Confirmed on Monday prior to the Sunday talk is to be given.',

  `Notes` varchar(200) NOT NULL COMMENT 'Notes if needed.',

  `Extra1` varchar(100) NOT NULL COMMENT 'If needed in future.',

  `Extra2` varchar(100) NOT NULL COMMENT 'If needed in future.',

  `Host` varchar(30) NOT NULL COMMENT 'Host family to provide lunch.',

  `Extra3` varchar(100) NOT NULL COMMENT 'If needed in future.',

  `Extra4` varchar(100) NOT NULL COMMENT 'If needed in future.',

  PRIMARY KEY  (`Wid`),

  UNIQUE KEY `Date` (`Date`)

) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

 

 

Hope this helps.  ;D

Link to comment
https://forums.phpfreaks.com/topic/51302-solved-8-field-limit/#findComment-252663
Share on other sites

2 things to try...

 

1. Change your query from this:

 

$query = "INSERT INTO `weekly` VALUES ('', '', '$talk', '$speaker', '$CIA', '$COM', , '$Notes', '', '','$host', '', '')";
mysql_query($query) or die( "Unable to Enter Data");

 

to this: (this will let mysql tell you where it is finding a problem)

$query = "INSERT INTO `weekly` VALUES ('', '', '$talk', '$speaker', '$CIA', '$COM', , '$Notes', '', '','$host', '', '')";
mysql_query($query) or die(mysql_error());

 

2. You may want to try and run your query through phpmyadmin directly with some test values. It looks like you have addressed the structure incorrectly. Specifically it look slike you have a empty value being INSERTED between "$COM" and "$Notes" in you query whereas your SQL dump you provided does not show a field between those two fields.

Link to comment
https://forums.phpfreaks.com/topic/51302-solved-8-field-limit/#findComment-252691
Share on other sites

;D freakus_maximus, your sharp observation of my error has worked a treat. I took out the extra comma and tested the form again. The data entered successfully with no errors. I will now look at the code on my other forms and see if I have repeated the same mistake else where. Again, thank you for your time and expertise.

 

Kind regards, Mike B

Link to comment
https://forums.phpfreaks.com/topic/51302-solved-8-field-limit/#findComment-252700
Share on other sites

No problem glad to help.

 

Can you mark the topic as closed? Bottom left of your post I believe is a "Mark Complete" link.

 

Also, please use the code tags (looks like a the # symbol icon) when posting code. Just post your code, select it, then click the icon. That will make things easier to read in the future.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/51302-solved-8-field-limit/#findComment-252723
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.