SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jan 12, 2005, 12:52 #1
- Join Date
- Jan 2005
- Location
- Massachusetts
- Posts
- 10
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I have a blank page after passing data to PHP page connected to database
Help! This is my first PHP/MySQL site. I am not a programmer but strictly a designer with lots of Dreamweaver experience. I've gone thru some Dreamweaver MX tutorials on building dynamic sites, but that is all.
I have succesfully made a connection to my database, which consists of a table of lighting products which are to be browsed via PHP. My table fields are ProductID, SKU, ProductName, DescriptiveText, Price, RoomID and Type among other detials such as material, dimension, weight etc.
My first page calls for the user to browse by Room, and contains the following code (simplified):
<p><a href="test2_browse.php?RoomID=102">living</a></p>
<p><a href="test2_browse.php?RoomID=104">dining</a></p>
test2_browse.php then contains the following to filter and display the query results based on the $_GET selection:
<?php
$colname_rs_products = "1";
if (isset($_GET['RoomID'])) {
$colname_rs_products = (get_magic_quotes_gpc()) ? $_GET['RoomID'] : addslashes($_GET['RoomID']);
}
mysql_select_db($database_lighting, $lighting);
$query_rs_products = sprintf("SELECT * FROM products WHERE RoomID = %s", $colname_rs_products);
$rs_products = mysql_query($query_rs_products, $lighting) or die(mysql_error());
$row_rs_products = mysql_fetch_assoc($rs_products);
$totalRows_rs_products = mysql_num_rows($rs_products);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body>
<p>Room <?php echo $_GET['RoomID']; ?></p>
<p><?php echo $row_rs_products['ProductName']; ?></p>
<p> <?php echo $row_rs_products['DescriptiveText']; ?></p>
</body>
</html>
<?php
mysql_free_result($rs_products);
?>
I followed the example in the DW tutorial exactly, and all of this code was generated using the DW built-in support for PHP/MySQL.
BUT all I get is a blank page after I save, upload and test the pages. NO error message or anything. What is going on????
When I create the query in the DW Bindings panel and test it, it shows the data just fine. I just can't seem to get anything to display!
Can anyone help???
-
Jan 12, 2005, 17:39 #2
- Join Date
- Mar 2003
- Location
- Melbourne, Australia
- Posts
- 463
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you might be better asking in the php forum
http://www.sitepoint.com/forums/forumdisplay.php?f=34
a few things you can try to test your result is to
put print in front of strings, to see if they say what they are meant to
but that's beyond the scope of this reply
-
Jan 13, 2005, 07:41 #3
This is typical of DW, I don't know why they have broken code but they do:
Code://Default record to be fetched has the ID of one $colname_rs_products = "1"; //If we get an ID through the GET (but what about POST?) if (isset($_GET['RoomID'])) { //The value of the variale is either already quoted, or we quote it // Don't we know what the server is doing?? $colname_rs_products = (get_magic_quotes_gpc()) ? $_GET['RoomID'] : addslashes($_GET['RoomID']);); } // Change the database. // Why? Are we really using several databases? mysql_select_db($database_lighting, $lighting);
Bookmarks