Accessing data from a ready-made database

Hey All.

I am a total newbie when it comes to php and mySQL, and require some help with creating a database for a shopping cart.

I’m following this: http://www.phpwebcommerce.com/shopping-cart-database-design.php tutorial, but can’t figure out how to open the db.sql file it links to.

I’m working in xxamp.

Thank you in advance.

LeeshaH

You need it import them:
If you have phpMyAdmin just import them.

If you don’t then you can use mysql command:
mysql -umyusername -p mydatabasename < mysqlfile.sql

Hey Adam. Thanks for your help. I got it.

I continued with the tutorial, finished making the database in Xampp, phpMyadmin and downloaded the source code from the site.
http://www.phpwebcommerce.com/shopping-cart-source-code.php

I don’t understand this next part:

Extract the zip file ( ex. to C:\\Webroot\\plaincart )
Create a new MySQL database ( ex. 'plaincart' );
Create the tables using the SQL in plaincart.sql. On windows just open a command prompt window ( Start &gt; Run &gt; cmd.exe ) and go to the directory where you unzip the files then type this :

C:\\mysql\\bin\\mysql plaincart &lt; plaincart.sql

I'm assuming you install mysql in C:\\MySQL
Modify the database connection settings in library/config.php.

And I also don’t know how to view the active shopping cart (the demo site), like http://www.phpwebcommerce.com/plaincart/index.php Should I write another php file and somehow link all those source code given. Please help!

Thank you so much.

LeeshaH

I have never used mysql on Windows (I do not know where is it installed by default), but you have to know that MySQL and mysql refers to two different staff. mysql (all lowercase - http://dev.mysql.com/doc/refman/5.5/en/mysql.html) is a MySQL command line tool and MySQL is a database system.

The following steps can be done by phpMyAdmin

Create a new MySQL database ( ex. ‘plaincart’ );
Create the tables using the SQL in plaincart.sql. On windows just open a command prompt window ( Start > Run > cmd.exe ) and go to the directory where you unzip the files then type this:

Also unless you have installed it php isn’t present on IIS.

Hey guys.

I’m still not getting this… :frowning:

I tried running this:

C:\Users\User\Desktop\XAMP\xampp\mysql\bin>plaincart.sql

by typing it into the SQL section of phpMyAdmin, but when I press go, I get an error

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘C:\Users\User\Desktop\XAMP\xampp\mysql\bin>plaincart.sql’ at line 1
. I don’t know what I am doing wrong.

This is the folder structure to get to the plaincart.sql file:
Desktop>Xamp>xampp>mysql>bin>plaincart.sql

I’d really appreciate some help.

LeeshaH

Forget my earlier comment, I missed that you’re using xampp.

From what I see in your posts you need to 1) create a mysql database then 2) import the sql file (which means have the database system execute the sql statements contained in the sql file). In phpmyadmin you use the Import tab to do this, from a command line you run the mysql command line program as described in an earlier post.

Dear Doug

I tried what you suggested and got this:

Error

SQL query:

CREATE TABLE cart (
ct_id int( 10 ) unsigned NOT NULL AUTO_INCREMENT ,
pd_id int( 10 ) unsigned NOT NULL default ‘0’,
ct_qty mediumint( 8 ) unsigned NOT NULL default ‘1’,
ct_session_id char( 32 ) NOT NULL default ‘’,
ct_date datetime NOT NULL default ‘0000-00-00 00:00:00’,
PRIMARY KEY ( ct_id ) ,
KEY pd_id ( pd_id ) ,
KEY ct_session_id ( ct_session_id )
) TYPE = MYISAM AUTO_INCREMENT =58;

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘TYPE=MyISAM AUTO_INCREMENT=58’ at line 10

I feel like quiting. And I bet you’re frustrated as well.

I really appreciate your help.

it’s complaining about TYPE=MyISAM

that should be ENGINE=MYISAM

your script is out of date :slight_smile:

Wow… Thanks r937
I’ll give that a try :slight_smile: