Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Tw|chie #1
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
-
Retrieving individual data
Hi am trying to retrieve indivual data from a database and i keep getting the following error. Microsoft VBScript compilation (0x800A0401)... -
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... -
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... -
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... -
[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... -
Tw|chie #2
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
-
David Powers #3
Re: trouble retrieving data from mysql db. Help pls
Tw|chie wrote:
The column for product_type is probably CHAR or VARCHAR, which requires> 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:
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
-
Tw|chie #4
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



Reply With Quote

