Reply
no data gets entered to my database
Old 07-12-2005, 09:03 PM no data gets entered to my database
hiptobesquare's Avatar
Extreme Talker

Posts: 162
Location: London UK
does anyboy know how to make this work please?
i dont get an error message but no data gets entered into my database. i looked at the hp&mysq tutorial and copied it more or less exactly except my variables havnt come from a form on the previous page. they are derived from $_SESSION veriables generated over a collection of pages. Help much appreciated.


PHP Code:
<!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=iso-8859-1" />
<meta name="keywords" content="doorstop" />
<title>The Doorstop</title>
<style type="text/css">
        @import "doorstop.css";
</style>
</head>
<body> 
        <?php
session_start
();
$user="root";
$host="localhost";
$password="";
$database="doorstop";

$connection mysql_connect($host,$user,$password)   or die ("couldn't connect to server");
$db mysql_select_db("doorstop")                    or die ("coudn't locate the database");
$query="SELECT * FROM cart_items";
$result=mysql_query($query);


$customer_id="$_SESSION[customer_id]";
$system_name="$_SESSION[sysname]";
$number_of_doors="$_SESSION[numdoor]";
$hinged_or_sliding="$_SESSION[hingeslid]";
$door_size="$_SESSION[doorsize]x$_SESSION[apheight]";
$overall_aperture="$_SESSION[apwidth]x$_SESSION[apheight]";
$door_colours="$_SESSION[door1glass],$_SESSION[door2glass],$_SESSION[door3glass],$_SESSION[door4glass]$_SESSION[door5glass]";
$bars="$_SESSION[door1bars],$_SESSION[door2bars]";
$total_price="222";



$connection mysql_connect($host,$user,$password)   or die ("couldn't connect to server");
$db mysql_select_db("doorstop")                    or die ("coudn't locate the database");

$query "INSERT INTO cart_items VALUES ('$customer_id','$system_name','$number_of_doors','$hinged_or_sliding','$door_size',
                                       '$overall_aperture','$door_colours','$bars')"
;
mysql_query($query);

mysql_close();

$num=mysql_numrows($result);

echo 
"<b><center>Database Output</center></b><br><br>";

$i=0;
while (
$i $num) {
    
$customer_id=mysql_result($result,$i,"customer_id");
$system_name=mysql_result($result,$i,"system_name");
$number_of_doors=mysql_result($result,$i,"number_of_doors");
$hinged_or_sliding=mysql_result($result,$i,"hinged_or_sliding");
$door_size=mysql_result($result,$i,"door_size");
$overall_aperture=mysql_result($result,$i,"overall_aperture");
$door_colours=mysql_result($result,$i,"door_colours");
$bars=mysql_result($result,$i,"bars");
$total_price=mysql_result($result,$i,"total_price");


echo 
"<b>
Customer ID: $customer_id</b><br>
System Name: $system_name<br>
Number of Doors: $number_of_doors<br>
Hinged or Sliding: $hinged_or_sliding<br>
Door Size: $door_size<br>
Overall Aperture: $overall_aperture<br>
Door Colours: $door_colours<br>
bars: $bars<br>
Total Price: $total_price
<br><hr><br>"
;

$i++;
}

  
?>
</body>
</html>
hiptobesquare is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-12-2005, 09:09 PM
hiptobesquare's Avatar
Extreme Talker

Posts: 162
Location: London UK
this is the tutorial i follwed. Quite how anyone can learn enough about php and mysql to answer these posts is beyond me.

http://www.freewebmasterhelp.com/tutorials/phpmysql

thankyou
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 07-13-2005, 03:27 AM
Enigmatic's Avatar
Registered User

Posts: 86
Location: No Fixed Abode
Currently working through the code but whilst I'm reading it, what is it your looking to do and perhaps we can find a better way.
Enigmatic is offline
Reply With Quote
View Public Profile
 
Old 07-13-2005, 04:39 AM
hiptobesquare's Avatar
Extreme Talker

Posts: 162
Location: London UK
What i want is to have an "add to cart button" on the previous page which will add to my cart_items table the details received from the user. If you know of a better way to do it than what ive posted above that wouls be fantastic.
over a series of pages i get info from the user as to what colour, size, quantity, type etc of wardrobe doors they want. the stage i am at now is the add to cart page. I looked into buying a package for this but dont reallyunderstand how id set it it up with what i already have and get the impression you have to follow quite a fixed design of site.
On the page previous to this one the user clicks an add to cart button and is brought to the page printed above. thinking about it though im wondering if it would be better to make the showcart.php (above) an include statement and include it each time someone add something to the cart. As it is i think im burrying myself as the user will click add to cart more than once to add their interior and lights so the page showcart.pho will be obsolete for those id imagine.
Thanks for looking
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 07-13-2005, 05:29 AM
hiptobesquare's Avatar
Extreme Talker

Posts: 162
Location: London UK
what would be ideal is if i could enter mysql queries with my add to cart button. Is that possible? then i could have several addtocart buttons each containg different insert into cart_items information and when one is clicked i can include the showcart.php script so they can see what has been entered
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to no data gets entered to my database
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13871 seconds with 12 queries