Jump to content

Louffeman

Members
  • Posts

    31
  • Joined

  • Last visited

Posts posted by Louffeman

  1. now the output is:SELECT * FROM trybase WHERE name IN ('',SELECT * FROM trybase WHERE name IN ('','produits',error the same:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:wampserver32wwwsalevotre_panier.php on line 31

  2. I have already changed<?phpsession_start();require_once 'panier.php';$panier = new Panier('produits');$listproduit = $panier->getPanier();?><?php if(!$listproduit){?><p> votre panier est vide </p><?php } else {?><table border="1" width="50%"><tr><td>Name</td><td>Price</td><td>Quantity</td><td>Amount</td></tr><?phpprint_r($_SESSION);if(isset($_SESSION['paniers'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['paniers'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);while ($produit=mysql_fetch_array($query)){?><tr><td><?php print $produit['name']; ?></td><td><?php print $produit['price']; ?></td><td><?php print $produit['quantity']; ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity'];?>€</td></tr><?php } ?><?php } ?><?php } ?></table><p><a href="index.php">Home[/url]</p>

  3. yes, this is the panier.php<?phpclass Panier{public $nom;private static $nbPanier = 0;public function __construct($nom){$this->name = $nom;}public function set ($key, $value){$_SESSION['paniers'][$this->nom][$key] = $value;}public function get($key){if(isset($_SESSION['paniers'][$this->nom][$key]))return $_SESSION['paniers'][$this->nom][$key];return null;}public function delet($key){if(isset($_SESSION['paniers'][$this->nom][$key]))unset($_SESSION['paniers'][$this->nom][$key]);}public function getPanier(){if(isset($_SESSION['paniers'][$this->nom]))return $_SESSION['paniers'][$this->nom];return array();}public function clear(){if(isset($_SESSION['paniers'][$this->nom]))unset($_SESSION['paniers'][$this->nom]);}}?>

  4. I did as you sais,but it is still the same, no display of the buying object (name, price, quantity and amount)<?phpif(isset($_SESSION['cart'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['cart'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);echo mysql_num_rows($query).'<br>';while ($produit=mysql_fetch_array($query)){?>

  5. it is clear that this part has problem, but the server has no error indication,

    <?phpif(isset($_SESSION['cart'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['cart'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);while ($produit=mysql_fetch_array($query)){?><tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?>€</td></tr><?php } ?><?php } ?><?php } ?>

  6. it is clear that this part has problem, but the server has no error indication, <?phpif(isset($_SESSION['cart'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['cart'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);while ($produit=mysql_fetch_array($query)){?><tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?>€</td></tr><?php } ?><?php } ?><?php } ?>

  7. yes, the server have no error, but not the display of the buying object (name, price, quantity and amount)which mean's this part doesn't work:

    <td><?php print $produit['name']; ?></td><td><?php print $produit['price']; ?></td><td><?php print $produit['quantity']; ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity'];?>€</td></tr>

  8. I didn't put the semicolon in my first script, but it runs well.now I put the semicolon, it change nothing, so I think it's not a problem.

     

    <td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?></td>

     

    for this line, I put serveral places to teste it, the error is always:it mean's the "else" is not necessary, No ? I d'ont know.Parse error: syntax error, unexpected T_ELSE in C:wampserver32wwwsalevotre_panier.php on line 41
    <?php } else {?>
    Also you haven't put a semicolon at the end of these 4 PHP lines:
  9. Hi,I have a shopping cart (first script)below is OK, but when I want to make the calculate(second script) the amount,it indicate the under last line ( <p><a href="index.php">Home[/url]</p), error is: Parse error: syntax error, unexpected $end in C:wampserver32wwwsalevotre_panier.php on line 41I wish someone can help me to modifiy it.first script (it is OK)<?phpsession_start();require_once 'panier.php';$panier = new Panier('produits');$listproduit = $panier->getPanier();?><?php if(!$listproduit){?><p> votre panier est vide </p><?php } else {?><table border="1" width="50%"><tr><td>Name</td><td>Price</td><td>Quantity</td><td>Amount</td></tr><?php foreach($listproduit as $produit) { ?><tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td></tr><?php } ?></table><?php } ?><p><a href="index.php">Home[/url]</p>second script:session_start();require_once 'panier.php';$panier = new Panier('produits');$listproduit = $panier->getPanier();?><?php if(!$listproduit){?><p> votre panier est vide </p><?php } else {?><table border="1" width="50%"><tr><td>Name</td><td>Price</td><td>Quantity</td><td>Amount</td></tr><?phpif(isset($_SESSION['cart'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['cart'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);while ($produit=mysql_fetch_array($query)){?><?php foreach($listproduit as $produit) { ?><tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?></td></tr><?php } ?></table><?php } ?><p><a href="index.php">Home[/url]</p>

×
×
  • Create New...