Jump to content

Charwil

New Members
  • Posts

    5
  • Joined

  • Last visited

Charwil's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. FloorPuzzles is the data in the Category db row, so it looks for FloorPuzzles in that row and returns all that have it. What do you mean I've buried my data in a script? It's in a db table... Thank you I will take a look into PDO, as for security that's something I work on once everything works correctly, although their is nothing for a user to inject into as of now. I wanted it to check the status as that section is to display a single product in more detail. The link on the category list page is directed to the product's ID, so the check for will return as for example "123456" and will set that query to work for that ID, then later on it uses it again to check for the ID in the database, and return that. I managed to achieve what I wanted to in this thread last night excluding the invalid parameter, which I guess is a flaw with what I said above, I think that's what you were trying to get at now. Thanks for the advice.
  2. Hello, I recently posted here about an issue I was having with my database orientated products page. I have now run into another problem where say if, /db.php was typed or /db.php?p=IDoNotExist was typed, it returns blank. I have in my code the desired content to be displayed, but it just doesn't seem to want to make a show. I was also wondering if it is possible to show different content for whatever the URL is, so for no parameter, the content about the products, and a non existent one, maybe "Product not found"? Here is my code: <?php $db=mysql_connect ("localhost", "webwibco_charlie", "Hello123") or die ('I cannot connect to the database because: ' . mysql_error()); $mydb=mysql_select_db("webwibco_products"); include("header.php"); $status = htmlspecialchars( @$_GET ['p'] ); if ($status == "floorpuzzles") { echo "<h1>Our Floor Puzzles</h1>"; $sql="SELECT ID, Name, Tags, Description, Category FROM products WHERE Category LIKE '%" . FloorPuzzles . "%'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; echo "<div class=\"box\">"; echo "<h1>$Name</h1>"; echo "<div class=\"floorbox\"><a href=\"?p=$ID\"><img src=\"images/products/catalogue/big/floorpuzzles/$ID.jpg\" class=\"small\"></a></div>"; echo "<h2>$Description</h2>"; echo "</div>"; } ?> <? }else{ if ($status == $_GET["p"]) { $sql="SELECT ID, Name, Tags, Description, Pieces, Size, Barcode, Category FROM products WHERE ID = '" . $_GET['p'] . "'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; $Pieces =$row['Pieces']; $Size =$row['Size']; $Barcode =$row['Barcode']; echo "<div class=\"1\">"; echo "<h1>$Name</h1>"; echo "<div class=\"bigbox\">"; echo "<div class=\"floorbox\"><img src=\"images/products/catalogue/big/floorpuzzles/$ID.jpg\" class=\"big\"></div>"; echo "</div>"; echo "</div>"; echo "<div class=\"2\">"; echo "<p>Puzzle Pieces: $Pieces</p> <p>Puzzle Size: $Size</p> <p>Barcode: $Barcode</p>"; echo "</div>"; } }else{ ?> <? echo"<h1>Our Products</h1> <p>Our jigsaw puzzles are hand cut by skilled craftsmen and therefore each one is unique with self-correcting pieces. There is a strict quality control process at all stages by our highly experienced staff. The puzzles are durable and provide fun and excitement, enhancing learning and a child’s development.<p> <p>All of our jigsaws are made using materials from sustainable resources grown in managed forests. Where possible we support companies in the UK and source our components locally, most of our suppliers are in the East Midlands, many in Derbyshire and Nottinghamshire. We keep packaging to a minimum and take our environmental and ethical responsibilities very seriously.</p> <p>Reducing waste and recycling was a way of life for us before it became fashionable. We are constantly searching for new ideas and consult teachers when developing our jigsaws, which are often used within the national curriculum.</p> <p>As well as making our own range, we manufacture for leading suppliers to the education market. Check for \"Made in Britain\" and it is probably made by us.</p> <p>We have a wide variety of products available for viewing, from classic floor puzzles to innovative inset trays. You can take a look at all our products on this page, simply use the navigation buttons to your left.</p>"; }} include("footer.php"); ?> The final echo is what I wish to be displayed on the URL without or with an invalid parameter. Here is my site URL: http://www.webwib.co.uk/JustJigsaws/search.php (note that only the "Floor Puzzles" category has content within it). Thank you in advance for assistance.
  3. Thank you very much. I had pieces spelled incorrectly, always get that wrong! Thank you for your help and time, you have saved me what would have probably been 2 days of constant Google searching
  4. Thank you for your quick response. I have attempted to implement your suggested solution, and it appears to be a step in the right direction. However, when navigating to the individual product page, I get this error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in/home/webwibco/public_html/JustJigsaws/search.php on line 31 This is line 31: while($row=mysql_fetch_array($result)){ I also noticed that it only displays the error when the URL extension is just "?JJ080" and still displays a blank page when it is "?p=JJ080". Here is my modified code after your solution: <?php $db=mysql_connect ("localhost", "webwibco_charlie", "Hello123") or die ('I cannot connect to the database because: ' . mysql_error()); $mydb=mysql_select_db("webwibco_products"); include("header.php"); $status = htmlspecialchars( @$_GET ['p'] ); if ($status == "floorpuzzles") { echo "<h1>Our Floor Puzzles</h1>"; $sql="SELECT ID, Name, Tags, Description, Category FROM products WHERE Category LIKE '%" . FloorPuzzles . "%'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; echo "<div class=\"box\">"; echo "<h1>$Name</h1>"; echo "<div class=\"floorbox\"><a href=\"?$ID#productspage\"><img src=\"images/products/catalogue/big/floorpuzzles/$ID.jpg\" class=\"small\"></a></div>"; echo "<h2>$Description</h2>"; echo "</div>"; } }else{ if ($status == "$ID") { $sql="SELECT ID, Name, Tags, Description, Peices, Size, Barcode, Category FROM products WHERE ID LIKE '%" . @$_GET['p'] . "%'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; $Pieces =$row['Pieces']; $Size =$row['Size']; $Barcode =$row['Barcode']; echo "<div class=\"1\">"; echo "<h1>$Name</h1>"; echo "<div class=\"bigbox\">"; echo "<div class=\"floorbox\"><img src=\"images/products/catalogue/big/floorpuzzles/$ID.jpg\" class=\"big\"></div>"; echo "</div>"; echo "</div>"; echo "<div class=\"2\">"; echo "<p>Puzzle Pieces: $Pieces</p> <p>Puzzle Size: $Size</p> <p>Barcode $Barcode</p>"; echo "</div>"; } } } include("footer.php"); ?> I apologize if this is a quick fix I have missed, but I am a noob at this server side stuff, I fully understand what you're getting at, but not so much on how to execute it correctly. Thank you again for the quick response, and thanks in advance for any further assistance.
  5. Hello, I have been developing a website that needs to display products online, I was originally going to hand-write the PHP code but I thought it would be more beneficial to make it database orientated as new products can easily be added and a search function becomes possible. I have it working so far so good, but the last part I can't seem to get working. I have it so all the products that have the desired category are displayed, but I want a more detailed analysis of the product to appear when the image is clicked, which at the moment, displays a blank page. http://www.webwib.co.uk/JustJigsaws/products.php?p=floorpuzzles - this is the hand coded version that demonstrates how I want it to work. http://www.webwib.co.uk/JustJigsaws/db.php?floorpuzzles - this is the db version so far, it works how it is intended to apart from the last stage, which returns as a blank page rather than a dedicated page for the selected product. Here is my code, the third segment beginning with "if(isset($_GET['$ID'])){", is my attempt at the final stage. <?php $db=mysql_connect ("localhost", "webwibco_charlie", "Hello123") or die ('I cannot connect to the database because: ' . mysql_error()); $mydb=mysql_select_db("webwibco_products"); include("header.php"); if(isset($_GET['floorpuzzles'])){ echo "<h1>Our Floor Puzzles</h1>"; $sql="SELECT ID, Name, Tags, Description, Category FROM products WHERE Category LIKE '%" . FloorPuzzles . "%'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; echo "<div class=\"box\">"; echo "<h1>$Name</h1>"; echo "<div class=\"floorbox\"><a href=\"?$ID#productspage\"><img src=\"images/products/catalogue/$ID.jpg\" class=\"small\"></a></div>"; echo "<h2>$Description</h2>"; echo "</div>"; } } if(isset($_GET['anothercategory'])){ $sql="SELECT ID, Name, Tags, Description, Category FROM products WHERE Category LIKE '%" . AnotherCategory . "%'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; echo "<h1>Our Floor Puzzles</h1>"; echo "<div class=\"box\">"; echo "<h1>$Name</h1>"; echo "<div class=\"floorbox\"><a href=\"?$ID0#productspage\"><img src=\"images/products/catalogue//$ID.jpg\" class=\"small\"></a></div>"; echo "<h2>$Description</h2>"; echo "</div>"; } } if(isset($_GET['$ID'])){ $sql="SELECT ID, Name, Tags, Description, Peices, Size, Barcode, Category FROM products WHERE ID LIKE '%" . $ID . "%'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; $Pieces =$row['Pieces']; $Size =$row['Size']; $Barcode =$row['Barcode']; echo "<div class=\"1\">"; echo "<h1>$Name</h1>"; echo "<div class=\"bigbox\">"; echo "<div class=\"floorbox\"><img src=\"images/products/catalogue/$ID.jpg\" class=\"big\"></div>"; echo "</div>"; echo "</div>"; echo "<div class=\"2\">"; echo "<p>Puzzle Pieces: $Pieces</p> <p>Puzzle Size: $Size</p> <p>Barcode $Barcode</p>"; echo "</div>"; } } include("footer.php"); ?> Thank you in advance for any assistance given.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.