Jump to content

.chester

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by .chester

  1. As predicted, it was a minor thing. The nr_buc column was actually called nr_bucati. As soon as I changed it, everything worked perfectly. Thanks for the help everyone, much obliged!
  2. UPDATE: <?php include("autorizare.php"); include("admin_top.php"); mysql_connect("localhost", "root", ""); mysql_select_db("anticariat"); ?> <h1>Comenzi</h1> <b>Comenzi inca neonorate</b><br> <?php /* afisam lista comenzilor neonorate*/ $sqlTranzactii="select id_tranzactie, data_tranzactie, nume_cumparator, adresa_cumparator from tranzactii where comanda_onorata=0"; $resursaTranzactii=mysql_query($sqlTranzactii) or die(mysql_error()); print mysql_error(); while($rowTranzactie=mysql_fetch_array($resursaTranzactii)) print_r($sqlTranzactii); print_r($resursaTranzactii); { ?> <form action="prelucrare_comenzi.php" method="post"> Data comenzii: <b><?php echo $rowTranzactie['data_tranzactie']?></b> <div style="width:500px; border:1px solid #ffffff; background-color:#c0c0c0; padding:5px"> <b><?php echo $rowTranzactie['nume_cumparator']?></b><br> <?php echo $rowTranzactie['adresa_cumparator']?> <table border="1" cellpadding="4" cellspacing="0"> <tr> <td align="center"><b>Carte</b></td> <td align="center"><b>Nr. Buc</b></td> <td align="center"><b>Pret</b></td> <td align="center"><b>Total</b></td> </tr> <?php $sqlCarti="select titlu, nume_autor, pret, nr_buc from vanzari, carti, autori where carti.id_carte=vanzari.id_carte and carti.id_autor=autori.id_autor and id_tranzactie=".$rowTranzactie['id_tranzactie']; $resursaCarti=mysql_query($sqlCarti); while($rowCarte=mysql_fetch_array($resursaCarti)) { print '<tr><td>'.$rowCarte['titlu'].' de '.$rowCarte['nume_autor'].'</td> <td align="right">'.$rowCarte['nr_buc'].'</td> <td align="right">'.$rowCarte['pret'].' </td>'; $total=$rowCarte['pret'] * $rowCarte['nr_buc']; print '<td align="right">'.$total.'</td></tr>'; $totalGeneral=$totalGeneral+$total; } ?> <tr> <td colspan="3" align="right">Total comanda:</td><td><?php echo $totalGeneral?> lei</td> </tr> </table> <input type="hidden" name="id_tranzactie" value="<?php echo $rowTranzactie['id_tranzactie']?>"> <input type="submit" name="comanda_onorata" value="Comanda onorata!"> <input type="submit" name="anuleaza_comanda" value="Anuleaza comanda"> </div> </form> <?php } ?> </body> </html> I worked on it some more and there's a wee bit of progress. At least the table is showing now. I also added print_r() to $sqlTranzactii and $resursaTranzactii. The result: I don't know what to make of what print_r() is displaying. Is there no data being extracted from the database?
  3. I've tried adding mysql_error() as explained by some other forumites, the page stays exactly the same, with the same error on line 12 (even though line 12 isn't even relevant anymore, as it contains the mysql_error() code). I've tried running the query directly in the mysql window, it works perfectly and returns what it should. I'm stumped.
  4. data_tranzactie is actually timestamp format. Could you please explain where in the code should I add the mysql_error? I've never used it before.
  5. It's one of those questions again. I'm getting Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given on line 12, the one with the while() statement: $sqlTranzactii="select id_tranzactie, DATE_FORMAT(data_tranzactie,'%d-%m-%y') as data_tranzactie, nume_cumparator, adresa_cumparator from tranzactii where comanda_onorata=0"; $resursaTranzactii=mysql_query($sqlTranzactii); while($rowTranzactie=mysql_fetch_array($resursaTranzactii)) form action="prelucrare_comenzi.php" method="post"> Data comenzii: <b><?php echo $rowTranzactie['data_tranzactie']?></b> <div style="width:500px; border:1px solid #ffffff; background-color:#c0c0c0; padding:5px"> <b><?php echo $rowTranzactie['nume_cumparator']?></b><br> <?php echo $rowTranzactie['adresa_cumparator']?> I tried googling the issue, but I haven't found anything exactly like my problem. I'm sure it's something trivial that I'm missing, though. Any ideas?
  6. I did a bit of troubleshooting and came up with a few concerning facts: 1. I've checked the source for the "Add to cart" button and it seems it doesn't pass any info except id_carte, as evidenced by the empty values: <form action="cos.php?actiune=adauga" method="post"> <input type="hidden" name="id_carte" value="6"> <input type="hidden" name="titlu" value=""> <input type="hidden" name="autor" value=""> <input type="hidden" name="pret" value=""> <input type="submit" value="Cumpara acum!"> </form> 2. I also used var_dump and it returns the following, which I guess makes sense: array(5) { ["id_carte"]=> array(1) { [0]=> string(1) "3" } ["nr_buc"]=> array(1) { [0]=> int(1) } ["pret"]=> array(1) { [0]=> string(0) "" } ["titlu"]=> array(1) { [0]=> string(0) "" } ["nume_autor"]=> array(1) { [0]=> NULL } } So I guess the "Add to cart" button isn't sending the required info, which is why there's nothing to display in the shopping cart, except quantity and id_carte. Now what?
  7. Hello, I'm working on an online bookstore and I'm having some problems with the shopping cart section. On the book page I have the following code, which is supposed to gather information like book title, author and price and send it to the shopping cart: <form action="cos.php?actiune=adauga" method="post"> <input type="hidden" name="id_carte" value="<?=$id_carte?>"> <input type="hidden" name="titlu" value="<?=$rowCarte['titlu']?>"> <input type="hidden" name="autor" value="<?=$rowCarte['nume_autor']?>"> <input type="hidden" name="pret" value="<?=$rowCarte['pret']?>"> <input type="submit" value="Cumpara acum!"> </form> Cart.php looks like this: <?php session_start(); include("conectare.php"); include("pagetop.php"); include("meniu.php"); $actiune=$_GET['actiune']; if(isset($_GET['actiune']) && $_GET['actiune']=="adauga") { $_SESSION['id_carte'][]=$_POST['id_carte']; $_SESSION['nr_buc'][]=1; $_SESSION['pret'][]=$_POST['pret']; $_SESSION['titlu'][]=$_POST['titlu']; $_SESSION['nume_autor'][]=$_POST['nume_autor']; } if(isset($_GET['actiune']) && $_GET['actiune']=="modifica") { for($i=0; $i<count($_SESSION['id_carte']); $i++) { $_SESSION['nr_buc'][$i]=$_POST['noulNrBuc'][$i]; } } ?> <td align="top"> <h1>Cosul de cumparaturi</h1> <form action="cos.php?actiune=modifica" method="post"> <table border="1" cellspacing="0" cellpadding="4"> <tr bgcolor="#F9F1E7"> <td><b>Nr. Buc</b></td> <td><b>Carte</b></td> <td><b>Pret</b></td> <td><b>Total</b></td> </tr> <?php for($i=0; $i<count($_SESSION['id_carte']); $i++) { if($_SESSION['nr_buc'][$i] !=0) { print '<tr><td><input type="text" name="noulNrBuc['.$i.']" size="1" value="'.$_SESSION['nr_buc'][$i].'"></td> <td>'.$_SESSION['titlu'][$i].' de '.$_SESSION['nume_autor'][$i].' </td> <td align="right">'.$_SESSION['pret'][$i].' lei </td> <td align="right">'.($_SESSION['pret'][$i] * $_SESSION['nr_buc'][$i]).' lei </td> </tr>'; $totalGeneral=$totalGeneral + ($_SESSION['pret'][$i] * $_SESSION['nr_buc'][$i]); } } print '<tr><td align="right" colspan="3"> Total in cos </td><td align="right">'.$totalGeneral.' lei </td></tr>'; ?> </table> <input type="submit" value="Modifica"><br><br> Introduceti 0 pentru cartile ce doriti sa le scoateti din cos! <h1>Continuare</h1> <table> <tr> <td width="200" align="center"><img src="cos.jpg"><a href="index1.php">Continua cumparaturile</a></td> <td width="200" align="center"><img src="casa.jpg"><a href="casa.php">Mergi la casa</a></td> </tr> </table> </td> <?php include("page_bottom.php"); ?> My problem is every time I add a book to the cart, nothing is updated except for the quantity, so I have no author, title or price info, like so: I'm just starting php coding and I can't figure out what's going on. Anyone willing to lend a helping hand?
  8. Is the newline char inside the carte.php file which is referred to in the $inapoi variable? Should I post carte.php too? And if that doesn't work, is there any other way around this? Could I perhaps return the user to the book they just commented on in some other way?
  9. Hello everyone, I'm just starting out with PHP as I need to create an online bookstore for a school project. I'm working by a magazine which should teach you exactly how to do this using PHP, but I've had a bunch of problems with the code they use and I don't really know what's going on. Anyway, this looks really simple and basically what it does is allows you to post a comment on a book, then returns you to the book's page. Problem is, I'm getting the Header may not contain more than a single header, new line detected. error and I can't figure out why. I've tried researching into the matter but all the cases I found had to do with returning to an url, which is not my case. Anyway, here's the snippet of code: The form: <div style="width:400px; border:1px solid #ffffff; background-color:#F9F1E7; padding:5px"> <b>Adauga opinia ta:</b> <hr size="1"> <form action="adauga_comentariu.php" method="POST"> Nume: <input type="text" name="nume_utilizator"><br><br> Email: <input type="text" name="adresa_email"><br><br> Comentariu: <br> <textarea name="comentariu" cols="45"></textarea><br><br> <input type="hidden" name="id_carte" value="<?=id_carte?>"> <center><input type="submit" value="Adauga"</center> </form> </div> The script adaugare_comentariu.php: <?php ob_start(); include("conectare.php"); $numeFaraTags=strip_tags($_POST['nume_utilizator']); $emailFaraTags=strip_tags($_POST['adresa_email']); $comentariuFaraTags=strip_tags($_POST['comentariu']); $sql="insert into comentarii (id_carte, nume_utilizator, adresa_email, comentariu) values(".$_POST['id_carte'].", '".$numeFaraTags."','".$emailFaraTags."','".$comentariuFaraTags."')"; mysql_query($sql); $inapoi="carte.php?id_carte=".$_POST['id_carte']; header("location:urldecode($inapoi)"); ob_end_flush(); ?> conectare.php connects to the mysql database. $inapoi is the variable which returns the user to carte.php (the book he posted a comment on), where id_carte is the book's unique id. I'm getting Header may not contain more than a single header, new line detected on line ten, which is the header line. Can anyone help me? I've been stumped on this for a few days now and I've just let it pass and started working on other bits, but it's bugging me too much and I'd like to fix it.
×
×
  • 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.