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

rating

MySQL error on Digital Pro

Thread began 2/01/2011 1:35 pm by m.finelli420407 | Last modified 2/01/2011 3:37 pm by Jason Byrnes | 1139 views | 6 replies |

m.finelli420407

MySQL error on Digital Pro

Hello,
I follow all the passages of the "Adding Digital File Pro to DataAssist Insert and Update Pages" guide.
I have an already Insert, Update and Detail page done with Data Assist.
Completing the process of creating an update field in my Insert and Update page and a image preview on my detail page, I went on testing.
I open the Insert page, and on clicking "insert" I get this nice MySQL error advice:

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 '1)' at line 1

Has the table in my database to be set in a specific way? Does anyone has got this message?

I've bought the Super Suite in December 2010.

Thanks!

Sign in to reply to this post

Jason ByrnesWebAssist

please send a copy of your page so i can see the code.

Sign in to reply to this post

m.finelli420407

the page

Here you have the full code:

<?php require_once('Connections/foto.php'); ?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("webassist/file_manipulation/helperphp.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;
}
}
?>
<?php
$maxRows_WADADynListtblAlbums = 1000;
$pageNum_WADADynListtblAlbums = 0;
if (isset($_GET['pageNum_WADADynListtblAlbums'])) {
$pageNum_WADADynListtblAlbums = $_GET['pageNum_WADADynListtblAlbums'];
}
$startRow_WADADynListtblAlbums = $pageNum_WADADynListtblAlbums * $maxRows_WADADynListtblAlbums;

mysql_select_db($database_foto, $foto);
$query_WADADynListtblAlbums = "SELECT albumID, albumTitolo FROM tblAlbums";
$query_limit_WADADynListtblAlbums = sprintf("%s LIMIT %d, %d", $query_WADADynListtblAlbums, $startRow_WADADynListtblAlbums, $maxRows_WADADynListtblAlbums);
$WADADynListtblAlbums = mysql_query($query_limit_WADADynListtblAlbums, $foto) or die(mysql_error());
$row_WADADynListtblAlbums = mysql_fetch_assoc($WADADynListtblAlbums);

if (isset($_GET['totalRows_WADADynListtblAlbums'])) {
$totalRows_WADADynListtblAlbums = $_GET['totalRows_WADADynListtblAlbums'];
} else {
$all_WADADynListtblAlbums = mysql_query($query_WADADynListtblAlbums);
$totalRows_WADADynListtblAlbums = mysql_num_rows($all_WADADynListtblAlbums);
}
$totalPages_WADADynListtblAlbums = ceil($totalRows_WADADynListtblAlbums/$maxRows_WADADynListtblAlbums)-1;?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "foto/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1_2 Start
$WA_UploadResult1_Params["WA_UploadResult1_2"] = array(
'UploadFolder' => "foto/thumb/",
'FileName' => "[FileName]_thumb",
'DefaultFileName' => "",
'ResizeType' => "4",
'ResizeWidth' => "100",
'ResizeHeight' => "100",
'ResizeFillColor' => "" );
// WA_UploadResult1_2 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "photoLocation", "0", "", "true", $WA_UploadResult1_Params);
}
?>
<?php
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $foto;
$WA_table = "tblPhotos";
$WA_sessionName = "WADA_Insert_tblPhotos";
$WA_redirectURL = "tblPhotos_Detail.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "photoID";
$WA_fieldNamesStr = "photoTitolo|photoTitle|photoDescr|photoDesceng|photoLocation|photoThum|albumID";
$WA_fieldValuesStr = "".((isset($_POST["photoTitolo"]))?$_POST["photoTitolo"]:"") ."" . "|" . "".((isset($_POST["photoTitle"]))?$_POST["photoTitle"]:"") ."" . "|" . "".((isset($_POST["photoDescr"]))?$_POST["photoDescr"]:"") ."" . "|" . "".((isset($_POST["photoDesceng"]))?$_POST["photoDesceng"]:"") ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."" . "|" . "".((isset($_POST["photoThum"]))?$_POST["photoThum"]:"") ."" . "|" . "".((isset($_POST["albumID"]))?$_POST["albumID"]:"") ."";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_foto;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?><!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>Insert tblPhotos</title>
<link href="WA_DataAssist/styles/Refined_Pacifica.css" rel="stylesheet" type="text/css" />
<link href="WA_DataAssist/styles/Arial.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="WADAInsertContainer">
<form action="tblPhotos_Insert.php" method="post" enctype="multipart/form-data" name="WADAInsertForm" id="WADAInsertForm">
<div class="WADAHeader">Insert Record</div>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">photoID:</th>
<td class="WADADataTableCell"></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoTitolo:</th>
<td class="WADADataTableCell"><input type="text" name="photoTitolo" id="photoTitolo" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoTitle:</th>
<td class="WADADataTableCell"><input type="text" name="photoTitle" id="photoTitle" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoDescr:</th>
<td class="WADADataTableCell"><input type="text" name="photoDescr" id="photoDescr" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoDesceng:</th>
<td class="WADADataTableCell"><input type="text" name="photoDesceng" id="photoDesceng" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoLocation:</th>
<td class="WADADataTableCell"><input type="file" name="photoLocation" id="photoLocation" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoThum:</th>
<td class="WADADataTableCell"><input type="text" name="photoThum" id="photoThum" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">albumID:</th>
<td class="WADADataTableCell">
<select name="albumID" id="albumID">
<option value="">seleziona l'album</option>
<?php
do {
?>
<option value="<?php echo $row_WADADynListtblAlbums['albumID']?>"><?php echo $row_WADADynListtblAlbums['albumTitolo']?></option>
<?php
} while ($row_WADADynListtblAlbums = mysql_fetch_assoc($WADADynListtblAlbums));
$rows = mysql_num_rows($WADADynListtblAlbums);
if($rows > 0) {
mysql_data_seek($WADADynListtblAlbums, 0);
$row_WADADynListtblAlbums = mysql_fetch_assoc($WADADynListtblAlbums);
}
?>
</select>
</td>
</tr>
</table>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Insert" id="Insert" value="Insert" alt="Insert" src="WA_DataAssist/images/Pacifica/Refined_insert.gif" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="tblPhotos_Results.php" title="Cancel"><img border="0" name="Cancel" id="Cancel" alt="Cancel" src="WA_DataAssist/images/Pacifica/Refined_cancel.gif" /></a></td>
</tr>
</table>
<input name="WADAInsertRecordID" type="hidden" id="WADAInsertRecordID" value="" />
</div>
</form>
</div>
</body>
</html>
<?php
mysql_free_result($WADADynListtblAlbums);
?>

