manxten Posted January 19, 2014 Report Posted January 19, 2014 Salut! Am si eu o problema cu un cos de cumparaturi. Problema: Structura: 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.comcod products.php: <?php include("includes/db.php"); include("includes/functions.php"); if - Pastebin.comcod index.php: <? header("location:products.php"); ?> - Pastebin.comcod billing.php: <?php include("includes/db.php"); include("includes/functions.php"); if - Pastebin.comcod shopping.sql: -- phpMyAdmin SQL Dump -- version 2.11.9.5 -- http://www.phpmyadmin.net -- - - Pastebin.comfunctions.php: <?php function get_product_name($pid){ $result=mysqli_query($db, "select - Pastebin.comdb.php: <?php //conectare la baza de date @ $db = mysqli_connect("localhost", " - Pastebin.comEu 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 Quote
GarryOne Posted January 19, 2014 Report Posted January 19, 2014 (edited) 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 January 19, 2014 by GarryOne Quote
manxten Posted January 19, 2014 Author Report Posted January 19, 2014 (edited) functioneaza. mersi mult raman datorfunctioneaza si fara sa mai realizez iar conexiunea inainte de functie Edited January 19, 2014 by manxten Quote