OK. I am relatively new to all of this stuff. I have managed to intall the apache bundle and I am now able to create html documents which uses php on my machine, by storing the documents in the 'htdocs' folder.
However, I am having some trouble getting mysql to work with php.
I shall explain:
I have created a table using mysql and I now want to connect to the database throught the use of php to return the results of a query. However, this does not work for me.
The HTML document is as follows:
<HTML>
<HEAD>
<TITLE>Connecting to an SQL server</TITLE>
</HEAD>
<BODY>
<?php
require_once('DB.php');
$db = DB::connect("mysql://localhost/test");
if (DB::iserror($db)) { die(db->getMessage()); }
$sql = "SELECT name, phone FROM contacts";
$result = $db -> query($sql);
if (DB::iserror($db)) { die($db->getMessage()); }
while ($result -> fetchInto($row)){
echo $row[ 0 ], $row[ 1 ];
}
?>
</body>
</html>
When i open the HTML i get
getMessage()); } $sql = "SELECT name, phone FROM contacts"; $result = $db -> query($sql); if (DB::iserror($db)) { die($db->getMessage()); } while ($result -> fetchInto($row)){ echo $row[ 0 ], $row[ 1 ]; } ?>
in the browser as if the code is wrong, but i am assured by reliable resources that the code is correct.
I think it may have something to do with where the html fileis kept and where the database is kept, as the readme was a little vague when it came to this.
Can anyone help
...and yes, both the apache and mysql batch files are open whilst i am doing this. I have even tried keeping the mysql window open as a third window while trying to run it.
Cheers
Andy