Sign in to reply to this post

Jason ByrnesWebAssist

in the insert record behavior, make sure to select a data type for each column that data will be inserted to.

Sign in to reply to this post

m.finelli420407

Consider that the code was completely done automatically by Data Assist.
In which part of the Application Builder Insert have I to intervene?

Thanks!

Sign in to reply to this post

m.finelli420407

I understood what you mean.
I completed all the fields... and it works, but I cannot see the image....

This is the code of the detail page:
<?php require_once('Connections/foto.php'); ?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.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;
}
}
?><?php
if (!session_id()) session_start();
?>
<?php
$ParamphotoID_WADAtblPhotos = "-1";
if (isset($_GET['photoID'])) {
$ParamphotoID_WADAtblPhotos = (get_magic_quotes_gpc()) ? $_GET['photoID'] : addslashes($_GET['photoID']);
}
$ParamSessionphotoID_WADAtblPhotos = "-1";
if (isset($_SESSION['WADA_Insert_tblPhotos'])) {
$ParamSessionphotoID_WADAtblPhotos = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_tblPhotos'] : addslashes($_SESSION['WADA_Insert_tblPhotos']);
}
$ParamphotoID2_WADAtblPhotos = "-1";
if (isset($_GET['photoID'])) {
$ParamphotoID2_WADAtblPhotos = (get_magic_quotes_gpc()) ? $_GET['photoID'] : addslashes($_GET['photoID']);
}
mysql_select_db($database_foto, $foto);
$query_WADAtblPhotos = sprintf("SELECT photoID, photoTitolo, photoTitle, photoDescr, photoDesceng, photoLocation, photoThum, albumID FROM tblPhotos WHERE photoID = %s OR ( -1= %s AND photoID= %s)", GetSQLValueString($ParamphotoID_WADAtblPhotos, "int"),GetSQLValueString($ParamphotoID2_WADAtblPhotos, "int"),GetSQLValueString($ParamSessionphotoID_WADAtblPhotos, "int"));
$WADAtblPhotos = mysql_query($query_WADAtblPhotos, $foto) or die(mysql_error());
$row_WADAtblPhotos = mysql_fetch_assoc($WADAtblPhotos);
$totalRows_WADAtblPhotos = mysql_num_rows($WADAtblPhotos);?>
<?php
// WA Application Builder Delete
if (isset($_POST["Delete_x"])) // Trigger
{
$WA_connection = $foto;
$WA_table = "tblPhotos";
$WA_redirectURL = "tblPhotos_Results.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "photoID";
$WA_columnTypesStr = "undefined";
$WA_fieldValuesStr = "".((isset($_POST["WADADeleteRecordID"]))?$_POST["WADADeleteRecordID"]:"") ."";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_comparisions = explode("|", $WA_comparisonStr);
$WA_connectionDB = $database_foto;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$deleteParamsObj = WA_AB_generateWhereClause($WA_fieldNames, $WA_columns, $WA_fieldValues, $WA_comparisions);
$WA_Sql = "DELETE FROM `" . $WA_table . "` WHERE " . $deleteParamsObj->sqlWhereClause;
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<!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>Details tblPhotos</title>
<link href="WA_DataAssist/styles/Refined_Pacifica.css" rel="stylesheet" type="text/css" />
<link href="WA_DataAssist/styles/Arial.css" rel="stylesheet" type="text/css" />
<style type="text/css">
/* Title Section */
#WADAPageTitleArea {
width: 555px;
}
#WADAPageTitleArea div, #WADAPageTitleArea p {
font-size: 11px;
padding-bottom: 10px;
}
#WADAPageTitleArea div#WADAPageTitle, #WADAPageTitle {
font-size: 14px;
font-weight: bold;
}

