Welcome! Log In Create A New Profile


Topic 6A-1

Posted by Dennis 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
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-1
September 26, 2006 08:04PM
Topic Completed
Re: Topic 6A-1
September 28, 2006 10:06AM
Topic Completed
Re: Topic 6A-1
October 06, 2006 02:33PM
I get everything to run, but I cannot see bookstore_db. All I see is mysql and test. Where can I get definitions of the tables for bookstore_db?

avatar Re: Topic 6A-1
October 10, 2006 09:22PM
all done
Re: Topic 6A-1
October 11, 2006 07:29AM
Topic completed
Re: Topic 6A-1
October 12, 2006 09:26PM
This topic is giving me (another!) headache. I have copied the bookstore_db into the FoxServ\mysql\data\ directory. I can list the 3 databases - mysql, test and bookstore_db - but cannot list the tables in bookstore_db. It seems (from www.php.net) that the mysql_list_tables command is now obsolete so I have been trying to do as they suggest and use mysql_query() instead. My code is copied below but I am getting this error - DB Error, could not list tables MySQL Error: Access denied for user: '@localhost' to database 'bookstore_db'. Any ideas? Is there a password for bookstore_db that we need to pass across, or is this a spurious message?

And, by the way, what is the URL for the Semester 1 forum - it keeps disappearing from the list...?

My code:


$title = "Database Connection";
include("header.php"winking smiley;

//This code creates a connection to the MySQL server
$link_id = mysql_connect();
if($link_id) echo "Connected to the MySQL server successfully<br>";
else die ("Connection to the MySQL server was unsuccessful"winking smiley;

//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_db:</h3>";
mysql_select_db("bookstore_db"winking smiley;

$sql = "SHOW TABLES FROM $bookstore_db";
$result = mysql_query($sql);
if (!$result) {
echo "DB Error, could not list tables\n";
echo 'MySQL Error: ' . mysql_error();

while ($row = mysql_fetch_row($result)) {
echo "Table: {$row[0]}\n";

Re: Topic 6A-1
October 13, 2006 08:04AM
Access denied for user: '@localhost' to database 'bookstore_db' means just that - accesss is denied. If access was denied for a user named pete, then it would have said "pete@localhost".

So create a user and password in the user table in the mysql db, and give this user the rights you want to. Then add give the user access to the bookstore_db (in the db table in the mysql databhase), specifying what rights the user has on this db. Use this information in $link_id = mysql_connect(localhost,user, password);

Remember to restart mysql or reload theprivileges.

The sem 1 forum is always there?

Re: Topic 6A-1
October 13, 2006 04:52PM
Topic Completed
Re: Topic 6A-1
October 30, 2006 09:23PM
Hi again

I am still having a problem with user privileges. I can do the exercises in chapter 6 to add, delete and update records in a MySQL database, if it is one that I create. But if I try to do this with the database called mysql (to add, delete or edit a user), or bookstore_db, I am getting the 'Access denied...' message. Since I can't get into the mysql database, I can't add a user or edit their rights; I can't specify privileges...

When I connect (using $link_id = mysql_connect(localhost,user, password)winking smiley I am using a name and a password which works, but I am not doing this as root because I don't know the right password. Is this the problem? If so, how can I delete the existing root and add a new one (with a new password) if I don't have permission to access the mysql table?

I have been using MySQL administrator to look at this as well, and when I try to use User Administration to work with the Users Accounts, I can add a new user with no problem but if I try to bring up the details for an existing user I am getting the message 'A MySQL error was encountered. The message is: Error while fetching user information. The following error occurred: Unknown column 'Show_db_priv' in 'field list' (1054).

Any ideas? I am going nowhere very fast with this... the project deadline is looming and I haven't been able to start yet.

Thanks in advance...
Re: Topic 6A-1
October 31, 2006 08:15AM
Try just mysql_connect() not entering any info in the brackets
- with XAMPP its normally not required.

If the above does not work, then follow the phpMyAdmin link on the XAMPPlocalhost page. On the front page of phpmyadmin there's a link Privileges. Click and then click Add a user. Enter login information, and for now, tick all the privileges.

Go to the mysql db and and insert a user for your database in the db table, ticking all privileges again.

Go to the front page oh phpMyAdmin and click the reload mysql link.
Sorry, only registered users may post in this forum.

Click here to login