Here are the details. Here is the code I wrote in PHP, in a file called "mini.php". I commented out some lines that didn't work, to give an example of what I tried earlier.
----------
Code: Select all
<?
$mysql_access = mysql_connect("localhost", "root");
echo '$mysql_access = ', $mysql_access, "<br>"; // Displays: Resource id #3
mysql_select_db($db, $mysql_access);
echo '$db = ', $db , "<br>"; // Displays: (blank)
$result = mysql_query("select * from onetable"); // Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\if3\mini.php on line 13
//$result = mysql_query("select * from onetable", $mysql_access); // Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\if3\mini.php on line 12
//$result = mysql_query("SHOW tables", $mysql_access); // Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\if3\mini.php on line 11
echo '$result = ', $result, "<br>"; // Displays: (blank)
$row = mysql_fetch_row($result); // <--- problem is said to be here
echo '$row = ', $row , "<br>"; // Displays: (blank)
mysql_close($mysql_access);
?>I created the MySQL database by hand in the comand prompt, using the simple login...
Code: Select all
C:\xampp\mysql\bin>mysql -u root -h localhost
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.33-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database onedb;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| mysql |
| onedb |
| phpmyadmin |
| readings |
| test |
| webauth |
+--------------------+
8 rows in set (0.03 sec)
mysql> use onedb;
Database changed
mysql> create table onetable(onecol int);
Query OK, 0 rows affected (0.06 sec)
mysql> insert into onetable values(3);
Query OK, 1 row affected (0.02 sec)
mysql> insert into onetable values(4);
Query OK, 1 row affected (0.00 sec)
mysql>Here is what results when I run the PHP program...
$mysql_access = Resource id #2
$db =
$result =
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\if3\mini.php on line 12
$row =