/* Details page CSS */
.WADADetailsContainer {
font-size: 11px;
}
#WADADetails {
padding-top: 10px;
}
</style>
</head>

<body>


<div class="WADADetailsContainer"> <a name="top"></a>
<div id="WADAPageTitleArea">
<div id="WADAPageTitle">Page Title</div>
</div>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<?php if ($totalRows_WADAtblPhotos > 0) { // Show if recordset not empty ?>
<div id="WADADetails">
<div class="WADAHeader">Details</div>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">photoID:</th>
<td class="WADADataTableCell"><?php echo($row_WADAtblPhotos['photoID']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoTitolo:</th>
<td class="WADADataTableCell"><?php echo($row_WADAtblPhotos['photoTitolo']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoTitle:</th>
<td class="WADADataTableCell"><?php echo($row_WADAtblPhotos['photoTitle']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoDescr:</th>
<td class="WADADataTableCell"><?php echo($row_WADAtblPhotos['photoDescr']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoDesceng:</th>
<td class="WADADataTableCell"><?php echo($row_WADAtblPhotos['photoDesceng']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoLocation:</th>
<td class="WADADataTableCell"><img src="foto/thumb/<?php echo $row_WADAtblPhotos['photoLocation']; ?>" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">photoThum:</th>
<td class="WADADataTableCell"><?php echo($row_WADAtblPhotos['photoThum']); ?></td>
</tr>
<tr>
<th class="WADADataTableHeader">albumID:</th>
<td class="WADADataTableCell"><?php echo($row_WADAtblPhotos['albumID']); ?></td>
</tr>
</table>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<form action="" method="post" name="WADADeleteForm" id="WADADeleteForm">
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="tblPhotos_Update.php?photoID=<?php echo(rawurlencode($row_WADAtblPhotos['photoID'])); ?>" title="Update"><img border="0" name="Update" id="Update" alt="Update" src="WA_DataAssist/images/Pacifica/Refined_update.gif" /></a></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Delete" id="Delete" value="Delete" alt="Delete" src="WA_DataAssist/images/Pacifica/Refined_delete.gif" />
<input type="hidden" name="WADADeleteRecordID" id="WADADeleteRecordID" value="<?php echo($row_WADAtblPhotos['photoID']); ?>" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="tblPhotos_Results.php" title="Results"><img border="0" name="Results" id="Results" alt="Results" src="WA_DataAssist/images/Pacifica/Refined_results.gif" /></a></td>
</tr>
</table>
</div>
</form>
</div>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_WADAtblPhotos == 0) { // Show if recordset empty ?>
<div class="WADANoResults">
<div class="WADANoResultsMessage">No record found.</div>
</div>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<div class="WADADetailsLinkArea">
<div class="WADADataNavButtonCell"><a href="tblPhotos_Results.php" title="Results"><img border="0" name="Results1" id="Results1" alt="Results" src="WA_DataAssist/images/Pacifica/Refined_results.gif" /></a></div>
</div>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<?php } // Show if recordset empty ?>
</div>
</body>
</html>
<?php
mysql_free_result($WADAtblPhotos);
?>


It supposes to show me a 100x100 thumb in the "photo location" field....

Thanks again

Sign in to reply to this post

Jason ByrnesWebAssist

the only file name you are storing in the database is the file name of the large image.

you are not storing the file name of the thumb.


the file name stored in the photoLocation column is the large image. to display the large image, you need to use the large image path:

<img src="foto/<?php echo $row_WADAtblPhotos['photoLocation']; ?>" />


if you wanted to store the thumbnail image name, look in the bindings panel under the WA Uploaded Images binding group. You will see that the bindings are repeated three times, the last 2 times each binding has the upload path listed in front of it, look for the foto/thumb/ Server File name binding this one will have the file name for the thumbnail image.

Sign in to reply to this post

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