close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

datepicker + php insert

Thread began 9/05/2012 5:49 am by g.day442129 | Last modified 9/05/2012 10:11 am by g.day442129 | 3049 views | 1 replies

g.day442129

datepicker + php insert

Hello all I/ve browsed the forums & either can t find o runderstand the answers.
Trying to use date picker with an insert record form& am gettting the following error


Notice: Undefined index: ReadDate in C:\xampp\htdocs\solar\readings.php on line 42
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
My DW code is


<?php require_once('Connections/con_solar.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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO daily (ID, ReadDate, accountno, Tarr11, Tarr33, Export, SolarDay) VALUES (%s, #datepicker, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ID'], "int"),
GetSQLValueString($_POST['ReadDate'], "date"),
GetSQLValueString($_POST['accountno'], "int"),
GetSQLValueString($_POST['Tarr11'], "int"),
GetSQLValueString($_POST['Tarr33'], "int"),
GetSQLValueString($_POST['Export'], "int"),
GetSQLValueString($_POST['SolarDay'], "int"));

mysql_select_db($database_con_solar, $con_solar);
$Result1 = mysql_query($insertSQL, $con_solar) or die(mysql_error());

$insertGoTo = "results.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_con_solar, $con_solar);
$query_readings = "SELECT * FROM daily";
$readings = mysql_query($query_readings, $con_solar) or die(mysql_error());
$row_readings = mysql_fetch_assoc($readings);
$totalRows_readings = mysql_num_rows($readings);
?>
<!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>Solar daily readings</title>
<style type="text/css">
body,td,th {
color: #000;
}
body {
background-color: #FC3;
}
</style>
<script src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js" type="text/javascript"></script>
<link href="jquery-ui-1.7.2/css/base/ui.core.css" rel="stylesheet" type="text/css" />
<link href="jquery-ui-1.7.2/css/base/ui.datepicker.css" rel="stylesheet" type="text/css" />
<link href="jquery-ui-1.7.2/css/base/ui.theme.css" rel="stylesheet" type="text/css" />
<link href="jquery-ui-1.7.2/css/base/ui.datepicker.images.css" rel="stylesheet" type="text/css" />
<style type="text/css">
/* BeginOAWidget_Instance_2137022: #datepicker */

#datepicker .ui-widget {
font-family: inherit;
}

#datepicker .ui-datepicker {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}

#datepicker .ui-datepicker-title {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1.1em;
color: #cc0000;
font-weight: normal;
line-height: 1.8em;
}


#datepicker .ui-state-default, .ui-widget-content .ui-state-default {
border-color: #ff9900;
background-color: #ff9900;
color: #cc0000;
}

#datepicker .ui-state-default, .ui-state-default a {
color: #cc0000;
}


#datepicker .ui-state-highlight, .ui-widget-content .ui-state-highlight {
border-color:#66cc99;
background-color:#66cc99;
color:#666699;
}

#datepicker .ui-state-active, .ui-widget-content .ui-state-active {
border-color: #333399;
background-color: #333399;
color: #330066;
}

#datepicker .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus
{
border-color: #ffff99;
background-color: #ffff99;
color: #ff3300;
}

#datepicker .ui-widget-header
{
border-color: #cc0000;
background-color: #ff9900;
border-width: 2px;
}

/* Text attributes for the Days of Week Text */
#datepicker .ui-datepicker table th
{
font-size: .8em;
color: #cc0000;
font-weight: bold;
}



/* EndOAWidget_Instance_2137022 */
</style>
<script type="text/xml">
<!--
<oa:widgets>
<oa:widget wid="2137022" binding="#datepicker" />
</oa:widgets>
-->
</script>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">ID:</td>
<td><input type="text" name="ID" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">ReadDate:</td>
<td><script type="text/javascript">
// BeginOAWidget_Instance_2137022: #datepicker


$(function() {
$("#ReadDate").datepicker({ showOtherMonths: true });
$( ".selector" ).datepicker( "option", "dateFormat", "dd-mm-yy" );

});


// EndOAWidget_Instance_2137022
</script>
<input type="text" id="ReadDate" value=""></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Accountno:</td>
<td><input type="text" name="accountno" value="13351887" size="20" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Tarr11:</td>
<td><input type="text" name="Tarr11" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Tarr33:</td>
<td><input type="text" name="Tarr33" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Export:</td>
<td><input type="text" name="Export" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">SolarDay:</td>
<td><input type="text" name="SolarDay" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<p>
<input type="hidden" name="MM_insert" value="form1" />
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><div class="demo">

<p>Date: <input type="text" id="datepicker"></p>

</div><!-- End demo --></p>
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($readings);
?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...