Hello,
I have downloaded XAMPP and am trying to teach myself PHP MySQL using the book PHP MySQL for Dummies by Janet Valade 2010 edition. The book has not been very helpful so far. I was able, using a video on YouTube from River City Graphics learn how to set up XAMPP with a user name and password. Then I went into XAMPP and set up a trial database. With the book, I did a very simple test file for PHP that when I opened it in a web browser by typing in the address bar localhost.test.php, everything worked fine. I then went to the section on Testing MySQL. I typed the following code:
[php]<?php
/* Program: mysql_test.php
- Desc: Connects to MySQL Server and
-
outputs settings.
*/
echo "
Test MySQL
";
$host = “hostname”;
$user = “mysqlaccount”;
$password = “mysqlpassword”;
$cxn = mysqli_connect($host,$user,$password);
$sql=“SHOW DATABASES”;
$result = mysqli_query($cxn,$sql);
if($result == false) {
echo “
Error: “.mysqli_error($cxn).”
”;} else {
if(mysqli_num_rows($result) < 1) {
echo “
No current databases
”;} else {
echo “
- ”;
- $row[0] ”;
while($row = mysqli_fetch_row($result)) {
echo “
}
echo “
}
}
?> [/php]
I saved it as instructed as mysql_test.php. I changed the $host = “hostname” to “localhost” as the book said to. Also, per the book’s instructions, I changed the $user = “mysqlaccount” to “root”. For $password I substituted my own password.
Yet, when I type in the address bar localhost/mysql_test.php I only get an error message stating "Parse error: syntax error, unexpected ‘:’ in C:\xampphtdocs\mysql_test.php on line 11 where my password goes.
The book is absolutely no help. It basically says if you receive an error message to figure it out yourself. Can anybody please help me? Can anyone tell me what I have done wrong or at tell me where to look? Any help or advice is greatly appreciated.
Thank you
Michelle Jensen