Jump to content

LauraL19

Members
  • Posts

    10
  • Joined

  • Last visited

LauraL19's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for your help chaps, much appreciated.
  2. OK I have changed $passwd to $password in both catalogue.php and dbstuff.inc which seems to have taken me a step forward. The only error I now get is - Query died: category - No database selected
  3. I followed the instructions as set out in the book. I have since given full privileges to "admin". I have set the password as instructed in the book and been very careful in following every step.
  4. Hi chaps, thanks for your help. from replacing $result..... with your suggested line above, I get the following message - Warning: mysqli_connect(): (HY000/1045): Access denied for user 'admin'@'localhost' (using password: YES) in C:\xampp\htdocs\Catalogue.php on line 61 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\xampp\htdocs\Catalogue.php on line 65 Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\xampp\htdocs\Catalogue.php on line 65 Query died: category
  5. It returns - Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\dbstuff.inc on line 6
  6. Hi Ch0cu3r, That is a great help thank you. So my Database login seems to be failing I get an - Warning: mysql_errno() expects parameter 1 to be resource, string given in C:\xampp\htdocs\dbstuff.inc on line 3 For every line of the following, this is the first include that my PHP file loads - <?php $host = "localhost"; $user = "admin"; $passwd = "xy.34W"; $dbname = "FurnitureCatalog"; ?>
  7. Arghhhhh, no it isn't, formatting is lost during the pasting. Anything I need to do to prevent this on this web site?
  8. It was actually indented, but pasting it here it lost its indents. I should say this is not my code, it is code from Janet Valade. I had been writing my own code based on the principles gleaned from her book, but ving issues, so decided to start with her code, then modify it to my needs. So having downloaded it from her site, I found I had problems with this as well, so assume I have something fundamentally wrong. Anyway here is the code again, hopefully with indents this time. Thank you. <?php /* Program: Catalogue.php * Desc: Dislays a catalogue of products */ include ("dbstuff.inc"); $n_per_page = 2; if(isset($_POST['products'])) { if(!isset($_POST['interest'])) { header("location: Catalog_furniture.php"); exit(); } else { if(isset($_POST['n_end'])) { if($_POST['Products'] == "Previous") { $n_start = $_POST['n_end']-($n_per_page)-1; } else { $n_start = $_POST['n_end'] +1; } } else { $n_start = 1; } $n_end = $n_start + $n_per_page - 1; $cxn = mysqli_connect($host,$user, $passwd, $database); $query = "select * FROM Furniture WHERE type = '$_POST[interest]' ORDER BY name"; $result = mysqli_query($cxn,$query) or die ("query died: furniture"); $n=1; while($row = mysqli_fetch_assoc($result)) { foreach($row as $field => $value) { $products[$n][$field]=$value; } $n++; } $n_products = sizeof ($products); if($n_end > $n_products) { $n_end = $n_products; } include ("page_furniture_products.inc"); } // end else isset interest } // end if isset products else { $cxn = mysqli_connect ($host, $user, $passwd, $database); $query = "SELECT DISTINCT category, type FROM Furniture ORDER BY category, type"; $result = mysqli_query($cxn, $query) or die ("Query died: category"); while($row = mysqli_fetch_array($result)) { $furn_Categories[$row['category']][]=$row['type']; } include("page_furniture_index.inc"); } ?>
  9. How about this - Hi, I am a complete newbie and would like to self teach to build my own database driven website. I am working from "PHP&MySQL Web Development for Dummies (Janet Valade) as a starting point. After experiencing a number of issues with the code I had created for my own site, I decided to just write the code as provided in the book, this is for a simple catalogue. But I am getting problems with that. The error message I get is - Query died: category Thank you so much in anticipation of any help I am using PHP 5.5.3, and MySQL 5.6.11 and Apache 2.4.4, running on Windows 7 pro. This is the code for the main PHP file (catalogue.php), it calls 3 includes (dbstuff.inc, page_furniture_index.inc, page_furniture_products.inc), I will add the code for these if anyone wishes. But for now here is the main PHP file - <?php /* Program: Catalogue.php * Desc: Dislays a catalogue of products */ include ("dbstuff.inc"); $n_per_page = 2; if(isset($_POST['products'])) { if(!isset($_POST['interest'])) { header("location: Catalog_furniture.php"); exit(); } else { if(isset($_POST['n_end'])) { if($_POST['Products'] == "Previous") { $n_start = $_POST['n_end']-($n_per_page)-1; } else { $n_start = $_POST['n_end'] +1; } } else { $n_start = 1; } $n_end = $n_start + $n_per_page - 1; $cxn = mysqli_connect($host,$user, $passwd, $database); $query = "select * FROM Furniture WHERE type = '$_POST[interest]' ORDER BY name"; $result = mysqli_query($cxn,$query) or die ("query died: furniture"); $n=1; while($row = mysqli_fetch_assoc($result)) { foreach($row as $field => $value) { $products[$n][$field]=$value; } $n++; } $n_products = sizeof ($products); if($n_end > $n_products) { $n_end = $n_products; } include ("page_furniture_products.inc"); } // end else isset interest } // end if isset products else { $cxn = mysqli_connect ($host, $user, $passwd, $database); $query = "SELECT DISTINCT category, type FROM Furniture ORDER BY category, type"; $result = mysqli_query($cxn, $query) or die ("Query died: category"); while($row = mysqli_fetch_array($result)) { $furn_Categories[$row['category']][]=$row['type']; } include("page_furniture_index.inc"); } ?>
  10. Hi, I am a complete newbie and would like to self teach to build my own database driven website. I am working from "PHP&MySQL Web Development for Dummies (Janet Valade) as a starting point. After experiencing a number of issues with the code I had created for my own site, I decided to just write the code as provided in the book, this is for a simple catalogue. But I am getting problems with that. The error message I get is - Query died: category Thank you so much in anticipation of any help I am using PHP 5.5.3, and MySQL 5.6.11 and Apache 2.4.4, running on Windows 7 pro. This is the code for the main PHP file (catalogue.php), it calls 3 includes (dbstuff.inc, page_furniture_index.inc, page_furniture_products.inc), I will add the code for these if anyone wishes. But for now here is the main PHP file - <?php /* Program: Catalogue.php * Desc: Dislays a catalogue of products */ include ("dbstuff.inc"); $n_per_page = 2; if(isset($_POST['products'])) { if(!isset($_POST['interest'])) { header("location: Catalog_furniture.php"); exit(); } else { if(isset($_POST['n_end'])) { if($_POST['Products'] == "Previous") { $n_start = $_POST['n_end']-($n_per_page)-1; } else { $n_start = $_POST['n_end'] +1; } } else { $n_start = 1; } $n_end = $n_start + $n_per_page - 1; $cxn = mysqli_connect($host,$user, $passwd, $database); $query = "select * FROM Furniture WHERE type = '$_POST[interest]' ORDER BY name"; $result = mysqli_query($cxn,$query) or die ("query died: furniture"); $n=1; while($row = mysqli_fetch_assoc($result)) { foreach($row as $field => $value) { $products[$n][$field]=$value; } $n++; } $n_products = sizeof ($products); if($n_end > $n_products) { $n_end = $n_products; } include ("page_furniture_products.inc"); } // end else isset interest } // end if isset products else { $cxn = mysqli_connect ($host, $user, $passwd, $database); $query = "SELECT DISTINCT category, type FROM Furniture ORDER BY category, type"; $result = mysqli_query($cxn, $query) or die ("Query died: category"); while($row = mysqli_fetch_array($result)) { $furn_Categories[$row['category']][]=$row['type']; } include("page_furniture_index.inc"); } ?>
  11. I am a newbie from the UK. I am trying to self teach PHP and having some difficulties, so likely to be a pain. I hope with time that will not be the case.
×
×
  • 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.