Hello everyone:
I'm trying to learn PHP and I'm using this book to help me "PHP, MYSQL and Apache all in one" They have an example which is listed below. I'm using Dreamweaver to write the PHP and XAMPP to write the db.
I have set up the db connection with Dreamweaver.
My db is located in the default folder under XAMPP.
I get this error:
Incorrect database name 'storefront_db '
[PHP] <?php
session_start() ;
//connect to database
$conn = mysql_connect(" localhost", "nomad", "nomad") or die(mysql_error ());
mysql_select_db ("storefront _db ",$conn) or die(mysql_error ());
if ( POST[sel_item_id] != "") {
//validate item and get title and price
$get_iteminfo = "select item_title from store_items where id = POST[sel_item_id]";
$get_iteminfo_r es = mysql_query($ge t_iteminfo) or die(mysql_error ());
if (mysql_num_rows ($get_iteminfo_ res) < 1) {
//invalid id, send away
header("Locatio n: seestore.php");
exit;
} else {
//get info
$item_title = mysql_result($g et_iteminfo_res ,0,'item_title' );
//add info to cart table
$addtocart = "insert into store_shoppertr ack values ('', '$PHPSESSID', ' POST[sel_item_id]', ' POST[sel_item_qty]', ' POST[sel_item_size]', ' POST[sel_item_color]', now())";
mysql_query($ad dtocart);
//redirect to showcart page
header("Locatio n: showcart.php");
exit;
}
} else {
//send them somewhere else
header("Locatio n: seestore.php");
exit;
}
?>
[/PHP]
Any help would be great
nomad
I'm trying to learn PHP and I'm using this book to help me "PHP, MYSQL and Apache all in one" They have an example which is listed below. I'm using Dreamweaver to write the PHP and XAMPP to write the db.
I have set up the db connection with Dreamweaver.
My db is located in the default folder under XAMPP.
I get this error:
Incorrect database name 'storefront_db '
[PHP] <?php
session_start() ;
//connect to database
$conn = mysql_connect(" localhost", "nomad", "nomad") or die(mysql_error ());
mysql_select_db ("storefront _db ",$conn) or die(mysql_error ());
if ( POST[sel_item_id] != "") {
//validate item and get title and price
$get_iteminfo = "select item_title from store_items where id = POST[sel_item_id]";
$get_iteminfo_r es = mysql_query($ge t_iteminfo) or die(mysql_error ());
if (mysql_num_rows ($get_iteminfo_ res) < 1) {
//invalid id, send away
header("Locatio n: seestore.php");
exit;
} else {
//get info
$item_title = mysql_result($g et_iteminfo_res ,0,'item_title' );
//add info to cart table
$addtocart = "insert into store_shoppertr ack values ('', '$PHPSESSID', ' POST[sel_item_id]', ' POST[sel_item_qty]', ' POST[sel_item_size]', ' POST[sel_item_color]', now())";
mysql_query($ad dtocart);
//redirect to showcart page
header("Locatio n: showcart.php");
exit;
}
} else {
//send them somewhere else
header("Locatio n: seestore.php");
exit;
}
?>
[/PHP]
Any help would be great
nomad
Comment