23 Replies Latest reply: Jun 5, 2012 9:33 AM by Norv52 RSS

    Problem building record set using Dreamweaver CS6 Cloud Product

    Norv52 Community Member

      I am having a problem building a Results Page using Dreamweaver CS6.  I have followed all the steps described in Dreamweaver/Build Search and Results Page Article (multiple times).  It seems that when I save the Results page it does not copy the php used to build the dynamic table.  In fact when I view the source, I do not see any php code. 

       

      Additionally, when I attempt to bind the record set, it also does not accept the Default Value(s).  Enstead it gives me a list of all data in the colum(s) chosen for the record set (using Where..LIKE..variable definition).

       

      Any suggestions?

       

      Regards,

       

      Norv

        • 1. Re: Problem building record set using Dreamweaver CS6 Cloud Product
          Arpit Kapoor Employee Hosts

          Moving the discussion to Dreamveaver Forum.

          • 2. Re: Problem building record set using Dreamweaver CS6 Cloud Product
            MurraySummers CommunityMVP

            We would need to see the code on the page, and know how you have applied recordset server behavior to the page.  Can you help with that?

            • 3. Re: Problem building record set using Dreamweaver CS6 Cloud Product
              Norv52 Community Member

              Yes, I will be glad to go through each step.  I will also provide code.

               

              Step 1:  Built the Search Page by adding Form into exisitng htm page.  Used Insert> Form>Form to insert Form area.  Then added three (3) text fields using Text Icon from the Form Menu Bar (Classic View).

               

              Step 2: Added a Submit and Reset Button to the Search Page.  Again used the Form Menu Bar to create the Buttons.

               

              Step 3: Selecte the <form> tag at bottom of Document Window to point Form to the Results Page (using the Action Box.

               

              Saved page and then began building the Results Page using an existing htm page.  Saved the Results Page as a .php document.

               

              Results Page:  Here are steps taken to build Results Page (Code will follow):

               

              1/ On the Results Page created a Recordset using the bindings dialog box.  Used the Advanced Recordset Dialog Box.  In the Advanced Dialog Box I used the Select and Where features to create a Recordset that created a 3 column table (records.County, records.ListPrice, records.PropertyType).  In the Variable box I created 3 variables (varCounty, varListPrice, varPropertyType).  varCounty and varPropertyType parameters are text (Type) and % (for Default Value).  varListPrice parameters are floating point (type) and % (for Default Value).  RunTime Value is $_REQUEST["ColumnName"].

               

              Here is the Code generated by Dreamweaver.  Note, I am not including the code to access the database, because in all tests I am able to access the table.  In fact first time I built the dynamic table, everything worked and I saw the Colum and default value.  Have never been able to duplicate that effort.  :-)

               

              Here is code:

               

              <?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;

               

              }

               

              }

              $varCounty_rslistings = "%";

               

              if (isset($_GET["County"])) {

               

              $varCounty_rslistings = $_Get["County"];

               

              }

               

              $varListPrice_rslistings = "%";

               

              if (isset($_GET["ListPrice"])) {

               

              $varListPrice_rslistings = $_GET["ListPrice"];

               

              }

               

              $varPropertyType_rslistings = "%";

               

              if (isset($_GET["PropertyType"])); {

               

              $varPropertyType_rslistings = $_GET["PropertyType"];

               

              }

               

              mysql_select_db($database_MyDB, $MyDB);

               

              $query_reslistings = sprintf("SELECT records.County, records.ListPrice, records.PropertyType FROM records WHERE records.County LIKE %s AND records.ListPrice LIKE %s AND records.PropertyType LIKE %s", GetSQLValueString($varCounty_rslistings, "text"),GetSQLValueString($varListPrice_rslistings,"double"),

              GetSQLValueString($varPropertyType_rslistings,"text"));

               

              $rslistings = mysql_query($query_rslistings, $MyDB) or die(mysql_error());

               

              $row_rslistings = mysql_fetch_assoc($rslistings);

               

              $totalRows_rslistings = mysql_num_rows($rslistings);

               

              ?>

               

              That's the code that was generated by Dreamweaver. 

               

              Thanks in advance for your assistance

              • 4. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                MurraySummers CommunityMVP

                > In fact when I view the source, I do not see any php code.

                 

                When you say this, do you mean that you preview the page, and then use VIEW > Source from your browser?  If so, then that's normal.  You would never see any PHP (or ASP, or CF, or ASPX, or whatever) code with a view source like that.  All server-side code is parsed out of the page by the server before the page is uploaded to the client browser.

                 

                The code that you show here (and the process that you describe) looks completely adequate to add a selected recordset matching your search criteria to the results page.  How are you then displaying that recordset on the Results page?  In other words, I would need to see the code below the <body> tag.  The point is that it's not enough to bind the recordset to the page.  You have to also bind fields from that recordset to the visual elements of the page, and when combined with a repeat region to step through the recordset, you will get a display of all of the records.

                • 5. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                  Norv52 Community Member

                  Binding the dynamic table is not my problem.  I can bind the dynamic table to the page.   My problem is this: the Recordset Dialog box is not accepting "%" as the Default Value. Again, here are the steps I take to build my Recordset (and I will stop at the step where I am having problems).

                   

                  1/ Using the Advanced Recordset Dialog box,  I Select the 3 columns I have described above.  I use the "Select" button to place the columns in the SQL section of the dialog box.

                   

                  2/ Using the "Where" button, I then begin to build the variables described earlier (varCounty, varPriceList, varPropertyType).  After building the variables I click the "Test" button to see a preview of the Recordset.  Because I am using the "%" wildcard for the Default Value, I should be seeing the individual colum that I am testing and the wildcard Default Value.  Instead, I see all 3 columns and their data.

                   

                  The first time I built a Recordset using this same process, I was able to see (and test) each Column individually and they displayed the wildcard Default Value. 

                  • 6. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                    MurraySummers CommunityMVP

                    Can you show us the SQL string that is built using this process?  Also, what are the run-time values that you are using for these three variables?

                    • 7. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                      Norv52 Community Member

                      Not sure if I understand your question, because the SQL string that is built is exactly as stated above (see the $query_rslistings = sprintf...., above). 

                       

                      In the Dialog box, I create the following:

                       

                      SELECT records.County, records.PriceList, records.PropertyType

                      FROM records

                      WHERE records.County LIKE varCounty

                      AND records.Pricelist LIKE varPriceList

                      AND records.PropertyType LIKE varPropertyType

                       

                       

                      The run-time values that I am using are: $_GET["County"], $_GET["PriceList"] and $_GET["PropertyType"].

                       

                      I am going to check one other thing; whether I am trying to insert into Code View or Design View (I use Split Screen mode). 

                       

                      Again, thanks for all the assistance. 

                      • 8. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                        Norv52 Community Member

                        The only other php code generated by Dreamweaver in this entire process (that is not described above) are:

                         

                        1/ The php script that grants access to the database and table (records); and

                         

                        2/ the "php do" script that searches the recordset (rslistings). 

                         

                        Again, the recordset was correctly built once; but was limited to the first 2 columns.  I deleted those Search and Results page.  I have not been able to duplicate the process since.

                        • 9. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                          Norv52 Community Member

                          Now have a better understanding for your request.  Hence, I built a very simple Results page, using blank dynamic (php html 4.01 Transistional) page.  Code generated to build the SQL Query String is exactly as described earlier, with one exception: the run-time values are $_REQUEST["County"], $_REQUEST["ListPrice"] and $_REQUEST["PropertyType"]

                           

                          Here is the code generated between the  Body Tags:

                           

                          <body>

                          <table border ="1">

                           

                               <tr>

                                    <td>County</td>

                                    <td>ListPrice</td>

                                    <td>PropertyType</td>

                               </tr>

                           

                               <?php do { ?>

                           

                               <tr>

                                    <td><?php echo $row_rslistings['County']; ?></td>

                                    <td><?php echo $row_rslistings['List Price']; ?></td>

                                    <td><? php echo $row_rslistings['PropertyType']; ?></td>

                               </tr>

                           

                               <?php } while ($row_rslistings = mysql_fetch_assoc($rslistings)); ?>

                           

                          Again, obtained same results (builds a dynamic table, but will not display search data).  Additionally, I tested each entry into the Recordset/SQL entry box and still got full listing of the entire Recordset rather than list of Default Values (%). 

                           

                          </table>

                           

                          Again, thanks for your help in this matter. 

                          • 10. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                            MurraySummers CommunityMVP

                            In your code, change this -

                             

                            $totalRows_rslistings = mysql_num_rows($rslistings);

                             

                            ?>

                             

                            To this -

                             

                            $totalRows_rslistings = mysql_num_rows($rslistings);

                             

                            do {

                              $listings[] = $row_rslistings;

                            } while ($row_rslistings=mysql_fetch_assoc($rslistings));

                             

                            echo "<pre>";exit(print_r($listings));

                             

                            ?>

                             

                            Then browse to the page and show us what you get, please.

                            • 11. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                              Norv52 Community Member

                              I get the following error message:

                               

                              Notice: Undefined variable: Listings in C:\Program Files|EasyPHP-5.3.9\www\previeww\Listing Assets\Listing_results.php on line 55

                               

                              1

                               

                              Please note that line 55 is the line of code wiht  "<pre>".  "<pre>" is highlighted in red (similar color as my php syntax).

                               

                               

                              Again, thanks for your help. 

                              • 12. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                tunghia4 Community Member

                                I have problems same you in creat at (link removed by moderator) for code

                                • 13. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                  osgood_ CommunityMVP

                                  There is a space between ['List Price'] where you're asking for  $_REQUEST["ListPrice"] (without space)

                                   

                                   

                                  <td><?php echo $row_rslistings['County']; ?></td>

                                            <td><?php echo $row_rslistings['List Price']; ?></td>

                                            <td><? php echo $row_rslistings['PropertyType']; ?></td>

                                   

                                   

                                  Check and see if that has something to do with your issue. It may be nothing and an error caused by the forum or NOT associated at all.

                                  • 14. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                    Norv52 Community Member

                                    Space between ListPrice is a typo in this document.  Reads as follows in the Code:

                                     

                                     

                                    <td><?php echo $row_rslistings['ListPrice']; ?></td>

                                    • 15. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                      MurraySummers CommunityMVP

                                      Make sure that this line is correct, please -

                                       

                                      $listings[] = $row_rslistings;

                                       

                                      That's an empty pair of square brackets after "$listings", i.e., $listings [ ] (I put a space between them - don't do that in your final code)

                                       

                                      Now what do you get?

                                      • 16. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                        Norv52 Community Member

                                        I did not put empty space between brackets (smile).  Rechecked code and found another typo.

                                         

                                        I now get the following :

                                         

                                        Arrary

                                        (

                                        [0] =>

                                        )

                                        1

                                        • 17. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                          MurraySummers CommunityMVP

                                          OK - this means that your SQL statement is returning NO results.  The problem is in the SQL not in the display.

                                           

                                          Now change this -

                                           

                                          $rslistings = mysql_query($query_rslistings, $MyDB) or die(mysql_error());

                                           

                                          to this -

                                           

                                          exit ($query_rslistings);

                                          $rslistings = mysql_query($query_rslistings, $MyDB) or die(mysql_error());

                                           

                                          browse to the page, and copy what you get in a reply here

                                          • 18. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                            Norv52 Community Member

                                            Returns the following:

                                             

                                            SELECT records.County, records.ListPrice, records.PropertyType

                                            FROM records

                                            WHERE records.County LIKE '%'

                                            AND records.ListPrice LIKE 0

                                            AND records.PropertyType LIKE '%'

                                             

                                            That is nice! Getting closer!!! 

                                            • 19. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                              MurraySummers CommunityMVP

                                              I have only seen LIKE used with strings, so I don't know what your "LIKE 0" is going to return.  Could that be part of your problem?

                                              • 20. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                                Norv52 Community Member

                                                I am a novice regarding both php and MySQL.  This has rapidly moved beyound my knowledge of both.  I am now aware that I must revise the ListPrice variable.  

                                                 

                                                I was lead to believe that I could build the recordset and queries using just the Dreamweaving Bindings and Server Behaviors features.  Will now be learning a little bit more about SQL.

                                                • 21. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                                  MurraySummers CommunityMVP

                                                  > Will now be learning a little bit more about SQL.

                                                   

                                                  This is always the right approach.

                                                  • 22. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                                    Norv52 Community Member

                                                    I have begun a review of the table itself and may have stumbled upon the problem.  The Table (records) has ListPrice defined as VARCHAR.  The reason is that the Prices include the dollar sign ($).  Therefore, when I am defining the variable 'varPriceList' I actually want to GET/POST the string value; not a Floating Point Value, correct?

                                                    • 23. Re: Problem building record set using Dreamweaver CS6 Cloud Product
                                                      Norv52 Community Member

                                                      Finally success!!!!

                                                       

                                                      Folllowed advice given and delved more deeply into MySQL (and php).  As result of reading several Community Forum threads, and crash course into both MySQL and php, solved the problem.  Actually Dreamweaver wrote majority of the Code. 

                                                       

                                                      Steps taken were as follows:

                                                       

                                                      1/ Built Simple Recordset.  This to obtain the sanitizing code.

                                                       

                                                      2/ Used Simple Recordset to build one (1) "filtered" query.  Ran test and everything worked.

                                                       

                                                      3/ Added additional queries (wrote code) only after reviewing syntax information obtained from W3Schools.com and this Community. 

                                                       

                                                      Again, thanks for all the help.  Now on to more MySQL and php challenges!!