Page 1 of 1

How to configure MySQL Server to talk to CMS.

Posted: Fri Sep 07, 2007 6:40 pm
by aidank
Hi There

I am trying to configure MySQL Server to talk to CMS.

I am testing my Apache/PHP/MySQL installation by creating a file called testMysql.php, source code below

';
}
mysql_close();
?>

When I load the page((http://localhost:8080/test/testMysql.php), the page appears to be blank.

My other PHP test files load correctly but I cannot load any PHP files that communicate with MySQL database.

I have created an empty database called 'cms' on mySQL Server 5.0.

I have also downloaded the mysqli PHP5 extension/data connector from www.mysql.com.

Can anybody help me with this, any advice would be much appreciated.

Thanks

Aidan

Re: How to configure MySQL Server to talk to CMS.

Posted: Fri Sep 07, 2007 8:15 pm
by alby
aidank wrote: I am testing my Apache/PHP/MySQL installation by creating a file called testMysql.php, source code below

';
}
mysql_close();
?>

When I load the page((http://localhost:8080/test/testMysql.php), the page appears to be blank.
Insert a control for error and empty result, for example:
$connection = mysql_connect("localhost", "root", "******");
if (!$connection) {
    die("Could not connect: " . mysql_error());
}
echo "Connected successfully";


$database = mysql_select_db("cms");
$database = mysql_select_db("cms", $connection);
if (!$database) {
    die ("Can't use cms: " . mysql_error());
}
echo "DB Connected successfully";


$result = mysql_query("SELECT name FROM help_category", $connection);
if (!$result) {
    die("Invalid query: ". mysql_error() ."\n". "Whole query: $query");
}
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo $row[0] . '';
}
}
else echo "Empty result!";
Alby

Re: How to configure MySQL Server to talk to CMS.

Posted: Sat Sep 08, 2007 3:06 pm
by aidank
Hi Alby,

Thanks for the advice but I am still having problems here.

When I query my DB through MySQL server, I can see the "cms" database and a test table I created called "pets". Here is the SQL query below

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 rows in set (0.56 sec)

mysql> use cms
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_cms |
+---------------+
| pet          |
+---------------+
1 row in set (0.00 sec)

mysql> INSERT INTO pet VALUES ('Maddog','Damian');
Query OK, 1 row affected (0.13 sec)

mysql> SHOW TABLES;
+---------------+
| Tables_in_cms |
+---------------+
| pet          |
+---------------+
1 row in set (0.00 sec)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

However when I run php files like the one you provided I just get empty pages back with no error messages.

Here is some of examples of the php test files I have been running on localhost:8080:

';
}
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.

Any ideas on how I should resolve this issue would be greatly appreciated as I am a novice when it comes to DBs etc

Thanks

Aidan

Re: How to configure MySQL Server to talk to CMS.

Posted: Sat Sep 08, 2007 4:29 pm
by alby
aidank wrote: Hi Alby,

Thanks for the advice but I am still having problems here.

...............

Here is some of examples of the php test files I have been running on localhost:8080:

';
}
mysql_close();
?>

Any ideas on how I should resolve this issue would be greatly appreciated as I am a novice when it comes to DBs etc
Have you try my code? Which error?
Alby

Re: How to configure MySQL Server to talk to CMS.

Posted: Sat Sep 08, 2007 7:02 pm
by aidank
Hi Alby,

Yes I tried your code and I just get a complete blank page back. No error messages appear. When I place other pieces of normal test around your code, they are displayed so the file itself is been found and displayed by Apache, it just coming back blank.

As I say I checked my DB and my table is present and it has content in it.

Thanks
Aidan

Re: How to configure MySQL Server to talk to CMS.

Posted: Sat Sep 08, 2007 7:42 pm
by alby
aidank wrote: Yes I tried your code and I just get a complete blank page back. No error messages appear. When I place other pieces of normal test around your code, they are displayed so the file itself is been found and displayed by Apache, it just coming back blank.
Very strange if blank page only.
Maybe you have display error off.

Insert this code in top:

Code: Select all

ini_set('display_errors', true)
error_reporting(E_ALL);

$connection = mysql_connect("localhost", "root", "******");
if (!$connection) {
    die("Could not connect: " . mysql_error());
}
echo "Connected successfully";


$database = mysql_select_db("cms");
$database = mysql_select_db("cms", $connection);
if (!$database) {
    die ("Can't use cms: " . mysql_error());
}
echo "DB Connected successfully";


$result = mysql_query("SELECT name FROM help_category", $connection);
if (!$result) {
    die("Invalid query: ". mysql_error() ."<br>\n". "Whole query: $query");
}
if (mysql_num_rows($result) > 0) {
   while($row = mysql_fetch_array($result, MYSQL_NUM)) {
      echo $row[0] . '<br>';
   }
}
else echo "Empty result!";

Alby

Re: How to configure MySQL Server to talk to CMS.

Posted: Sat Sep 08, 2007 11:36 pm
by calguy1000
This is not a CMS Made Simple topic, instead its a general 'how do I get my PHP application to talk to the database' topic.

If the topic is CMS related I would be happy to help further. But it's not.
Numerous (thousands of?) people have managed to connect to CMS made simple to the database provided by their host with no difficulty.

My oppinion is.... Please take this topic elsehwere.  This board is for CMS related questions.  If your host hasn't provided you with enough information to connect to the database, then you need to take it up to your host.  If you're looking for general programming help, then there are other places to look for it.

Thank you.

Re: How to configure MySQL Server to talk to CMS.

Posted: Sun Sep 09, 2007 7:57 am
by Milhaus
Perhaps this would fit to The Lounge thread...