Page 1 of 1

Viewing records/Deleting Tables

Posted: Tue Mar 11, 2003 4:35 am
by williery10
Hi I have just got PHP and MySQL going on my machine and am doing my first tutorial. Just started and already am stuck.

1) Have been trying to access a small table i created and keep getting this error.

PHP Warning: mysql_query() [function.mysql-query]: Unable to save result set in C:\Inetpub\wwwroot\test.php on line 21 PHP Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\test.php on line 25 PHP Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\test.php on line 29

It´s probably due to an error in the records entered but I have just realised that WINMYSQLAdmin does not have the facility to create, destroy, delete or VIEW tables, or records.

?What application do I need to edit/records my tables manually?

2) I read in a posting that it is possible to import and export a database from WinMySQLAdmin but cannot seem to find the option, should this only be done from the dos promt/shell.


Any help would be great
williery (Novice)

Posted: Tue Mar 11, 2003 5:55 am
by twigletmac
Could you show us the code that is generating the errors?

Mac

Posted: Tue Mar 11, 2003 6:09 am
by williery10
no problem

<html>
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT * FROM employees",$db);
printf("First Name: %s<br>\n", mysql_result($result,0,"first"));
printf("Last Name: %s<br>\n", mysql_result($result,0,"last"));
printf("Address: %s<br>\n", mysql_result($result,0,"address"));
printf("Position: %s<br>\n", mysql_result($result,0,"position"));
?>
</body>
</html>

I copied this directly from the tutorial
I linked the mysql to an access db to view my records and they look fine so am at a bit of a loss
cheers williery

Posted: Wed Mar 12, 2003 8:51 pm
by net7
Well, from what I can see, you might not be connecting to the database correctly.

Is there a username "root" without a password in your MySQL? Or is your domain localhost?

(I had this error on my linux machine a while back and realized "localhost" was not correct and I had to use "localhost.localdomain".)

But it sounds like you are on a windows box.

Posted: Wed Mar 12, 2003 8:53 pm
by net7
Hmm, as I looked through your post again I noticed the errors were for lines like 25 and 29 while your whole page (that you posted) is only like 15 lines. Hmmm.


And if you want to edit your MySQL manually (tables, databases, records) you can use phpMyAdmin. http://www.phpmyadmin.net[/url]

Posted: Thu Mar 13, 2003 3:10 am
by williery10
Thanks for all your help,
after a bit of sweating and thought I realised the query was returning nothing so checked my db dump script and the name of the db was wrong. :oops: .will be sure in the future to check tutourial scripts rather than just copying and pasting. Thanks for all your help.
Williery