Welcome! Log In Create A New Profile

Advanced

Lesson 6

Posted by MicheleC 
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
Lesson 6
August 10, 2010 10:13AM
All tasks in Lesson 6 complete.

No problems - my first experience with mySql - nice!.

Would like to recommend TOAD for MySql 4.6 freeware.

I have been using TOAD for years on Oracle databases - it works just as well on MySql - makes life alot easier for viewing your changes and updates. Would be glad to help anyone getting started with it.

Would like to know from an industry perspective if there are any particular areas of PHP that should be focused on for further investigation at this point.
Re: Lesson 6
August 15, 2010 01:48PM
Finshed this a while ago but forgot to post... mostly done without problem, only had a problem with connecting... this is what i found to help $link_id = mysql_connect("localhost", "root","password" )... the "password" being whatever you have chosen to set it as...
Re: Lesson 6
August 15, 2010 02:02PM
Mac

i just thought i would ask when will we get the details of the prac/project?
Re: Lesson 6
August 16, 2010 10:57AM
Hi Mac,

I am also curious as to what is happening with the first assignment, I am catching up on the modules as I fell behind but I am concerned as to what the first assignment is that we have to hand in and when the due date is as in the MyUNISA portal it says that the first assignments need to be handed in by the 20th of August...Please advise?
avatar
Mac
Re: Lesson 6
August 16, 2010 10:58AM
Once I see quite a few people have worked through the manual. But not later than early September.
Re: Lesson 6
August 16, 2010 11:03AM
Awesome, thank you so much. I was concerned that I will fall too far behind. I will keep you updates as to where I am with the modules.
Re: Lesson 6
August 21, 2010 02:16PM
Really struggling on this one, my code is as follows:
Language: PHP
<?php $title = "Database Connection" ; include ("header.php") ; //This code adds a connection to the MySQL server $link = mysql_connect("localhost","alessio","password") ;   //This code displays a list of available databases echo "<h3>The following databases are available:</h3>" ; $result = mysql_list_dbs() ; while ($row = mysql_fetch_row($result)) { echo $row[0], "<p>" ; } //This code selects a db and lists the tables vontained within echo "<h3>The following tables are in bookstore_db:</h3>" ; mysql_select_db("bookstore_db") ; $result = mysql_list_tables("bookstore_db") ; while ($row = mysql_fetch_row($result)) { echo $row[0], "<p>" ; include ("footer.php") ; ?>

