Zergman Posted August 31, 2008 Share Posted August 31, 2008 Have a insert form on a page, when I go to submit it, I get this Incorrect table name '' Here's my code <?php require_once('Connections/cnt2tracker.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $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"] == "myform")) { $insertSQL = sprintf("INSERT INTO ``data`` (flagentTID, level1, level2, level3, notes, tdate, flmanager, t2agent) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['flagentTID'], "text"), GetSQLValueString($_POST['optone'], "text"), GetSQLValueString($_POST['opttwo'], "text"), GetSQLValueString($_POST['optthree'], "text"), GetSQLValueString($_POST['notes'], "text"), GetSQLValueString($_POST['tdate'], "date"), GetSQLValueString($_POST['flmanager'], "text"), GetSQLValueString($_POST['t2agent'], "text")); mysql_select_db($database_cnt2tracker, $cnt2tracker); $Result1 = mysql_query($insertSQL, $cnt2tracker) or die(mysql_error()); $insertGoTo = "callDetail.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>TTV Tier 2 Call Tracker</title> <script type="text/javascript"> function setOptions(chosen,selbox) { // selbox assignment deleted selbox.options.length = 0; if (chosen == " ") { selbox.options[selbox.options.length] = new Option('Please Select',' '); setTimeout(setOptions(' ',document.myform.optthree),5); } if (chosen == "1") { selbox.options[selbox.options.length] = new Option('first choice - option one','11'); selbox.options[selbox.options.length] = new Option('first choice - option two','12'); setTimeout(setOptions('11',document.myform.optthree),5); } // repeat for entries in first dropdown list if (chosen == "11") { selbox.options[selbox.options.length] = new Option('first choice - option one - sub one','111'); selbox.options[selbox.options.length] = new Option('first choice - option one - sub two','112'); } // repeat for all the possible entries in second dropdown list } </script> And my page <body> <? include 'includes/header.inc.php'; ?> <br /> details of incident<hr /> <form action="<?php echo $editFormAction; ?>" method="post" name="myform" id="myform"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right"><div align="right">Agent TID :</div></td> <td><input type="text" name="flagentTID" value="" size="32" /></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap="nowrap"><div align="right">Trouble :</div></td> <td><select name="optone" size="10" onchange="setOptions(document.myform.optone.options continued from previous line[document.myform.optone.selectedIndex].value, continued from previous linedocument.myform.opttwo);"> <option value=" " selected="selected"> </option> <option value="1">First Choice</option> <option value="2">Second Choice</option> <option value="3">Third Choice</option> <option value="4">MY CHOICE</option> </select> <select name="opttwo" size="10" onchange="setOptions(document.myform.opttwo.options continued from previous line[document.myform.opttwo.selectedIndex].value, continued from previous linedocument.myform.optthree);"> <option value=" " selected="selected">Please Select</option> </select> <select name="optthree" size="10"> <option value=" " selected="selected">Please Select</option> </select></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right" valign="top"><div align="right">Notes :</div></td> <td><textarea name="notes" cols="50" rows="5"></textarea> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Insert Incident" /></td> </tr> </table> <input type="hidden" name="tdate" value="" /> <input type="hidden" name="flmanager" value="" /> <input type="hidden" name="t2agent" value="" /> <input type="hidden" name="MM_insert" value="myform" /> </form> <p> </p> </body> Never seen this error before and I can't seem to figure out whats wrong. Page loads just fine, but it errors when I click submit. Thanks in advance Quote Link to comment Share on other sites More sharing options...
metrostars Posted August 31, 2008 Share Posted August 31, 2008 Why have you got ``data`` you only need 1 ` at each side. `data` . Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 31, 2008 Share Posted August 31, 2008 your error checkin seems so verbose did u write this yourself? Quote Link to comment Share on other sites More sharing options...
Zergman Posted August 31, 2008 Author Share Posted August 31, 2008 Sadly I didn't write it, Im in a time crunch so I let dreamweaver do it since its a simple page. Im more focused on the backend but I got time to take care of that. Thanks metrostars, that was it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.