trouble retrieving data from mysql db. Help pls

Ask a Question related to Dreamweaver AppDev, Design and Development.

  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. Similar Questions and Discussions

    1. Retrieving individual data
      Hi am trying to retrieve indivual data from a database and i keep getting the following error. Microsoft VBScript compilation (0x800A0401)...
    2. retrieving data from website
      hi there all, me again... is it possible if you know the layout of a web site, to retrieve data from it? i mean things like a weather site that...
    3. Trouble with retrieving session variables
      Hi Guys, I am using sessions to store the login name and then retrieve it on every page. Here are the details of the php settings. 1) I have...
    4. PHP problem retrieving data
      I'm not sure why this isn't working, but it's giving me no output. I have a form which requests email and city to pull up a listing, then Email that...
    5. [PHP-DEV] MySQL Problem retrieving errno, when connect fails + solution
      Hi, There is a problem in the MySQL extension when trying to get the errno, if the connection failed, if a prior mysql_connect() call already...
  3. #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

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

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

Posting Permissions

  • You may not post new threads
  • You may 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