My screen show up blank. I've imported bookstore_db and can get the page to show up only if I take out these two lines of code:
Language: PHP
while ($row = mysql_fetch_row($result)) { echo $row[0], "<p>" ;

which then doesn't list the tables. Any ideas?
Re: Lesson 6
August 21, 2010 04:46PM
yuo haven't closed the while statement...

Do this

while ($row = mysql_fetch_row($result)) {
echo $row[0], "<p>" ; }
Re: Lesson 6
August 25, 2010 12:25PM
Argh! Always the little things!

Thanks.
avatar
Mac
Re: Lesson 6
August 25, 2010 03:26PM
Just google for php error reporting - there are many ways to turn it on (either in php.ini file or in your code) so that you get feedback on where the problem lies as opposed to a blank screen....

It does take a bit of getting used to what the error means but generally it pinpoints the line. Sometimes it is the line before, but you would be in the general area of the mistake, which 90% of the time is a parse error, pointing at a typo.
avatar Re: Lesson 6
August 31, 2010 12:41PM
how do i import the bookstore database? confused smiley

>>>
The One that owns The Technology rulez the world!
Re: Lesson 6
August 31, 2010 02:11PM
@theSinthesizer

What you wanna do is the following.
if you have phpmyadmin installed and working:
create a new database by entering its new name in the field provided.
this will automatically select that database.
Now at the top you will see a few options, select import.
browse for the sql dump file and viola. database imported.

If you are on windows:
open up cmd prompt
change directory to where the importme.sql file is sitting
execute the mysql command - with or without connection params ie: mysql -uadmin -ppassword
this should drop you into your database
now create a database with
#create database db-name character set utf8 collate utf8_general_ci;
database created.
Now we need permissions
#grant all on db-name.* to user@'%' identified by 'password';
and
#grant all on db-name.* to user@'localhost' identified by 'password';
now change to that database
#use db-name
now run
#source importme.sql

and you are done.

Hope this helps.
avatar Re: Lesson 6
August 31, 2010 02:42PM
@shellshock,

sup dude?! Tried that but can only import .sql files can't import .myd, .myi or frm.

Any further suggestionz?

>>>
The One that owns The Technology rulez the world!
Re: Lesson 6
August 31, 2010 02:59PM
Those are your actual database files - should`nt really play too much with these.

Its a little tricky for me to tell you where exactly they should go in windows as I am using linux and the path for those files are /var/lib/mysql/databasename

however, If you are using Xampp it should be something like this

C:\xampp\mysql\data\databasename

if the database does not exist create it using the mysql command set. then stop the database and copy your .myd, .myi or frm files to the C:\xampp\mysql\data\databasename location.

Start your database.

Let me know.
avatar Re: Lesson 6
August 31, 2010 04:06PM
shellshock

ur a legend dude!

Tha! smile

>>>
The One that owns The Technology rulez the world!
Re: Lesson 6
September 01, 2010 03:22PM
Mac,

Tried turning on error reporting both through my code & my php.ini file, still getting blank screen. Using ideone.com though, which helps a lot.
avatar
Mac
Re: Lesson 6
September 02, 2010 07:33AM
Changes to php.ini (xampp\php\php.ini) requires a restart of Apache.

display_errors = On
error_reporting = E_ALL & ~E_NOTICE

There are several references to the above - some preceded by a ; which menas it is a comment and not interpreted. Make sue you are looking at the clear lines.

error.log, located in the xampp\apache\logs folder; may be helpful at times.
Re: Lesson 6
September 02, 2010 11:56AM
Great, came right thanks!

Running MAMP, so had to jump through a few hoops to be able to edit my php.ini file, which is written into Snow Leopard, but once again, Google to the rescue!
avatar Re: Lesson 6
September 02, 2010 04:34PM
i'm on task 6a-1....

the code connects and outputs the database and table names, but i get a message: "Deprecated: Function mysql_list_tables() is deprecated".

I went to php.net/mysql_list_tables and it said I should use "$result = mysql_query("database name"winking smiley" instead.

Did that, but get message that this is boolean and "mysql_fetch_row()" expects a resource. This means that it expects a result pointer.

Y is there this clash between the manual and the result?

>>>
The One that owns The Technology rulez the world!
Re: Lesson 6
September 02, 2010 08:42PM
Jippy. I'm finally done with lesson 6. For some strange reason had some difficulty getting to know phpmyadmin but as soon as I got the hang of it I couldn't stop playing in it!
Good luck to all...
avatar
Mac
Re: Lesson 6
September 03, 2010 07:22AM
Remember that the manual is PHP4. The textbook is PHP5. I want you to understand that as you move from 4 to 5 what the changes are, becasue soon it will be 6, menaing you have an understanding of changes that takes place between versions. Hence you need to update depreciated (4) built-in functions.
Re: Lesson 6
September 03, 2010 01:50PM
Lesson 6 done & dusted!
avatar Re: Lesson 6
September 03, 2010 05:38PM
mac i changed the
Language: PHP
$result = mysql_list_tables("bookstore_db")
to
Language: PHP
$result = mysql_query("SELECT * FROM bookstore_db");
but i'm getting an error "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given".

Please advise.

>>>
The One that owns The Technology rulez the world!
avatar
Mac
Re: Lesson 6
September 05, 2010 03:38PM
Give all the code...
avatar Re: Lesson 6
September 06, 2010 04:54PM
Language: PHP
<?php $title = "Database Connection"; include "header.php"; //This code creates a connection to the MySQL server $link_id = mysql_connect("localhost", "root", ""); if($link_id) echo "Connected to the MySQL server successfully<br>"; else die ("Connection to the MySQL server unsuccessful");   //This code displays a list of available databases echo "<h3>The following databases are available</h3>"; $result = mysql_list_dbs(); while ($row = mysql_fetch_row($result)) { echo $row[0], "<p>"; } //This code selects a db and lists the tables contained within echo "<h3>The following tables are in bookstore</h3>"; mysql_select_db("bookstore_db"); //$result = mysql_list_tables("bookstore_db"); $result = mysql_query("SELECT * FROM bookstore_db"); while ($row = mysql_fetch_row($result)) { echo $row[0], "<p>"; } include "footer.php";   ?>

>>>
The One that owns The Technology rulez the world!
Re: Lesson 6
September 07, 2010 07:19AM
@theSinthesizer,

Your almost right, your syntex in the mysql_query is just slightly wrong.

Try the following instead:
Language: PHP
$result = mysql_query("SHOW TABLES FROM bookstore_db");
Re: Lesson 6
September 07, 2010 06:40PM
thSinthesizer,

I used this code :
Language: PHP
$result = mysql_list_tables("bookstore_db") ;
and it worked without a problem.
Re: Lesson 6
September 07, 2010 10:00PM
Completed Lesson 6 two Weeks ago forgot to post sorry, I did not have many problems with it. Now onward with the pracspinning smiley sticking its tongue out
avatar Re: Lesson 6
September 09, 2010 11:18AM
Thanks rogerdurbs, your code worked.

Also thank you Alessio but I tried that code and it didn't worked. Thanks anyway dude!

Finished lesson 6 a while back just didn't post. cool smiley

>>>
The One that owns The Technology rulez the world!
Re: Lesson 6
September 14, 2010 11:22AM
Done With Lesson six last night.
Now Im going to sink my teeth into the Practical.
Good luck on that everyone.
Remember to polish polish polish.
Sorry, only registered users may post in this forum.

Click here to login