Jump to content

LauraL19

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by LauraL19

  1. 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 
    
  2. 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 

     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";
    ?>
    
  3. 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");
    }
    ?>
    
  4. 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");
    }
    ?>
    
  5. 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");
    }
    ?>
×
×
  • 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.