kennyaidan
Programmer
Hi Guys,
On my home PC, I have installed a MySql DB and an Apache server in order to progress my PHP knowledge. I created a new database called "manual" and within this DB I added a table and simple simple data. When I query my DB through MySQL server, I can see the "manual" database and a test table I created called "pets". Here is the SQL query below
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 rows in set (0.56 sec)
mysql> use manual
Database changed
mysql> SHOW TABLES;
Empty set (0.03 sec)
mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20));
Query OK, 0 rows affected (0.92 sec)
mysql> SHOW TABLES;
+------------------+
| Tables_in_manual |
+------------------+
| pet |
+------------------+
1 row in set (0.00 sec)
mysql> INSERT INTO pet VALUES ('Tiger','Damian');
Query OK, 1 row affected (0.13 sec)
mysql> SHOW TABLES;
+------------------+
| Tables_in_manual |
+------------------+
| pet |
+------------------+
1 row in set (0.00 sec)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
However when I run sample php files to extract and display the data I just get empty pages back with no error messages.
Here is an example of a php test file I have been running on localhost:
<?php
$connection = mysql_connect("localhost", "root", "*******");
$database = mysql_select_db("manual");
$result = mysql_query("SELECT * FROM pets");
while($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo $row[0] . '<br>';
}
mysql_close();
?>
So it seems that while the MySQL DB has been created and tables are present, the php files cannot connect and retrieve data from the DB hence the test pages are appearing blank. I receive no error messages on these test php files.
When I add simple pieces of text before the php code, they are displayed fine in browser so Apache itself is working fine, I feel it is obviously my code that is missing something? Or do I need to install further SW that allows PHP and MySQL talk to each other?
Any ideas on how I should resolve this issue would be great
Thanks
Aidan
On my home PC, I have installed a MySql DB and an Apache server in order to progress my PHP knowledge. I created a new database called "manual" and within this DB I added a table and simple simple data. When I query my DB through MySQL server, I can see the "manual" database and a test table I created called "pets". Here is the SQL query below
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 rows in set (0.56 sec)
mysql> use manual
Database changed
mysql> SHOW TABLES;
Empty set (0.03 sec)
mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20));
Query OK, 0 rows affected (0.92 sec)
mysql> SHOW TABLES;
+------------------+
| Tables_in_manual |
+------------------+
| pet |
+------------------+
1 row in set (0.00 sec)
mysql> INSERT INTO pet VALUES ('Tiger','Damian');
Query OK, 1 row affected (0.13 sec)
mysql> SHOW TABLES;
+------------------+
| Tables_in_manual |
+------------------+
| pet |
+------------------+
1 row in set (0.00 sec)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
However when I run sample php files to extract and display the data I just get empty pages back with no error messages.
Here is an example of a php test file I have been running on localhost:
<?php
$connection = mysql_connect("localhost", "root", "*******");
$database = mysql_select_db("manual");
$result = mysql_query("SELECT * FROM pets");
while($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo $row[0] . '<br>';
}
mysql_close();
?>
So it seems that while the MySQL DB has been created and tables are present, the php files cannot connect and retrieve data from the DB hence the test pages are appearing blank. I receive no error messages on these test php files.
When I add simple pieces of text before the php code, they are displayed fine in browser so Apache itself is working fine, I feel it is obviously my code that is missing something? Or do I need to install further SW that allows PHP and MySQL talk to each other?
Any ideas on how I should resolve this issue would be great
Thanks
Aidan