Professional Web Applications Themes

trouble retrieving data from mysql db. Help pls - Dreamweaver AppDev

Hi all, Hope fully someone can help me out, because I have spent the last 4 hours hammering google without any success. I am working in dreamweaver mx on a win2k machine attempting to develop a product catalogue utilizing php and mysql. I want my audience to be able to select from 4 options on the catalogue page: pumps, nozzles, underwater lights and accessories. Depending on the option they select I would like a query to be sent to the server and display the associated records in a table. This is what I have done so far: I have created ...

  1. #1

    Default trouble retrieving data from mysql db. Help pls

    Hi all,

    Hope fully someone can help me out, because I have spent the last 4 hours
    hammering google without any success. I am working in dreamweaver mx on a
    win2k machine attempting to develop a product catalogue utilizing php and
    mysql. I want my audience to be able to select from 4 options on the catalogue
    page: pumps, nozzles, underwater lights and accessories. Depending on the
    option they select I would like a query to be sent to the server and display
    the associated records in a table.

    This is what I have done so far:

    I have created a products table in my mysql database using myphpadmin provided
    by my webhost with the following fields:

    ? ProductID [Primary Key]
    ? ProductModel
    ? ProductType
    ? ProductAttributes
    ? ProductPrice
    ? ProductPicture

    I then created a page for each previously mentioned category and then created
    an individual record set for each aswell. I created a table on each page and
    inserted dynamic text for ProductModel, ProductType and ProductAttributes.

    I created all record sets to use the ProductType as the URL parameter, E.G on
    the nozzles page: SELECT * FROM products WHERE ProductType = "Nozzles";

    When I hit the test button in dreamweaver I get prompted for the parameter and
    the correct data gets selected. When I upload it to my site and or try the
    dynamic data view I just get a blank table.

    After its done this I've looked in the code window and my php block is as
    follows:

    <?php require_once('Connections/connMasterTrade.php'); ?>
    <?php
    $colname_Recordset1 = "1";
    if (isset($_GET['%Nozzles%'])) {
    $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['%Nozzles%'] :
    addslashes($_GET['%Nozzles%']);
    }
    mysql_select_db($database_connMasterTrade, $connMasterTrade);
    $query_Recordset1 = sprintf("SELECT * FROM products WHERE ProductType = '%s'",
    $colname_Recordset1);
    $Recordset1 = mysql_query($query_Recordset1, $connMasterTrade) or
    die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>

    The select statement is totally different to the one I put in?

    I suspect I am not querying the database properly in the first place, or
    perhaps I should be using multiple record sets on a single page or need more
    tables in my database. IN anycase I am totally lost and would appreciate some
    help from your goodselves.

    Many thanks in advance.

    Richard





    Tw|chie Guest

  2. #2

    Default Re: trouble retrieving data from mysql db. Help pls

    ok..i've managed to connect to my MySQL database and retrieve the products
    records. I simple amended the hyperlinks on each of the pages to pass a
    variable called $query over to the corresponding pages and all records are
    displayed in all cases. :))

    Using statement: "SELECT * FROM products"

    When I try and change the statement to filter out certain data, say just
    nozzles.php : "SELECT * FROM products WHERE product_type=nozzles", it comes
    back with an error:

    "Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result
    resource in /home/www/rbedenham.supremeserver18.com/nozzles.php on line 10"

    What I don't understand is why did it work with this function in the first
    place, but not when I changed the query? Is my SQL statement correct? But if it
    were a problem with the statement would the error not point to that line
    instead? Any suggestions?

    Many Thanks in advance
    Richard

    Found some good tutorials on php [url]http://www.tutorialized.com/tutorials/PHP/1[/url]
    if anyone is interested.

    Tw|chie Guest

  3. #3

    Default Re: trouble retrieving data from mysql db. Help pls

    Tw|chie wrote:
    > When I try and change the statement to filter out certain data, say just
    > nozzles.php : "SELECT * FROM products WHERE product_type=nozzles", it comes
    > back with an error:
    The column for product_type is probably CHAR or VARCHAR, which requires
    a string, so you must put the value in quotes:

    "SELECT * FROM products WHERE product_type='nozzles'"

    --
    David Powers
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    Co-author "PHP Web Development with DW MX 2004" (Apress)
    [url]http://computerbookshelf.com[/url]
    David Powers Guest

  4. #4

    Default Re: trouble retrieving data from mysql db. Help pls

    not too worry I managed to sort it.. I tried a different SQL statement:
    "SELECT * FROM products WHERE product_type LIKE '%nozzles%'"
    and it works on each of my pages.
    Thanks anyways.



    Tw|chie Guest

Similar Threads

  1. retrieving data from website
    By max in forum ASP.NET Web Services
    Replies: 2
    Last Post: February 25th, 10:36 PM
  2. Trouble with retrieving session variables
    By Avinash Korwarkar in forum PHP Development
    Replies: 1
    Last Post: October 6th, 06:14 AM
  3. PHP problem retrieving data
    By Wm in forum PHP Development
    Replies: 5
    Last Post: August 11th, 01:18 PM
  4. [PHP-DEV] MySQL Problem retrieving errno, when connect fails + solution
    By Michael Bretterklieber in forum PHP Development
    Replies: 0
    Last Post: August 6th, 09:53 AM
  5. Forms and retrieving data
    By rozdias webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 23rd, 12:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139