Copy link to clipboard
Copied
I have successfully created a Login page that will carry a session variable to the User Update Page. The problem is that the Dynamic Data in the form fields aren't pulling up the record from the MySQL table. Then if I type anything into the fields and try to perform an update just to test it, it goes to a black page with the error message "Incorrect table name."
I would appreciate any help with this. I'm using DW CS4, MySQL & PHP.
Thanks!
Copy link to clipboard
Copied
Here are the basic steps, perhaps you can check these against what you have.
1. Created a recordet based on the User ID session variable - test the recodset in the behavior panel to make sure it's returning data
2. Bind the database fields to the form fields.
3. Apply the update behavior, select the recordset you created n step one and specify a redirect page.
If you've done all these and it's not working, then please post your code and or a link to the page in question.
Copy link to clipboard
Copied
Hi Lon...thanks for your help again. ![]()
Okay, when I first made the Recordset in the "simple" mode, it tested fine. Then after I hit "okay", it had a red exclamation point next to it. Upon clicking it again and hitting the "test" button it gave me the following error: "totalRows is an invalid variable name; it does not appear in the SQL. Missing type for variable:totalRows."
When you stated to "bind the database fields to the form fields," are you talking about inserting the Dynamic Data...the "Init val" with the lightening bolt? If so, I did do that too.
Also, the 3rd thing, "
Apply the update behavior, select the recordset you created n step one and specify a redirect page."
When I apply the update behavior, do I click on the Submit button to select that or the form it is in? When I went to reclick on the behavior,
I didn't see a place to select the recordset. No problem with the "redirect page."
Also when I now click on the update behavior, it gives me the following error: "While executing inspectServerBehavior in UpdateRecord.htm
a JavaScript error occured."
Eeeeyiieh! Thanks for your help. I'm also going to post the code below:
<?php require_once('Connections/sgallery.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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE ``artist id`` SET `First Name`=%s, `Last Name`=%s, Street=%s, City=%s, Zip=%s, email=%s, username=%s, password=%s WHERE `Artist ID`=%s",
GetSQLValueString($_POST['First Name'], "text"),
GetSQLValueString($_POST['Last Name'], "text"),
GetSQLValueString($_POST['Street'], "text"),
GetSQLValueString($_POST['City'], "text"),
GetSQLValueString($_POST['Zip'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['hiddenField'], "int"));
mysql_select_db($database_sgallery, $sgallery);
$Result1 = mysql_query($updateSQL, $sgallery) or die(mysql_error());
}
$colname_Recordset1 = "-1";
if (isset($_POST['Artist ID'])) {
$colname_Recordset1 = $_POST['Artist ID'];
}
mysql_select_db($database_sgallery, $sgallery);
$query_Recordset1 = sprintf("SELECT * FROM `artist id` WHERE `Artist ID` = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $sgallery) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = "-1";
if (isset($_SESSION['Artist ID'])) {
$totalRows_Recordset1 = $_SESSION['Artist ID'];
}
$colname_Recordset1 = "-1";
if (isset()) {
$colname_Recordset1 = ;
}
mysql_select_db($database_sgallery, $sgallery);
$query_Recordset1 = sprintf("SELECT * FROM `artist id` WHERE `Artist ID` = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $sgallery) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);$colname_Recordset1 = "-1";
if (isset($_POST['Artist ID'])) {
$colname_Recordset1 = $_POST['Artist ID'];
}
mysql_select_db($database_sgallery, $sgallery);
$query_Recordset1 = sprintf("SELECT * FROM `artist id` WHERE `Artist ID` = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $sgallery) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$colname_Recordset1 = "-1";
if (isset($_SESSION['Artist ID'])) {
$colname_Recordset1 = $_SESSION['Artist ID'];
}
mysql_select_db($database_sgallery, $sgallery);
$query_Recordset1 = sprintf("SELECT * FROM `artist id` WHERE `Artist ID` = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $sgallery) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
?>
<!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>S Gallery Online</title>
<link href="sgallery.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-image: url(BASICartistform.gif);
background-repeat: no-repeat;
margin-bottom: 1000px;
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
background-color: #000000;
}
-->
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<div class="logo"></div>
<div class="headermenu">
<ul id="MenuBar1" class="MenuBarHorizontal">
<li>
<div align="center"><a href="index.php">Home</a> </div>
</li>
<li>
<div align="center"><a href="onlineartgalleries.php" class="MenuBarItemSubmenu">Galleries</a>
<ul>
<li><a href="paintinggallery.php">Paintings</a> </li>
<li><a href="printmakingartgallery.php">Printmaking</a> </li>
<li><a href="sculptureartgallery.php">Sculpture</a> </li>
<li><a href="pastelartgallery.php">Pastels</a></li>
<li><a href="photographyartgallery.php">Photography</a></li>
<li><a href="mixedmediaartgallery.php">Mixed Media</a></li>
<li><a href="digitalartgallery.php">Drawings</a> </li>
<li><a href="fiberartgallery.php">Fiber Art</a></li>
<li><a href="jewelryartgallery.php">Jewelry</a></li>
<li><a href="digitalartgallery.php">Digital Art</a></li>
</ul>
</div>
</li>
<li>
<div align="center"><a href="joinonlineartgallery1.php">Join</a> </div>
</li>
<li>
<div align="center"><a href="#">Blog</a></div>
</li>
<li>
<div align="center"><a href="about.php">About</a></div>
</li>
<li>
<div align="center"><a href="#">FAQ</a></div>
</li>
<li>
<div align="center"><a href="contactus.php">Contact</a></div>
</li>
<li>
<div align="center"><a href="memberlogin.php">LOGIN</a></div>
</li>
</ul>
</div>
<div class="maincontent">
<div class="quicklinks"><span class="fontquicklinks">Art News</span><br />
<span class="fontquicklinks">Competitions</span><br />
<span class="fontquicklinks">Art Schools</span><br />
<span class="fontquicklinks">Museums</span><br />
<span class="fontquicklinks">Art Resources</span><br />
<span class="fontquicklinks">Exhibitions</span><br />
<span class="fontquicklinks">Paintings</span><br />
<span class="fontquicklinks">Sculpture</span><br />
<span class="fontquicklinks">Photography</span><br />
<span class="fontquicklinks">Pastels</span><br />
<span class="fontquicklinks">Mixed Media</span><br />
<span class="fontquicklinks">Printmaking</span><br />
<span class="fontquicklinks">Drawings</span><br />
<span class="fontquicklinks">Fiber Art</span><br />
<span class="fontquicklinks">Jewelry</span><br />
<span class="fontquicklinks">Digital Art</span><br />
<span class="fontquicklinks">Submit an Event</span><br />
</div>
<div class="imageupload">Information Update/Edit:<br />
<br />
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
<label>
<input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_Recordset1['Artist ID']; ?>" />
<br />
First Name:
<input name="First Name" type="text" id="First Name" value="<?php echo $row_Recordset1['First Name']; ?>" />
</label>
<br />
<label>Last Name:
<input name="Last Name" type="text" id="Last Name" value="<?php echo $row_Recordset1['Last Name']; ?>" />
</label>
<br />
<label>Street:
<input name="Street" type="text" id="Street" value="<?php echo $row_Recordset1['Street']; ?>" />
</label>
<br />
<label>City:
<input name="City" type="text" id="City" value="<?php echo $row_Recordset1['City']; ?>" />
</label>
<br />
<label>Zip:
<input name="Zip" type="text" id="Zip" value="<?php echo $row_Recordset1['Zip']; ?>" />
</label>
<br />
<label>Email:
<input name="email" type="text" id="email" value="<?php echo $row_Recordset1['email']; ?>" />
</label>
<br />
<label>Username:
<input name="username" type="text" id="username" value="<?php echo $row_Recordset1['username']; ?>" />
</label>
<br />
<label>Password:
<input name="password" type="password" id="password" value="<?php echo $row_Recordset1['password']; ?>" />
</label>
<br />
<label>Update
<input type="submit" name="update" id="update" value="Submit" />
</label>
<br />
<br />
<input type="hidden" name="MM_update" value="form1" />
</form>
<p> </p>
<p> </p>
<p> </p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</div>
<div class="adssidebar"></div>
</div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
}
Copy link to clipboard
Copied
To assure the data displayed based on respective users, create a recordset from the table by filter it using username -> Session Variable -> MM_Username. To view the data in form before update, click the textbox, you may see Dynamic button at properties panel. Click it and choose the recordset that u have just created and choose the data that u want to display.
Copy link to clipboard
Copied
Hi, you may want to reduce the fint size in your posts, it seems that part got caught with the code view and the scroll bar is way down, so I don't know if I caught the whole message!
Anyway, first thing, if you're getting javascript errors, you need to delete the wincache file for dreamwever (there's a similar file for Mac if that's what you're on). Do a search here or Adobe.com for "Dreamweaver Javascript Errors", it will tell you exactly where to find that file.
Next, if you're getting the exclamation point next to the recordset, just try to re-open the dialog and re-save it to see if the warning goes away. If it does, you still want to check your code for duplcate pieces of code - most common you would see two lines to the include file for the database connection, or the code at the end of the page to close the recordset. If that's the case, delete any duplications. If the warning persists, just delete the recordset and start over, again watch for code duplication.
Sounds like you have the bindings correct - you can also just drag the database field in the Bindings panel to the text field on your page. Other form elements such as list menus, you have to use the lightning bolt.
For the update behavior, you don't need to select anything on the page first. Just choose the behavior from the servier behaviors panel and fill in the required spaces. One of those will be "Select Record From" which should display the name of the recordset you created.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now