Incorrect Table Name "
Max Resnikoff Sep 13, 2014 7:50 AMI keep getting this error message when i try to add a new record:
Warning: mysql_pconnect(): MySQL server has gone away in C:\xampp\htdocs\dramadatabase\Connections\drama_database.php on line 9
INSERT INTO ``set`` (name, `description`, `size`, weight, `values`, material, maneuverability, quantity, image) VALUES ('asd', 'asd', 'Small', 'Light', 'Cheap', 'asd', 'Easy', 6, 'http://helpx.adobe.com/dreamweaver/using/building-search-results-pages.html')Incorrect table name ''
Here is my page code:
<title>Add New Set</title>
<?php require_once('Connections/drama_database.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "addset")) {
$insertSQL = sprintf("INSERT INTO ``set`` (name, `description`, `size`, weight, `values`, material, maneuverability, quantity, image) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['size'], "text"),
GetSQLValueString($_POST['weight'], "text"),
GetSQLValueString($_POST['values'], "text"),
GetSQLValueString($_POST['material'], "text"),
GetSQLValueString($_POST['maneuverability'], "text"),
GetSQLValueString($_POST['quantity'], "int"),
GetSQLValueString($_POST['image'], "text"));
mysql_select_db($database_drama_database, $drama_database);
$Result1 = mysql_query($insertSQL, $drama_database) or die(mysql_error());
$insertGoTo = "setinventory.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_drama_database, $drama_database);
$query_addset = "SELECT * FROM `set`";
$addset = mysql_query($query_addset, $drama_database) or die(mysql_error());
$row_addset = mysql_fetch_assoc($addset);
$totalRows_addset = mysql_num_rows($addset);
session_start(); ?>
<!--HEADER CONTENT START -->
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<head>
<style type="text/css">
body{ margin:0px; background:#FFF;}
.header {
height:165px;
background:#FFF;
border:1px solid#CCC;
position:fixed;
width:100%;
top:0px;
}
</style>
</head>
<div class="header"><?php include('defaultheader.php');?></div>
<div class="addnewequipsidebutton"></div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<!--HEADER CONTENT END -->
<div align="center">
<h1>Add New Set</h1>
</div>
<div align="center">
<form action="<?php echo $editFormAction; ?>" method="POST" name="addset" id="addset">
<table width="294" border="0">
<tr>
<td width="108" class="formtag">Name</td>
<td width="176"><span id="sprytextfield1">
<label for="name"></label>
<input name="name" type="text" class="formfield" id="name">
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td class="formtag">Description</td>
<td><span id="sprytextfield2">
<label for="description"></label>
<textarea name="description" class="formfielddesc" id="description"></textarea>
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td class="formtag">Size</td>
<td><label for="size"></label>
<select name="size" class="formfield" id="size">
<!--Connection to Other Table-->
<option id="0">-- Select Size --</option>
<?php
require("Connections/drama_database.php");
$getallsetsize = mysql_query("SELECT * FROM setsize");
while($viewallsetsize = mysql_fetch_array($getallsetsize)){
?>
<option id="<?php echo $viewallsetsize['id']; ?>"><?php echo $viewallsetsize['size'] ?></option>
<?php } ?>
<!--Connection to Other Table-->
</select></td>
</tr>
<tr>
<td class="formtag">Weight</td>
<td><label for="weight"></label>
<select name="weight" class="formfield" id="weight">
<!--Connection to Other Table-->
<option id="0">-- Select Weight --</option>
<?php
require("Connections/drama_database.php");
$getallsetweight = mysql_query("SELECT * FROM setweight");
while($viewallsetweight = mysql_fetch_array($getallsetweight)){
?>
<option id="<?php echo $viewallsetweight['id']; ?>"><?php echo $viewallsetweight['weight'] ?></option>
<?php } ?>
<!--Connection to Other Table-->
</select></td>
</tr>
<tr>
<td class="formtag">Value</td>
<td><label for="values"></label>
<select name="values" class="formfield" id="values">
<!--Connection to Other Table-->
<option id="0">-- Select Value --</option>
<?php
require("Connections/drama_database.php");
$getallsetvalues = mysql_query("SELECT * FROM setvalues");
while($viewallsetvalues = mysql_fetch_array($getallsetvalues)){
?>
<option id="<?php echo $viewallsetvalues['id']; ?>"><?php echo $viewallsetvalues['values'] ?></option>
<?php } ?>
<!--Connection to Other Table-->
</select></td>
</tr>
<tr>
<td class="formtag">Material</td>
<td><span id="sprytextfield3">
<label for="material"></label>
<input name="material" type="text" class="formfield" id="material">
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td class="formtag">Maneuverability</td>
<td><label for="maneuverability"></label>
<select name="maneuverability" class="formfield" id="maneuverability">
<!--Connection to Other Table-->
<option id="0">-- Select Maneuverability --</option>
<?php
require("Connections/drama_database.php");
$getallsetmaneuverability = mysql_query("SELECT * FROM setmaneuverability");
while($viewallsetmaneuverability = mysql_fetch_array($getallsetmaneuverability)){
?>
<option id="<?php echo $viewallsetmaneuverability['id']; ?>"><?php echo $viewallsetmaneuverability['maneuverability'] ?></option>
<?php } ?>
<!--Connection to Other Table-->
</select></td>
</tr>
<tr>
<td class="formtag">Quantity</td>
<td><span id="sprytextfield4">
<label for="quantity"></label>
<input name="quantity" type="text" class="formfield" id="quantity">
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td class="formtag">Image URL</td>
<td><span id="sprytextfield5">
<label for="image"></label>
<input name="image" type="text" class="formfield" id="image">
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td class="formtag"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit" class="button" id="submit" value="Add New Set"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="addset">
</form>
</div>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "integer");
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "url");
</script>
<?php
mysql_free_result($addset);
?>
And here is my SQL Code for the table in question:
-- phpMyAdmin SQL Dump
-- version 3.5.5
--
-- Host: localhost
-- Generation Time: Sep 13, 2014 at 09:49 AM
-- Server version: 5.5.39-36.0
-- PHP Version: 5.4.23
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!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: `mresnik_dramadatabase`
--
-- --------------------------------------------------------
--
-- Table structure for table `set`
--
CREATE TABLE IF NOT EXISTS `set` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text COLLATE utf8_unicode_ci NOT NULL,
`description` text COLLATE utf8_unicode_ci NOT NULL,
`size` text COLLATE utf8_unicode_ci NOT NULL,
`weight` text COLLATE utf8_unicode_ci NOT NULL,
`values` text COLLATE utf8_unicode_ci NOT NULL,
`material` text COLLATE utf8_unicode_ci NOT NULL,
`maneuverability` text COLLATE utf8_unicode_ci NOT NULL,
`quantity` int(11) NOT NULL,
`image` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;
--
-- Dumping data for table `set`
--
INSERT INTO `set` (`id`, `name`, `description`, `size`, `weight`, `values`, `material`, `maneuverability`, `quantity`, `image`, `timestamp`) VALUES
(1, 'Block', 'White block used for defining rooms and stage.', 'Large', 'Heavy', 'Mid-range', 'Wood', 'Hard', 8, 'http://www.conferencestagehire.co.uk/resources/_wsb_453x319_carpet+stage+twin.jpg', '0000-00-00 00:00:00');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


