Pasa Mike Posted February 14, 2007 Share Posted February 14, 2007 I'm not sure how to get around this.... Error: " error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 2, '1', '1', 2, NULL, 'Testing... one two three', NULL)' at line 1 " ===================================================================================================== Thanks in advance for any help, I'm still learning my way around.... My Code: (created to add an event to dynamic listing/calender) ---------------------------------------------------------------- <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "form1")) { $insertSQL = sprintf("INSERT INTO tbl_content (startdate, numofdays, time1, time2, price, title, description, timestamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['startdate'], "startdate"), GetSQLValueString($_POST['numofdays'], "tinyint"), GetSQLValueString($_POST['time1'], "text"), GetSQLValueString($_POST['time2'], "text"), GetSQLValueString($_POST['price'], "int"), GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString($_POST['timestamp'], "date")); mysql_select_db($database_dbc, $dbc); $Result1 = mysql_query($insertSQL, $dbc) or die(mysql_error()); $insertGoTo = "event_add2.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"><!-- InstanceBegin template="/Templates/edit-r.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <!-- InstanceBeginEditable name="doctitle" --> <title>.:the wave:. admin panel 1.0</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="head" --> <script type="text/JavaScript"> <!-- function MM_popupMsg(msg) { //v1.0 confirm(msg); } function GP_popupConfirmMsg(msg) { //v1.0 document.MM_returnValue = confirm(msg); } //--> </script> <link href="wstyle.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 {color: #999999} .style4 {color: #999999; font-size: 12px; } --> </style> </head> <body bgcolor="#4c4920" leftmargin="0" topmargin="0" rightmargin="0"> <table height="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="940" rowspan="2"><table width="940" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="940" height="670" valign="top"><table height="728" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="150" colspan="3" valign="top"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="940" height="150"> <param name="movie" value="swf/main.swf" /> <param name="quality" value="high" /> <embed src="swf/main.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="940" height="150"></embed> </object></td> </tr> <tr> <td colspan="3" valign="top" bgcolor="#123C8D"></td> </tr> <tr> <td height="2" colspan="3" valign="middle" bgcolor="#123C8D"></td> </tr> <tr> <td width="10" rowspan="2" valign="middle" bgcolor="#133E8C"> </td> <td width="913" rowspan="2" align="left" valign="top" bgcolor="#123D8C"> <!--Begin editable Form--> <form id="form1" name="form1" method="post" action="<?php echo $editFormAction; ?>"> <table width="900" border="0"> <tr> <td width="182" valign="top"><img src="images/addevent1.gif" width="182" height="74" /></td> <td width="501" rowspan="2"><div align="left" class="Wtext"><strong>Event Title:</strong><br /> <input name="textfield" type="text" size="55" /> </div> <div align="left"> <script>DateInput('startdate', true, 'YYYY-MM-DD')</script> <br /> <span class="Wtext"><strong>Number of Days: </strong></span><span class="style4">{select <strong>one</strong> option} </span><br /> <table width="155" border="0"> <tr> <td width="149" class="Wtext"><div align="right">Single Day: <input name="numofdays" type="radio" value="1" /> </div></td> </tr> <tr> <td class="Wtext"><div align="right">Multiple Days: <input name="numofdays" type="radio" value="2" /> </div></td> </tr> </table> <br /> <span class="Wtext"><strong>Time Schedule: </strong></span><span class="style4">{select which information will be needed} </span><br /> <table width="155" border="0"> <tr> <td width="149" class="Wtext"><div align="right">Meet Time: <input name="time1" type="radio" value="0" /> </div></td> </tr> <tr> <td class="Wtext"><div align="right">Start Time: <input name="time1" type="radio" value="1" /> </div></td> </tr> </table> <br /> <table width="155" border="0"> <tr> <td width="149" class="Wtext"> <div align="right">End Time:<input name="time2" type="radio" value="0" /><br /> Return Time:<input name="time2" type="radio" value="1" /></div></td> </tr> </table> <br /> <span class="Wtext"><strong>Price: </strong></span><span class="style4">{select <strong>one</strong> option}</span><br /> <table width="155" border="0"> <tr> <td width="149"><div align="right"><span class="Wtext">Free: <input name="price" type="radio" value="1" /> </span></div></td> </tr> <tr> <td><div align="right"><span class="Wtext">One Payment: <input name="price" type="radio" value="2" /> </span></div></td> </tr> <tr> <td><div align="right"><span class="Wtext">Multiple Payments: <input name="price" type="radio" value="3" /> </span></div></td> </tr> </table> <br /> <p><span class="Wtext"><strong>Event Description: </strong></span><span class="style4">{<strong>simple explanation</strong> of the event - not exhaustive}</span><br /> <textarea name="description" cols="55" rows="5" id="description"></textarea> </p> <p><span class="style2">Ready to move on?:</span><br /> <input type="reset" value="Reset" /> <input type="submit" value="Continue" /> </p> </div> </label></td> <td width="203"> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="3"> </td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form> </td> <td width="17" height="300" valign="middle" bgcolor="#133E8C"> </td> </tr> <tr> <td height="200" valign="middle" bgcolor="#133E8C"> </td> </tr> <tr> <td height="76" colspan="3" valign="top" background="images/bkgnd_footer.gif" bgcolor="#062464"><div class="Copywright"><br /> </div> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="431"><table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="10"> </td> <td width="417" valign="top"><span class="copywright">© 2004–2007 <a href="http://www.cbglades.com/" class="copywright">Church by the Glades.</a> All rights reserved.<br /> 400 Lakeview Drive, Coral Springs, Florida, 33071. 954.755.7766</span><br /> <span class="michaelnewsom">Web Site Design by <a href="http://www.michaelnewsom.com/" class="michaelnewsom" target="_blank">Michael Newsom</a></span></td> </tr> </table></td> <td width="492" valign="top"><div align="center"><a href="http://www.cbglades.com/" class="botlinks">Church by the Glades</a><span class="style2"> |</span> <a href="http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=132460813" class="botlinks"> The Wave @ myspace.com</a> <br /><a href="/" class="botlinks">Home</a><span class="style2"> | </span> <a href="/wpg.php?title=The+Wave" class="botlinks">The Wave</a><span class="style2"> | </span> <a href="/wpg.php?title=Life+Groups" class="botlinks">Life Groups</a><span class="style2"> | </span> <a href="/wpg.php?title=Elements" class="botlinks">Elements</a> <span class="style2">|</span> <a href="/wpg2.php?title=Events" class="botlinks">Events</a><span class="style2"> | </span> <a href="/wpg3.php?title=Resources" class="botlinks">Resources</a><span class="style2"> | </span> <a href="/wpg.php?title=Contact+Us" class="botlinks">Contact Us</a> </div> </td> </tr> </table></td> </tr> </table> <p></p></td> </tr> </table> <p></p></td> <td width="58" height="272" valign="bottom" background="images/RVert.jpg"> </td> </tr> <tr> <td valign="bottom"> </td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 14, 2007 Share Posted February 14, 2007 Wayyyy too much code. We don't need your HTML. Use Code Tags! Do this: $Result1 = mysql_query($insertSQL, $dbc) or die('Query: '.$insertSQL.' - '.mysql_error()); So you can see exactly what your sql looks like. Post the result here. That will help explain where the problem lies. 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.