Jump to content
manxten

[EROARE] Cos de cumparaturi

Recommended Posts

Salut! Am si eu o problema cu un cos de cumparaturi.

Problema: eroare.jpg

Structura: str.png

in images am imaginile produselor cu numele salvate in baza de date si in includes am functiile(functions.php) folosite si un fisier cu conectarea la baza de date(db.php)

cod shoppingcart.php: <?php include("includes/db.php"); include("includes/functions.php"); if - Pastebin.com

cod products.php: <?php include("includes/db.php"); include("includes/functions.php"); if - Pastebin.com

cod index.php: <? header("location:products.php"); ?> - Pastebin.com

cod billing.php: <?php include("includes/db.php"); include("includes/functions.php"); if - Pastebin.com

cod shopping.sql: -- phpMyAdmin SQL Dump -- version 2.11.9.5 -- http://www.phpmyadmin.net -- - - Pastebin.com

functions.php: <?php function get_product_name($pid){ $result=mysqli_query($db, "select - Pastebin.com

db.php: <?php //conectare la baza de date @ $db = mysqli_connect("localhost", " - Pastebin.com

Eu m-am gandit prima data ca ar putea sa fie din cauza conexiunii ca nu e declarat global $db, dar nu am reusit sa ii dau de cap. Daca m-ati putea ajuta as ramane recunoscator :)

Link to comment
Share on other sites

Da, cel mai probabil e din cauza ca nu ai declar $db GLOBAL.

in functions.php, la prima functie, incearca asa si vezi daca mai primesti eroare.

$db = mysqli_connect("localhost", "root", "", "test_db");

function get_product_name($pid){

GLOBAL $db;

$result=mysqli_query($db, "select name from products where serial=$pid");

$row=mysqli_fetch_array($result);

return $row['name'];

}

Edited by GarryOne
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...