close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Weird SQL duplication on Recordset update

Thread began 7/12/2011 10:40 am by Jared Lui | Last modified 7/12/2011 3:56 pm by Jared Lui | 678 views | 2 replies |

Jared Lui

Weird SQL duplication on Recordset update

First question: is the results page supposed to have 2 mysql_select statements?

Why I ask is at some point I went in and updated the recordset via double clicking it in the server behaviors panel. Then at some point later needed to tweak the recordset again. I'd make the changes in advanced view. test and click OK to save and leave the recordset editor.

I'd upload the page and test it and see nothing changed. I'd go back into my code and see the save never took effect. I'd go into the recordset and see it was the same prior to my edits. I'd edit again, test and click OK to save. Then looked at the code and not see it changed. But then noticed a second mysql_select statement directly below the first one. I thought maybe it was for another task but compared the two and they are exact character for character.

I deleted one and went into the recordset editor again to edit it, tested, clicked OK and checked the code again. The duplicate select statement is back. I can hand code the select statement and the changes show in the recordset fine.

Anyway, this has happened 2 other times but only seems to be on the results page when I am doing advanced selects. Pretty sure it's a CS4 issues and not DA related am even more probable it's something I'm doing. Just checking to see if anyone else has experienced this.

Sign in to reply to this post

Jared Lui

It just happened again this time on a pretty simple select and on the search page. Here's an example: (i bolded the duplicate to see it better). Again, I don't believe this is an DA issue but am curious if anyone else has had this happen? Thanks.

<?php
$maxRows_WADADynListfigure_lines = 1000;
$pageNum_WADADynListfigure_lines = 0;
if (isset($_GET['pageNum_WADADynListfigure_lines'])) {
$pageNum_WADADynListfigure_lines = $_GET['pageNum_WADADynListfigure_lines'];
}
$startRow_WADADynListfigure_lines = $pageNum_WADADynListfigure_lines * $maxRows_WADADynListfigure_lines;

mysql_select_db($database_FIGURES, $FIGURES);
$query_WADADynListfigure_lines = "SELECT Line_Name, Line_Name FROM figure_lines ORDER BY Line_Name";
$query_limit_WADADynListfigure_lines = sprintf("%s LIMIT %d, %d", $query_WADADynListfigure_lines, $startRow_WADADynListfigure_lines, $maxRows_WADADynListfigure_lines);
$WADADynListfigure_lines = mysql_query($query_limit_WADADynListfigure_lines, $FIGURES) or die(mysql_error());
$row_WADADynListfigure_lines = mysql_fetch_assoc($WADADynListfigure_lines);

if (isset($_GET['totalRows_WADADynListfigure_lines'])) {
$totalRows_WADADynListfigure_lines = $_GET['totalRows_WADADynListfigure_lines'];
} else {
$all_WADADynListfigure_lines = mysql_query($query_WADADynListfigure_lines);
$totalRows_WADADynListfigure_lines = mysql_num_rows($all_WADADynListfigure_lines);
}
$totalPages_WADADynListfigure_lines = ceil($totalRows_WADADynListfigure_lines/$maxRows_WADADynListfigure_lines)-1;
$maxRows_WADADynListfigure_lines = 1000;
$pageNum_WADADynListfigure_lines = 0;
if (isset($_GET['pageNum_WADADynListfigure_lines'])) {
$pageNum_WADADynListfigure_lines = $_GET['pageNum_WADADynListfigure_lines'];
}
$startRow_WADADynListfigure_lines = $pageNum_WADADynListfigure_lines * $maxRows_WADADynListfigure_lines;

mysql_select_db($database_FIGURES, $FIGURES);
$query_WADADynListfigure_lines = "SELECT Line_Id, Line_Name FROM figure_lines ORDER BY Line_Name";
$query_limit_WADADynListfigure_lines = sprintf("%s LIMIT %d, %d", $query_WADADynListfigure_lines, $startRow_WADADynListfigure_lines, $maxRows_WADADynListfigure_lines);
$WADADynListfigure_lines = mysql_query($query_limit_WADADynListfigure_lines, $FIGURES) or die(mysql_error());
$row_WADADynListfigure_lines = mysql_fetch_assoc($WADADynListfigure_lines);

if (isset($_GET['totalRows_WADADynListfigure_lines'])) {
$totalRows_WADADynListfigure_lines = $_GET['totalRows_WADADynListfigure_lines'];
} else {
$all_WADADynListfigure_lines = mysql_query($query_WADADynListfigure_lines);
$totalRows_WADADynListfigure_lines = mysql_num_rows($all_WADADynListfigure_lines);
}
$totalPages_WADADynListfigure_lines = ceil($totalRows_WADADynListfigure_lines/$maxRows_WADADynListfigure_lines)-1;
?>

Sign in to reply to this post

Jared Lui

Jason explained how this is happening and why.

This is caused by a conflict in my column naming convention and how DW and DA deal with naming parameters. This could be explained better I am sure but that is the gist of it.

Because I use an underscore in my column names DW was giving me errors trying to save recordsets when DA would create parameters which conflict with my column names.

In short, if you get an error when using the Test button in the recordset that says:
ParamX is an invalid variable name; it does not appear in the SQL
Missing type for variable:ParamX
NOTE: where "X" is the column name

Chances are that you have underscores in your column names. This also can cause duplicate select statements to be created. Best practice is to use camelCase for file names (thanks Jason). But to fix this in your code just remove the underscore in the parameter like the example below where Figure_Id is my column name. DA created a parameter called: $ParamFigure_Id_WADAfigures and apparently the first underscore is the problem. So just remove all instances of the first underscore so it looks like this: $ParamFigureId_WADAfigures.

The code below was where the problem is. I removed the first underscore in all three places and it corrected my issue.

<?php
$ParamFigure_Id_WADAfigures = "-1";
if (isset($_GET['Figure_Id'])) {
$ParamFigure_Id_WADAfigures = (get_magic_quotes_gpc()) ? $_GET['Figure_Id'] : addslashes($_GET['Figure_Id']);
}
mysql_select_db($database_FIGURES, $FIGURES);
$query_WADAfigures = sprintf("SELECT Figure_Id, Figure_Name, Date_Stamp, Size, Figure_Added, Series_Id, Line_Id, Figure_Approve, Figure_Locked, Figure_Text, Figure_Text_Added, Figure_Text_Approved FROM figures WHERE Figure_Id = %s", GetSQLValueString($ParamFigure_Id_WADAfigures, "int"));
$WADAfigures = mysql_query($query_WADAfigures, $FIGURES) or die(mysql_error());
$row_WADAfigures = mysql_fetch_assoc($WADAfigures);
$totalRows_WADAfigures = mysql_num_rows($WADAfigures);?>

Hope this helps someone.
Cheers!

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