Welcome! Log In Create A New Profile

Advanced

Topic 6A

Posted by mauritz 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Topic 6A
August 03, 2009 09:03PM
Im not done with this one yet because I realised that the hand manual teaches us the basic mysql commands before it tells us to import the bookstore db into mysql. I am not sure if I misread the instructions somewhere, but for those of you who must still do this, remember to first import the databases into mysql before you go on with topic 6A as the task revolves around the bookstore_db database. Another idea would be to explain how to change the mysql username and password so that we can get use to using mysql_connect("localhost","username","password"winking smiley - I apologise if it does open later in the chapter. I already changed my mysql username and password by going through the apache control panel, but I cannot find the txt files to import the bookstore_db files. For the tutorial I am using one of the default databases to complete the task.

For those of you who want to change your mysql username and password, do the following: (assuming your running xammp under windows xp, should be the same under other os's)

Goto http://localhost/security/xamppsecurity.php and change the mysql password.

new connection syntax:

$link = mysql_connect("localhost","root","newpassword"winking smiley


REMEMBER THAT FROM NOW ON IN THIS TASKS TO USE THE NEW PASSWORD OTHERWISE YOU WILL NOT BE ABLE TO CONNECT TO THE DB. THIS ALSO COUNTS FOR PHPMYADMIN!!!!
Re: Topic 6A
August 03, 2009 09:36PM
Good, google really is our friend smiling smiley

For those of you struggling with the same issue, you will see that there is a folder on the examples CD called bookstore_db

Copy the folder and its content to C:\xammp\mysql\data (providing you installed it on XP at its default directory) - Check under the xammp installation folder for mysql -> DATA -> and copy it in there!
Re: Topic 6A
August 03, 2009 10:30PM
Mmmm errors errors errors smiling smiley

For those of you who struggle with Task 6A-2 (you retype the code 50 times but it still gives you the following error:

Warning: mysql_list_fields() [function.mysql-list-fields]: Unable to save MySQL query result in C:\xampp\htdocs\studentdocs\Lesson6\myfiles\sample.php on line 7

Do not stress, because for once, its not your fault smiling smiley After almost a hour i did a google search and saw that it was a db related error. I went into Phpmyadmin and clicked on the subject table under bookstore_db and it gave me the following error:

#1034 - Incorrect key file for table 'subject'; try to repair it

I then tried to repair the corrupted table but unfortunetaly only got:

Table Op Msg_type Msg_text
bookstore_db.subject repair Error Incorrect key file for table 'subject'; try to rep...
bookstore_db.subject repair error Corrupt


Mac, could you please maybe email me a fresh copy of the files or maybe there is an alternative solution to my problem, this obviously is a show stopper seeing that the rest of topic 6 is based bookstore_db.

Sorry for the inconvinience!
avatar
Mac
Re: Topic 6A
August 04, 2009 07:45AM
You can download the files from @#$%&/cd1.zip - but the files as on the CD is 100% correct, so this copy is the same as on the CD the same as on your CD???
...replace those funny letter with the the course website address....

Yes, you copy the files to a folder bookstore_db.

Then, in phpmyadmin, on the homepage, click privileges, then add a new user.
Complete the fields as follows, eg -> tom, localhost, tom1, tom1 (username, host, password, retype)
Under database for user, leave on none.
Check all the privileges (not a good idea but that does not matter now) and Go.

Go to the mysql database, and the db table.
Insert a new entry, using tom, localhost and bookstore_db, and tick all privileges.On the phpmyadmin homepage, reload the privileges.
Use this info in your connection to connect.

Language: PHP
$link = mysql_connect("localhost","tom","tom1"); mysql_select_db("bookstore_db");
Re: Topic 6A
August 04, 2009 10:11PM
I downloaded a new copy but it still comes back as a corrupt db. It may be something on my installation, but I have no idea what the problem may be.

Mac, would you be able to send me the individual fields ect for the the bookstore_db database?
avatar
Mac
Re: Topic 6A
August 05, 2009 08:43AM
In phpmyadmin's structure view, select all (at the bottom of the table, and run a repair; optimize etc). Definitely has nothing to do with the code or the db as provided

else copy this below into the sql tab and run

CREATE TABLE IF NOT EXISTS `subject` (
`Sub_id` varchar(20) NOT NULL default '',
`Subject` varchar(50) default NULL,
PRIMARY KEY (`Sub_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `subject`
--

INSERT INTO `subject` (`Sub_id`, `Subject`) VALUES
('sub01', 'Theater'),
('sub02', 'Computing'),
('sub03', 'Science'),
('sub04', 'Fiction'),
('sub05', 'Non-fiction');

-- --------------------------------------------------------

--
-- Table structure for table `titles`
--

CREATE TABLE IF NOT EXISTS `titles` (
`ISBN` varchar(10) NOT NULL default '',
`Title` varchar(60) default NULL,
`Price` varchar(10) default NULL,
`Pub_date` varchar(12) default NULL,
`Auth_id` varchar(10) default NULL,
`Sub_id` varchar(20) default NULL,
PRIMARY KEY (`ISBN`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `titles`
--

INSERT INTO `titles` (`ISBN`, `Title`, `Price`, `Pub_date`, `Auth_id`, `Sub_id`) VALUES
('0101452', 'Romeo and Juliet', '$6.99', '03/23/1988', 'auth01', 'sub01'),
('0123499', 'Hamlet', '$3.99', '04/06/1993', 'auth01', 'sub01'),
('0354977', 'XML:An Introduction', '$47.00', '08/29/1999', 'auth02', 'sub02'),
('077961', 'NetObjects Fusion 5.0: Advanced', '$47.00', '09/16/2000', 'auth50', 'sub02'),
('3234AA', 'HTML Level 2', '$47.00', '03/15/1999', 'auth16', 'sub02'),
('1233878', 'Exobiology: An Introduction', '$45.00', '11/11/1999', 'auth27', 'sub03'),
('6784290', 'Viewing Quasars with the Naked Eye', '$60.00', '07/30/1998', 'auth27', 'sub03'),
('23452A45', 'War and Peace', '$12.99', '02/22/1995', 'auth11', 'sub04'),
('234DHJ2', 'Sentimental Education', '$11.00', '06/08/1987', 'auth12', 'sub04'),
('34693AC', 'Home Repair Made Difficult', '$19.99', '08/23/1979', 'auth23', 'sub05'),
('23267D', 'Bob''s Guide to Cool Music', '$6.99', '05/06/1982', 'auth22', 'sub05'),
('5464BBA', 'Office 2000', '$25.00', '08/20/1999', 'auth02', 'sub02');
Re: Topic 6A
August 06, 2009 09:31PM
Strangely enough, when I imported the sql as above it works smiling smiley YAY!!! Now lets finish this !
Re: Topic 6A
August 09, 2009 07:57PM
All done smiling smiley
Anonymous User
Re: Topic 6A
August 19, 2009 03:49PM
I'm getting the same error mauritz described. Copied the code above (posted by mac) into the sql tab, but am still getting the following error message in phpmyadmin:

Error
SQL query:

--
-- Dumping data for table `subject`
--
INSERT INTO `subject` ( `Sub_id` , `Subject` )
VALUES (

'sub01', 'Theater'
), (
'sub02', 'Computing'
), (
'sub03', 'Science'
), (
'sub04', 'Fiction'
), (
'sub05', 'Non-fiction'
);



MySQL said:

#1034 - Incorrect key file for table 'subject'; try to repair it

Is there anything else that I can try?
avatar
Mac
Re: Topic 6A
August 20, 2009 08:48AM
Drop all the tables, then try again.
Anonymous User
Re: Topic 6A
August 20, 2009 02:03PM
When I tried to drop the tables, I received an error message. I ended up emptying the tables, just to see what would happen (fortunately I remembered that we have the file on cd, so it didn't matter, even if I messed up somehow smile ). I then received a message saying that I needed to repair the tables, which I did. The #1034 error message was gone, but then I had empty tables! So I copied the code above, inserted it into the SQL tab and it worked perfectly. This might have been the long way round, but at least it works properly now...

Thanks mac.

Topic 6A complete.

Apply Your Knowledge 6-1 is easier than it looks...
fcb
Re: Topic 6A
August 27, 2009 12:16PM
Done. Managing databases is where the real fun begins - PHP+MySQL just makes it so much easier thumbs up smiley
Re: Topic 6A
August 28, 2009 07:36PM
Hey , Getting behind again , but finished 6A YEAH !!!!

smoking smiley When all else fails , read instructions grinning smiley
smiling smiley Reading is a course on it's own ! smiling smiley
avatar Re: Topic 6A
August 31, 2009 10:30PM
Done,

Help for those of you who still need to do this:

You can avoid all the issues described above by using a db already on the server, such as "information_schema". See what is on your MySQL server when you get to point 5 of Task 6A-1. Then replace "bookstore_db" with "information_schema", (or the db of your choice), in the code listed under point 6 on page 72, and see the tables of the db listed (similar to that shown under point 7).

"information_schema" contains lots of tables and viewing is made easier if you also replace the 2nd to last line of code listed under point 6 with this:
Language: PHP
echo $row[0], "\n <p>";

But, I also wanted to see the correct stuff working, so after also getting the corrupted db table results inside PHPMYADMIN (for bookstore_db), I dropped the tables as suggested and ran the scripts as given by Mac above. All ran as it should from there.

Remember to also do as Mac suggests above re. creating the user "tom" in PHPMYADMIN, and then including the correct parameters in the :"mysql_connect()" command in your code.
Re: Topic 6A
September 01, 2009 08:05PM
i have done exactly that

smoking smiley When all else fails , read instructions grinning smiley
smiling smiley Reading is a course on it's own ! smiling smiley
Re: Topic 6A
September 03, 2009 01:07PM
Thanks Maritz, finished 6a-1. Am really enjoying this section.
Re: Topic 6A
September 03, 2009 01:11PM
am using 2004 edition of prescribed book as I borrowed from a friend the tut letter says to use version 2005. Mac will that be a problem
Re: Topic 6A
September 03, 2009 04:23PM
This topic is gr8. Am done with all of 6a.
avatar
Mac
Re: Topic 6A
September 03, 2009 09:28PM
You'll just have to figure out which sections of the manual corresponds with which sections of the handbook, as set out in the tut. Just read the whole book smiling smiley
Saadia Wrote:
-------------------------------------------------------
> am using 2004 edition of prescribed book as I
> borrowed from a friend the tut letter says to use
> version 2005. Mac will that be a problem
Re: Topic 6A
September 07, 2009 09:02PM
Nooit Mac

I was worried about setting up on the mac, cause now I really battle to get things to work.
I can't find phpMyAdmin, I can see the bookstore_db folder. When I list the available databases it does return two databases. but of course not the bookstore one.

There is no mysql\data folder within my xamp folder.

Should I rather switch to a pc and start all over?
sad smiley
avatar
Mac
Re: Topic 6A
September 08, 2009 09:11AM
Never done it on a mac - but there is a specific xampp version for a mac - download here
Re: Topic 6A
September 17, 2009 07:27PM
Wow did I have a tough time getting things working.
I finally did come right on the mac, but what a learning curve.

For future mac using students I will advise to download MAMP... Macingtosh Appache MySql PHP.
Notice only one p at the end, its got no support for perl.

It works fine and gets the same job done. XAMPP is great and works fine on my Imac at home, but at work The G5 seems to have serious permission issues. So MAMP was the awnser.
Its even got a cool widget feature, really nice.

Blah blah blah, bottom line is I got this topic done.

Thanx Mac
I love this shit.
You get these problems, and you sweat it out and then you dance... until the next problem.
avatar
Mac
Re: Topic 6A
September 18, 2009 07:25AM
> You get these problems, and you sweat it out and then you dance... until the next problem.

Precisely. It is the only way to learn. And why I use the PHP4 manual and the PHP5 textbook.
avatar Re: Topic 6A
September 18, 2009 03:25PM
Then, in phpmyadmin, on the homepage, click privileges, then add a new user.
Complete the fields as follows, eg -> tom, localhost, tom1, tom1 (username, host, password, retype)
Under database for user, leave on none.
Check all the privileges (not a good idea but that does not matter now) and Go.

Go to the mysql database, and the db table.
Insert a new entry, using tom, localhost and bookstore_db, and tick all privileges.On the phpmyadmin homepage, reload the privileges.
Use this info in your connection to connect.

$link = mysql_connect("localhost","tom","tom1"winking smiley;
mysql_select_db("bookstore_db"winking smiley;


Thanks Mac... This is exactly what i needed!!! Voila i can now see the db...
Re: Topic 6A
September 22, 2009 08:00AM
Hi

Thanks for everyone inputs helped alot. Finished.
avatar Re: Topic 6A
September 22, 2009 01:06PM
Done... now this is the real deal section.... it's the stuff that project dreams are made of.... Project completion is now well within view.... I wonder however if PHP 4 or 5 does support the very ubiquitous MSAccess Database... if so... how does one link it.....?
Re: Topic 6A
October 01, 2009 01:27PM
Today is a great day for me.

I created my first not local but live database on the web and connected to it.
Its like I lost my virginity

I'm a developer today!
avatar
Mac
Re: Topic 6A
October 01, 2009 05:57PM
Liberating hey smiling smiley
Re: Topic 6A
October 04, 2009 09:06PM
Hi

Do i need to open MySQL to view the database or do just call the the exsiting database ? For the exercise the database already exist but for our assignment do we create the table "course", "course_student", "student". if so where do we create it? MySql is opening up as an application is there something wrong with my installation?

Rgds
Radhika
avatar
Mac
Re: Topic 6A
October 05, 2009 04:11PM
Go to localhost, click on phpmyadmin. Create a new database, name it registration.

Go to the database from the left menu (it should redirect you there automatically after you have created the datbase) and paste the db structure, as provided in the prac documentation, in the space provided.

On the phpmyadon frontpage (click the little house icon), click privileges, then add a new user.
Username - e.g. test
Host= localhost
password = e.g. mypaasword. Retype the password.
Click check all under global privileges to give all rights for this user.
Click Go button to save

Go to the mysql database (left menu), then click onthe db table.Click on insert. Use the information you have created above e.g.
host=localhost
db= registration
user=test
Click all the tick boxes for now - giving this user rights to everything.
Click Go button to save

On the phpmyadon frontpage (click the little house icon), click reload privileges.

Use the information above to connect to your datbase.
Sorry, only registered users may post in this forum.

Click here to login