
dh526
Members-
Posts
39 -
Joined
-
Last visited
Never
Everything posted by dh526
-
The values of $cardid etc are from some tables and they are all echoed out correctly and do return a number... (or email address) <form method='POST' action='buy.php'> <input type='hidden' value=$cardid name='cardid' /> <input type='hidden' value=$addid name='addid' /> <input type='hidden' value=$email name='email' /> <input type='hidden' value=$prodid name='prodid' /> <input type='submit' value='confirm order' > </form> Then on the next page I want to insert these values into a table. So I have done this : $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblOrders (ProductID, username, AddressID, CardID ) VALUES ($product,'$username', $addid, $cardid)"; but it doesn't work. I get a [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement error. What is wrong ?? can anyone help?? thank you in advance
-
Arrrggg, had it working for a moment, and now its gone :S was to do with the value='1' instead of =1 :S amateurish error Anyway, now I am getting this error ... : [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ProductID='. at the moment my query looks like this: $sqlprod="SELECT ProductID, myname, Cost, Description FROM tblProducts WHERE ProductID=$product"; however if I change it to ='$product' I get a type mismatch... Arrrgggg I.HATE.MICROSOFT.
-
'db09' is set up as a DSN and that works fine on many other forms... I think the issue is with passing the $product (either 1 or 2) to the tblProducts table. This does however return 1 (as there is 1 record) with the best_num_rows() function mind, so surely I can search with the value sent from the other page ($product) and search tblProducts. I think i have an error in these bits...: $product = $_POST['product']; echo "product : "; echo $product; $sqlprod="SELECT ProductID, myname, Cost, Description FROM tblProducts WHERE ProductID=$product"; $rsprod=odbc_exec($conn, $sqlprod); if (odbc_fetch_row($rsprod)) { $prodid=odbc_result($rsprod,"ProductID"); $myname=odbc_result($rsprod,"myname"); $cost=odbc_result($rsprod,"Cost"); $description=odbc_result($rsprod,"Description"); echo $myname; echo $cost; echo $description; echo $prodid; } when i echo out the variables I get nothing
-
Hi everyone and thank you for looking This is the error message I get when sending information between the 2 pages below. [Microsoft][ODBC Microsoft Access Driver]Invalid use of null pointer I also pass the variable across and it gives the output of product: 1 so this works properly :S basket.php which sends either 0 or 1 to basket.php. $_username is stored in a cookie. <?php if ($set==1) { echo "<br><br><h2>6 months subscription</h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £20 <input type='hidden' name='product' value='1'/></td> </tr><tr><td> Description : </td> <td> 6 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 6 months subscription Now'></td></tr></table></form><img src='line1.png' width='100%'><br><br><br><br><h2>12 months subscription </h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £30 <input type='hidden' name='product' value='2'/></td></tr><tr><td> Description : </td> <td> 12 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 12 months subscription Now'></td></tr></table></form><br><img src='line1.png' width='100%'><br><br>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> This is basket.php which should display the product that has been bought. <?php $conn=odbc_pconnect('db09','',''); // -------------- TEST $sql2="SELECT ProductID, myname, Cost, Description FROM tblProducts WHERE ProductID='$product'"; $rs3=odbc_exec($conn, $sq2); $rs1=odbc_num_rows($rs); function best_odbc_num_rows($r1) { ob_start(); // block printing table with results (int)$number=odbc_result_all($r1); ob_clean(); // block printing table with results return $number; } $rs4=best_odbc_num_rows($rs3); echo $rs4; // end of test if (odbc_error()) { echo odbc_errormsg($conn); } $product = $_POST['product']; echo "product : "; echo $product; $sqladd="SELECT AddressID, HouseNumber, Street, Town, Postcode FROM tblAddress WHERE username='$username'"; $sqlcard="SELECT cardid, username, myname, type, mynum, exp, sec FROM tblCard WHERE username='$username'"; $sqlcust="SELECT username, Password, Surname, Forename, DOB, [Email Address] FROM tblCustomer WHERE username='$username'"; $sqlprod="SELECT ProductID, myname, Cost, Description FROM tblProducts WHERE ProductID='$product'"; $rsadd=odbc_exec($conn, $sqladd); $rscard=odbc_exec($conn, $sqlcard); $rscust=odbc_exec($conn, $sqlcust); $rsprod=odbc_exec($conn, $sqlprod); if (odbc_fetch_row($rscard)) { $cardid=odbc_result($rsadd,"cardid"); $type=odbc_result($rscard,"type"); $mynum=odbc_result($rscard,"mynum"); } if (odbc_fetch_row($rsadd)) { $housenumber=odbc_result($rsadd,"HouseNumber"); $street=odbc_result($rsadd,"Street"); $town=odbc_result($rsadd,"Town"); $postcode=odbc_result($rsadd,"Postcode"); $addid=odbc_result($rsadd,"AddressID"); } if (odbc_fetch_row($rscust)) { $forename=odbc_result($rscust,"Forename"); $surname=odbc_result($rscust,"Surname"); } if (odbc_fetch_row($rsprod)) { $name=odbc_result($rsprod,"myname"); $cost=odbc_result($rsprod,"Cost"); $description=odbc_result($rsprod,"Description"); $prodid=odbc_result($rsprod,"ProductID"); } if ($set==1) { echo "<h1>Order details</h1><br><br><form Action='buy.php' Method='POST'> Name: $forename $surname <br> Delivery Address: $housenumber $street, $town, $postcode -- <a href='address.php'>add/edit address details</a><br> <br> card used: $type ( $mynum ) -- <a href='card.php'>add/edit card details</a> <br> <br> <h3>item bought</h3><br> Name:$name <br> Cost: $cost <br> Description:$description <br><br><input type='hidden' value=$username name='username1'> <input type='hidden' value=$cardid name='cardid'><input type='hidden' value=$addid name='addid'> <input type='hidden' value=$email name='email'> <input type='submit' value='confirm order'> </form>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?>
-
The [ ] brackets are just because the "Email Address" field has a space in it and I ran into problems before with it ... I made the amendments and it still isn't working, and i dont understand why its not reading and info from the tables :S
-
Hi, I have worked out that the problem is at the top (the setcookie lines) that makes the screen go white, now I just get the correct layout with no details in it !
-
Well spotted And what isn't working... erm, everything, I just get a white screen when I click on one of the 2 subscribe buttons on subscribe.php trying to go to basket.php...
-
Good point... Don't really know what i was thinking there :S Right... On subcribe.php a choice of 2 options to buy. <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ;} else { $set=0; } ?> <?php if ($set==1) { echo "<br><br><h2>6 months subscription</h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £20 <input type='hidden' name='product' value='1'/></td> </tr><tr><td> Description : </td> <td> 6 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 6 months subscription Now' value='1'></td></tr></table></form><img src='line1.png' width='100%'><br><br><br><br><h2>12 months subscription </h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £30 <input type='hidden' name='product' value='2'/></td></tr><tr><td> Description : </td> <td> 12 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 12 months subscription Now'></td></tr></table></form><br><img src='line1.png' width='100%'><br><br>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> The basket.php, a simple preview of the order. <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ; $product=$_POST('product'); setcookie('product', $product, time()+3600); } else { $set=0; } ?> <?php if ($set==1) { $conn=odbc_connect('db09,'',''); $sqladd="SELECT AddressID, HouseNumber, Street, Town, Postcode FROM tblAddress WHERE username=$username"; $sqlcard="SELECT CardID, type, mynum FROM tblCard WHERE username=$username"; $sqlcust="SELECT Forename, Surname, [Email Address] FROM tblCustomer WHERE username=$username"; $sqlprod="SELECT ProductID, Name, Cost, Description FROM tblProducts WHERE ProductID=$product"; $rsadd=odbc_exec($conn, $sqladd); $rscard=odbc_exec($conn, $sqlcard); $rscust=odbc_exec($conn, $sqlcust); $rsprod=odbc_exec($conn, $sqlprod); if (odbc_fetch_row($rsadd)) { $housenumber=odbc_result($rsadd,"HouseNumber"); $street=odbc_result($rsadd,"Street"); $town=odbc_result($rsadd,"Town"); $postcode=odbc_result($rsadd,"Postcode"); $addid=odbc_result($rsadd,"AddressIDID"); } if (odbc_fetch_row($rscard)) { $type=odbc_result($rscard,"HouseNumber"); $mynum=odbc_result($rscard,"Street"); $cardid=odbc_result($rsadd,"CardID"); } if (odbc_fetch_row($rscust)) { $forename=odbc_result($rscust,"Forename"); $surname=odbc_result($rscust,"Surname"); } if (odbc_fetch_row($rsprod)) { $name=odbc_result($rsadd,"Name"); $cost=odbc_result($rsadd,"Cost"); $description=odbc_result($rsadd,"Description"); $prodid=odbc_result($rsadd,"ProductID"); } echo "<h1>Order details</h1><br><br><form Action='buy.php' Method='POST'> Name: $forename $surname <br> Delivery Address: $housenumber $street, $town, $postcode -- <a href='address.php'>add/edit address details</a><br> <br> card used: $type ( $mynyum ) -- <a href='card.php'>add/edit card details</a> <br> <br> <h3>item bought<h3><br> Name:$name <br> Cost: $cost <br> Description:$description <br><br><input type='hidden' value=$username name='username1'> <input type='hidden' value=$cardid name='cardid'><input type='hidden' value=$prodid name='prodid'><input type='hidden' value=$addid name='addid'> <input type='hidden' value=$email name='email'> <input type='submit' value='confirm order'> </form>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> and on buy.php. <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ; $product=$_POST('product'); } else { $set=0; } ?> <?php $cardid= $_POST['cardid']; $addid= $_POST['addid']; $email= $_POST['email']; $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblOrders (ProductID, username, AddressID, CardID ) VALUES ('$product','$username', '$addid','$cardid')"; if (odbc_exec($conn,$sql)) { echo "thank you for your custom! - a confirmation email has been sent to $email ."; echo " <br> <a href='index.php'>home</a> "; $to= $email; $from= "[email protected]"; $subject= "Tech!"; $message= "Thank you for your purchase, your order will be dispatched soon! "; $headers = "From: " .$from; mail($to, $subject, $message, $headers); } odbc_close($conn); ?> Thank you for looking
-
Hi, I'm trying to create a simple shop system with MS Access. I want to choose which product to buy, then when you click buy go to a confirm order page, then actually buy the item. Currently only the 1st of these works. I don't know if my method is correct, but any help would be massively appreciated subscribe.php <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ;} else { $set=0; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>tech!</title> <LINK href="favicon.ico" rel="favicon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#zone-bar li em").click(function() { var hidden = $(this).parents("li").children("ul").is(":hidden"); $("#zone-bar>ul>li>ul").hide() $("#zone-bar>ul>li>a").removeClass(); if (hidden) { $(this) .parents("li").children("ul").toggle() .parents("li").children("a").addClass("zoneCur"); } }); }); </script> </head> <body> <div id="page-wrap"> <div id="top-bar"> <a href="index.php"> <img src="images/logo.png" alt="DZone" class="floatleft height="200" width="500" /> </a> <div id="right-side"> <img src="images/usericon.jpg" alt="user icon" /> <?php if ($set==1) { echo "<a href='signedin.php'>$username</a> <a href='cart.php'>Basket</a>"; } else { echo "<a href='login1.php'>login</a> <a href='register1.php'>register</a>"; } ?> <a href="logout.php"> logout </a> <form id="main-search"> <label for="search-field" id="search-field-label">Search</label> <input type="text" tabindex="1" maxlength="255"id="search-field"/> <input type="image" alt="Search" value="Search" src="images/search.png" id="search-button"/> </form> </div> </div> <div id="zone-bar"> <ul> <li> <a href="#"><span> News <em class="opener-news"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding="5px" /> </em> </span></a> <ul class="Newssublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Reviews <em class="opener-reviews"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding= "5px" /> </em> </span></a> <ul class="reviewssublist"> <li><a href="#">Top 10's</a></li> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li> <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Shop <em class="opener-shop"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding = "5px" /> </em> </span></a> <ul class="shopsublist"> <li><a href="#">Subscribe</a></li> <li><a href="#">Back Issues</a></li> <li><a href="#">Merchandise</a></li> </ul> </li> <li> <a href="#"><span> Competitions <em class="opener-competitions"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="competitionsublist"> <li><a href="#">New Competition</a></li> <li><a href="#">Previous Winners</a></li> </ul> </li> <li> <a href="#"><span> Photos <em class="opener-photos"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="photosublist"> <li><a href="#">Tech! things</a></li> <li><a href="#">Tech! places</a></li> <li><a href="#">Tech! people</a></li> </ul> </li> <li> <a href="#"><span> Video <em class="opener-video"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="videosublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Movies</a></li> <li><a href="#">Music</a></li> <li><a href="#">Television</a></li> <li><a href="#">Comics & Animation</a></li> </ul> </li> <li> <a href="#"><span> About Us <em class="opener-aboutus"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="aboutussublist"> <li><a href="#">What we do</a></li> <li><a href="#">Jobs at tech!</a></li> <li><a href="#">Contact us</a></li> </ul> </li> </div> <div id='main-content'> <div id='feature-content'> <div id='feature-left'> <h1><a href="#">Subscribe</a></h1> <?php if ($set==1) { echo "<br><br><h2>6 months subscription</h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £20 <input type='hidden' name='product' value='1'/></td> </tr><tr><td> Description : </td> <td> 6 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 6 months subscription Now' value='1'></td></tr></table></form><img src='line1.png' width='100%'><br><br><br><br><h2>12 months subscription </h2><br><img src='magazine.png', width='100%'/><br><br><form method='POST' action='basket.php'><table><tr><td> Price : </td> <td> £30 <input type='hidden' name='product' value='2'/></td></tr><tr><td> Description : </td> <td> 12 issues of tech! magazine delivered to your door </td></tr><tr><td> <input type='submit' value='Buy 12 months subscription Now'></td></tr></table></form><br><img src='line1.png' width='100%'><br><br>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> </div> <div id='feature-right'> <div class='feature-mini'> <h2><a href='subscribe.html'>Subscribe</a></h2> <br> <a href='#'><h3>Subscribe to tech! magazine</h3> <img src='images/logo.png' width='100%' /></a> <p> Subscribe! 50% of retail price! That is a saving of £30 per year!...<a href='#'>subcribe</a> </p> <br> <img src='line.png' width='100%'> <br> <br> <p> <a href='twitter.php'><img src='twitter.png' width='100%'></a> <br> <p align='center'> <a href='http://twitter.com/techmaguk'> <h4>Follow us!<h4> </a> </p> </p> <br> <img src='line.png' width='100%'> <br> <br> <h2>Feature</h2> <br> <a href='#'><h3>Dell Adamo vs Mac Air</h3> <br> <img src='adamomac.png' width='100%' /></a> <p> The new adamo has been touted as an Air killer... We test them both...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%' /> <br> <br> <a href='#'><h3>Windows 7 revealed</h3> <br> <img src="win7.png" width="100%" /></a> <p> Windows 7 revealed, and we have a play with it!...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%'> <br> <br> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <div id="footer" align="center"> <a href='#'> | contact us | </a> <a href='#'> Accessibility | </a> </div> </div> </body> </html> basket.php <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ; $product=$_POST('product'); setcookie('product', $product, time()+3600); } else { $set=0; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>tech!</title> <LINK href="favicon.ico" rel="favicon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#zone-bar li em").click(function() { var hidden = $(this).parents("li").children("ul").is(":hidden"); $("#zone-bar>ul>li>ul").hide() $("#zone-bar>ul>li>a").removeClass(); if (hidden) { $(this) .parents("li").children("ul").toggle() .parents("li").children("a").addClass("zoneCur"); } }); }); </script> </head> <body> <div id="page-wrap"> <div id="top-bar"> <a href="index.php"> <img src="images/logo.png" alt="DZone" class="floatleft height="200" width="500" /> </a> <div id="right-side"> <img src="images/usericon.jpg" alt="user icon" /> <?php if ($set==1) { echo "<a href='signedin.php'>$username</a> <a href='cart.php'>Basket</a>"; } else { echo "<a href='login1.php'>login</a> <a href='register1.php'>register</a>"; } ?> <a href="logout.php"> logout </a> <form id="main-search"> <label for="search-field" id="search-field-label">Search</label> <input type="text" tabindex="1" maxlength="255"id="search-field"/> <input type="image" alt="Search" value="Search" src="images/search.png" id="search-button"/> </form> </div> </div> <div id="zone-bar"> <ul> <li> <a href="#"><span> News <em class="opener-news"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding="5px" /> </em> </span></a> <ul class="Newssublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Reviews <em class="opener-reviews"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding= "5px" /> </em> </span></a> <ul class="reviewssublist"> <li><a href="#">Top 10's</a></li> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li> <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Shop <em class="opener-shop"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding = "5px" /> </em> </span></a> <ul class="shopsublist"> <li><a href="#">Subscribe</a></li> <li><a href="#">Back Issues</a></li> <li><a href="#">Merchandise</a></li> </ul> </li> <li> <a href="#"><span> Competitions <em class="opener-competitions"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="competitionsublist"> <li><a href="#">New Competition</a></li> <li><a href="#">Previous Winners</a></li> </ul> </li> <li> <a href="#"><span> Photos <em class="opener-photos"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="photosublist"> <li><a href="#">Tech! things</a></li> <li><a href="#">Tech! places</a></li> <li><a href="#">Tech! people</a></li> </ul> </li> <li> <a href="#"><span> Video <em class="opener-video"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="videosublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Movies</a></li> <li><a href="#">Music</a></li> <li><a href="#">Television</a></li> <li><a href="#">Comics & Animation</a></li> </ul> </li> <li> <a href="#"><span> About Us <em class="opener-aboutus"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="aboutussublist"> <li><a href="#">What we do</a></li> <li><a href="#">Jobs at tech!</a></li> <li><a href="#">Contact us</a></li> </ul> </li> </div> <div id='main-content'> <div id='feature-content'> <div id='feature-left'> <h1><a href="#">Subscribe</a></h1> <?php if ($set==1) { $conn=odbc_connect('db09,'',''); $sqladd="SELECT AddressID, HouseNumber, Street, Town, Postcode FROM tblAddress WHERE username=$username"; $sqlcard="SELECT CardID, type, mynum FROM tblCard WHERE username=$username"; $sqlcust="SELECT Forename, Surname, [Email Address] FROM tblCustomer WHERE username=$username"; $sqlprod="SELECT ProductID, Name, Cost, Description FROM tblProducts WHERE ProductID=$product"; $rsadd=odbc_exec($conn, $sqladd); $rscard=odbc_exec($conn, $sqlcard); $rscust=odbc_exec($conn, $sqlcust); $rsprod=odbc_exec($conn, $sqlprod); if (odbc_fetch_row($rsadd)) { $housenumber=odbc_result($rsadd,"HouseNumber"); $street=odbc_result($rsadd,"Street"); $town=odbc_result($rsadd,"Town"); $postcode=odbc_result($rsadd,"Postcode"); $addid=odbc_result($rsadd,"AddressIDID"); } if (odbc_fetch_row($rscard)) { $type=odbc_result($rscard,"HouseNumber"); $mynum=odbc_result($rscard,"Street"); $cardid=odbc_result($rsadd,"CardID"); } if (odbc_fetch_row($rscust)) { $forename=odbc_result($rscust,"Forename"); $surname=odbc_result($rscust,"Surname"); } if (odbc_fetch_row($rsprod)) { $name=odbc_result($rsadd,"Name"); $cost=odbc_result($rsadd,"Cost"); $description=odbc_result($rsadd,"Description"); $prodid=odbc_result($rsadd,"ProductID"); } echo "<h1>Order details</h1><br><br><form Action='buy.php' Method='POST'> Name: $forename $surname <br> Delivery Address: $housenumber $street, $town, $postcode -- <a href='address.php'>add/edit address details</a><br> <br> card used: $type ( $mynyum ) -- <a href='card.php'>add/edit card details</a> <br> <br> <h3>item bought<h3><br> Name:$name <br> Cost: $cost <br> Description:$description <br><br><input type='hidden' value=$username name='username1'> <input type='hidden' value=$cardid name='cardid'><input type='hidden' value=$prodid name='prodid'><input type='hidden' value=$addid name='addid'> <input type='hidden' value=$email name='email'> <input type='submit' value='confirm order'> </form>"; } else { echo "You need to be signed in to view this page : please <a href='login1.php'>login</a> or <a href='register1.php'>register</a>"; } ?> </div> <div id='feature-right'> <div class='feature-mini'> <h2><a href='subscribe.html'>Subscribe</a></h2> <br> <a href='#'><h3>Subscribe to tech! magazine</h3> <img src='images/logo.png' width='100%' /></a> <p> Subscribe! 50% of retail price! That is a saving of £30 per year!...<a href='#'>subcribe</a> </p> <br> <img src='line.png' width='100%'> <br> <br> <p> <a href='twitter.php'><img src='twitter.png' width='100%'></a> <br> <p align='center'> <a href='http://twitter.com/techmaguk'> <h4>Follow us!<h4> </a> </p> </p> <br> <img src='line.png' width='100%'> <br> <br> <h2>Feature</h2> <br> <a href='#'><h3>Dell Adamo vs Mac Air</h3> <br> <img src='adamomac.png' width='100%' /></a> <p> The new adamo has been touted as an Air killer... We test them both...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%' /> <br> <br> <a href='#'><h3>Windows 7 revealed</h3> <br> <img src="win7.png" width="100%" /></a> <p> Windows 7 revealed, and we have a play with it!...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%'> <br> <br> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <div id="footer" align="center"> <a href='#'> | contact us | </a> <a href='#'> Accessibility | </a> </div> </div> </body> </html> And buy.php <?php if (isset($_COOKIE['username'])) {$username= $_COOKIE['username']; $set = 1 ; $product=$_POST('product'); setcookie('product', $product, time()+3600); } else { $set=0; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>tech!</title> <LINK href="favicon.ico" rel="favicon" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#zone-bar li em").click(function() { var hidden = $(this).parents("li").children("ul").is(":hidden"); $("#zone-bar>ul>li>ul").hide() $("#zone-bar>ul>li>a").removeClass(); if (hidden) { $(this) .parents("li").children("ul").toggle() .parents("li").children("a").addClass("zoneCur"); } }); }); </script> </head> <body> <div id="page-wrap"> <div id="top-bar"> <a href="index.php"> <img src="images/logo.png" alt="DZone" class="floatleft height="200" width="500" /> </a> <div id="right-side"> <img src="images/usericon.jpg" alt="user icon" /> <?php if ($set==1) { echo "<a href='signedin.php'>$username</a> <a href='cart.php'>Basket</a>"; } else { echo "<a href='login1.php'>login</a> <a href='register1.php'>register</a>"; } ?> <a href="logout.php"> logout </a> <form id="main-search"> <label for="search-field" id="search-field-label">Search</label> <input type="text" tabindex="1" maxlength="255"id="search-field"/> <input type="image" alt="Search" value="Search" src="images/search.png" id="search-button"/> </form> </div> </div> <div id="zone-bar"> <ul> <li> <a href="#"><span> News <em class="opener-news"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding="5px" /> </em> </span></a> <ul class="Newssublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Reviews <em class="opener-reviews"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding= "5px" /> </em> </span></a> <ul class="reviewssublist"> <li><a href="#">Top 10's</a></li> <li><a href="#">Gaming</a></li> <li><a href="#">Audio</a></li> <li><a href="#">Visual</a></li> <li><a href="#">Travel</a></li> <li><a href="#">Computing</a></li> <li><a href="#">Photography</a></li> <li><a href="#">Software</a></li> <li><a href="#">Outdoor</a></li> </ul> </li> <li> <a href="#"><span> Shop <em class="opener-shop"> <img src="images/zonebar-downarrow.png" alt="dropdown" padding = "5px" /> </em> </span></a> <ul class="shopsublist"> <li><a href="#">Subscribe</a></li> <li><a href="#">Back Issues</a></li> <li><a href="#">Merchandise</a></li> </ul> </li> <li> <a href="#"><span> Competitions <em class="opener-competitions"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="competitionsublist"> <li><a href="#">New Competition</a></li> <li><a href="#">Previous Winners</a></li> </ul> </li> <li> <a href="#"><span> Photos <em class="opener-photos"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="photosublist"> <li><a href="#">Tech! things</a></li> <li><a href="#">Tech! places</a></li> <li><a href="#">Tech! people</a></li> </ul> </li> <li> <a href="#"><span> Video <em class="opener-video"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="videosublist"> <li><a href="#">Gaming</a></li> <li><a href="#">Movies</a></li> <li><a href="#">Music</a></li> <li><a href="#">Television</a></li> <li><a href="#">Comics & Animation</a></li> </ul> </li> <li> <a href="#"><span> About Us <em class="opener-aboutus"> <img src="images/zonebar-downarrow.png" alt="dropdown" /> </em> </span></a> <ul class="aboutussublist"> <li><a href="#">What we do</a></li> <li><a href="#">Jobs at tech!</a></li> <li><a href="#">Contact us</a></li> </ul> </li> </div> <div id='main-content'> <div id='feature-content'> <div id='feature-left'> <h1><a href="#">Subscribe</a></h1> <?php $cardid= $_POST['cardid']; $addid= $_POST['addid']; $email= $_POST['email']; $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblOrders (ProductID, username, AddressID, CardID ) VALUES ('$product','$username', '$addid','$cardid')"; if (odbc_exec($conn,$sql)) { echo "thank you for your custom! - a confirmation email has been sent to $email ."; echo " <br> <a href='index.php'>home</a> "; $to= $email; $from= "[email protected]"; $subject= "Tech!"; $message= "Thank you for your purchase, your order will be dispatched soon! "; $headers = "From: " .$from; mail($to, $subject, $message, $headers); } odbc_close($conn); ?> </div> <div id='feature-right'> <div class='feature-mini'> <h2><a href='subscribe.html'>Subscribe</a></h2> <br> <a href='#'><h3>Subscribe to tech! magazine</h3> <img src='images/logo.png' width='100%' /></a> <p> Subscribe! 50% of retail price! That is a saving of £30 per year!...<a href='#'>subcribe</a> </p> <br> <img src='line.png' width='100%'> <br> <br> <p> <a href='twitter.php'><img src='twitter.png' width='100%'></a> <br> <p align='center'> <a href='http://twitter.com/techmaguk'> <h4>Follow us!<h4> </a> </p> </p> <br> <img src='line.png' width='100%'> <br> <br> <h2>Feature</h2> <br> <a href='#'><h3>Dell Adamo vs Mac Air</h3> <br> <img src='adamomac.png' width='100%' /></a> <p> The new adamo has been touted as an Air killer... We test them both...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%' /> <br> <br> <a href='#'><h3>Windows 7 revealed</h3> <br> <img src="win7.png" width="100%" /></a> <p> Windows 7 revealed, and we have a play with it!...<a href='#'>read more</a> </p> <br> <img src='line.png' width='100%'> <br> <br> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <div id="footer" align="center"> <a href='#'> | contact us | </a> <a href='#'> Accessibility | </a> </div> </div> </body> </html> As I said previously any help would be massively appreciated Thank you in advance
-
Hi everyone I have a problem (of which I seem to have lots ...) involving odbc_num_rows(). What I want to do is look up tblCard and see if there is any records with the username equal to that of $username stored in a cookie. Then if there is records show a table to edit those details, if not show a table to add some details. The problem I have is how to do the if statement... my 1st thought was to do if (odbc_num_rows($rs) > 0) then Show table edit card else show add card table. I dont really know if i've missed a step or am using odbc_num_rows incorrectly :S here is my code : <?php $conn=odbc_connect('db09','',''); $sql="SELECT username FROM tblCard WHERE username='$username'"; $rs=odbc_exec($conn, $sql); if ((odbc_num_rows($sql) > 0)) { echo "<H1> add a card! $username </h1><br><div><a href='address.php'>| Add/Edit Address Details | </a> <a href='card.php'> Add/Edit Card Details |</a> <a href='signedin.php'> Edit My Details |</a><br><br><br><a href='card.php'> Add card |</a> <a href='editcard.php'>Edit card</a><br><br><p> --Please note - All fields must be entered-- </p><br><br><form action='addcard.php' method='POST' onsubmit='return validate(this);'><table border = 0><tr><td>Name :</td> <td> <input type='text' name='cname' /></td></tr><tr><td>Number: </td> <td> <input type='text' name='num' /></td></tr><tr><td>Type: </td> <td> <input type='text' name='type' /> </td></tr><tr><td>Expiry date: </td> <td> <input type='text' name='ex' /> </td> <td>Please enter in the form of LL99 9LL</td></tr><tr><td>security code: </td> <td> <input type='text' name='sec' /> </td> <td>3 digits on signature strip</td></tr><tr><td></td></tr><tr><td> <input type='submit' value='Add card'></td> <td> </td></tr></form></table>"; } else { echo "<h1>Edit your Card details, $username</a></h1><br><div><a href='editcard.php'>| Add/Edit Card Details | </a> <a href='card.php'> Add/Edit Card Details |</a> <a href='signedin.php'> Edit My Details |</a><br><br><br><a href='card.php'> Add Card |</a> <a href='editaddress.php'>Edit Address</a><br><br><p>--Please note - All fields must be entered : if you wish to change one line of your address, please enter the full addresss again--</p><br><br><form action='editcard1.php' method='POST' onsubmit='return validate(this);'><table border = 0><tr><td>Name :</td> <td> <input type='text' name='cname' /></td></tr><tr><td>Number: </td> <td> <input type='text' name='num' /></td></tr><tr><td>Type: </td> <td> <input type='text' name='type' /> </td> </tr><tr><td>Expirydate: </td> <td> <input type='text' name='ex' /> </td> <td>Please enter in the form of LL99 9LL</td></tr><tr><td>security code: </td> <td> <input type='text' name='sec' /> </td> <td>3 digits on signature strip</td></tr><tr><td></td></tr><tr><td> <input type='submit' value='Edit card'></td> <td> </td></tr></form></table>"; } ?> Any help would be much appreciated thank you in advance
-
Suppose you don't get a PHP Recommended badge for nothing eh Thank you again Also, I had a google too, and found this : http://sqlserver2000.databases.aspfaq.com/what-are-reserved-access-odbc-and-sql-server-keywords.html It suggests that with Access number is reserved and as thats what my database is in (probably should have mentioned that if I didn't...), that would be why...
-
Thank you lots This worked : $sql = odbc_prepare($conn, "INSERT INTO tblCard (username, name, type, mynum, exp, sec) VALUES ('$username', '$name', '$type', '$num', '$ex', '$sec')" ); Seems like number is a reserved word or something else is playing up ... :S anyway, thank you so so much you've been really patient and spent lots of time helping me It makes learning this all the more easier with people around like you to help Thanks a million
-
I tried that, but it didn't work It still does the same thing :S also the "number" field in the table is just a normal text field as if you store it as a number a card starting in 0 would be shortened and the 0 removed... Your help is amazing PS. Sorry about the slow reply, I'm pretty new here and didn't realise it went onto page 2... :S plonker I am
-
Ok, been through all the options, turns out its the '$num' field that is breaking everything :s and that field is called "number" in the tblCard table and its just saved as a text field. Also, this is an amazing lesson in bug finding ! You've been amazing ! so thank you
-
That outputs : " Thank you for registering a Card! " and it inserts the username into the table.. so no errors... progress it seems...
-
more specifically... [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.Unfortunately there has been a problem - please Try againabcdeCharles1[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. does this help??
-
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. i get this now
-
lol.... still says..."thank you for registering a card" :s
-
thanks again dude, I really appreciate your efforts I did what you said, and it was promising as it came up with "thank you for registering a card" .. BUT.. it didn't actually write anything into the database :S I'm sooo stuck with this ... as I said before, my way worked in other tables in the same database... I'm confuzzled
-
Thank you dude, but I tried that and it didn't output anything. I think I can access the odbc ok, it just won't write to this table for no apparent reason ! ARRGGGGG!