My first SQL/PHP project. Code is

2 <?php
3 $varState_spaResults = "NSW";
4 if (isset(State)) {
5 $varState_spaResults = (get_magic_quotes_gpc()) ? State : addslashes(State);
6 }

This code was generated by DreamWeaver MX after writing the SQL code in a Recordset Dialog Box. A test of the SQL code worked while still in the dialog box but once converted to PHP (?if thats how it works?) by DW-MX it's returning the parse error.

In way over my head.... any help tremendously appreciated.

    For starters you are missing the $ in front of State.

    Did you type this or paste it in?

      I'm doing this in Dreamweaver so the actual code was generated automatically after if created a Recordset with my SQL code in it.

      Where should the $ be ???

      thanks for your time....

      christL

        The $ should appear directly in front of the State variable with no spaces in between them

          But unless Dream Weaver is really screwed up then the problem is elsewhere. There is no reason why automatically generated code would have such a glaring errors in it. And you really don't want to edit all this stuff by hand.

            Okay, I've added the $ infront of the State variable and have received the new error:

            Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/spasearc/public_html/results.php on line 56.

            Line 56 in BOLD below

            <?php do { ?>
            <tr bordercolor="#3366CC" class="bodyHeader">
            <td><?php echo $row_spaResults['Spa Name']; ?></td>
            <td><?php echo $row_spaResults['Spa Type']; ?></td>
            <td><?php echo $row_spaResults['City or Town']; ?></td>
            <td><?php echo $row_spaResults['State']; ?></td>
            <td><?php echo $row_spaResults['Country']; ?></td>
            </tr>
            <?php } while ($row_spaResults = mysql_fetch_assoc($spaResults)); ?>

            thanks heaps,

            christL

              Now that is seriously grotty code. If you're trying to fasttrack your understanding of PHP by using Dreamweaver, stop it; it will seriously slow you down for two reasons: (1) you can't learn a language if you don't write anything in it, and (2) Dreamweaver generates some of the stupidest code I've ever seen. (And apparently it doesn't even work.)

              You've put $ in front of all three occurrences of State in that first generated code I assume.

                To be honest - I guess I'm really just trying to fast track this job as it comes screaming towards deadline. :eek:

                But I'm up for learning what I need to get this working.

                I've redone the php elements on my results page and am not getting errors any more, but am not getting an records in my result either. I'm reveiwing my whole Database at the moment.

                Thanks for your help so far. I get the feeling I've ggot quite a way to go.......

                Cheers,

                christL

                  Okay I've got the search page & result page running without any errors coming up, but the Problem is that no records are being retrieved into my results page table.

                  The search form has the 'State' text field with the value 'NSW', but when the submit button is pressed and the results page loads there are no (as in ZERO) records being displayed.

                  WHY ???

                  Here's the whole PHP code from the top followed by the Table's code:

                  <?php require_once('Connections/Spa.php'); ?>
                  <?php
                  $startRow_SpaResults = $pageNum_SpaResults $maxRows_SpaResults;
                  $maxRows_SpaResults = 10;;
                  $pageNum_SpaResults = 0;
                  if (isset($HTTP_GET_VARS['pageNum_SpaResults'])) {
                  $pageNum_SpaResults = $HTTP_GET_VARS['pageNum_SpaResults'];
                  }
                  $startRow_SpaResults = $pageNum_SpaResults
                  $maxRows_SpaResults;

                  $varState_SpaResults = "NSW";
                  if (isset($State)) {
                  $varState_SpaResults = (get_magic_quotes_gpc()) ? $State : addslashes($State);
                  }
                  mysql_select_db($database_Spa, $Spa);
                  $query_SpaResults = sprintf("SELECT spa.Spa Name, spa.Spa Type, spa.Spa of Distinction, spa.City or Town, spa.State FROM spa WHERE spa.State LIKE '%s%%' ORDER BY spa.State", $varState_SpaResults);
                  $query_limit_SpaResults = sprintf("%s LIMIT %d, %d", $query_SpaResults, $startRow_SpaResults, $maxRows_SpaResults);
                  $SpaResults = mysql_query($query_limit_SpaResults, $Spa) or die(mysql_error());
                  $row_SpaResults = mysql_fetch_assoc($SpaResults);

                  if (isset($HTTP_GET_VARS['totalRows_SpaResults'])) {
                  $totalRows_SpaResults = $HTTP_GET_VARS['totalRows_SpaResults'];
                  } else {
                  $all_SpaResults = mysql_query($query_SpaResults);
                  $totalRows_SpaResults = mysql_num_rows($all_SpaResults);
                  }
                  $totalPages_SpaResults = ceil($totalRows_SpaResults/$maxRows_SpaResults)-1;
                  ?>

                  TABLE

                  <?php do { ?>
                  <tr bordercolor="#3366CC" class="bodyHeader">
                  <td><?php echo $row_SpaResults['Spa Name']; ?></td>
                  <td><?php echo $row_SpaResults['Spa Type']; ?></td>
                  <td><?php echo $row_SpaResults['City or Town']; ?></td>
                  <td><?php echo $row_SpaResults['State']; ?></td>
                  </tr>
                  <?php } while ($row_SpaResults = mysql_fetch_assoc($SpaResults)); ?>

                  Any ideas ????

                  thanks,

                  christL

                    What a fumbling mess BUT IT WORKS !!!!

                    Thanks for all your help in this first adventure into the world of PHP. I know to cross-reference DW-MX's code as I go along now.... there really are no shortcuts are there:rolleyes:

                    Big thanks to the PHP Builder Community at large for even being here in the first place.

                    Cheers,

                    christL

                      Write a Reply...