I am currently building a database with 3 tables using Mysql in solaris 9. I have work out my API in windows using dreamweaver. I would like to try linking the API and database by using php and apache server? anyone who can help me solve thi problem?
How to retrieve data from database in different machine?
Collapse
X
-
Originally posted by yoyozI am currently building a database with 3 tables using Mysql in solaris 9. I have work out my API in windows using dreamweaver. I would like to try linking the API and database by using php and apache server? anyone who can help me solve thi problem?
If you Need to Call for Database from your API use the IP Address and MySQL Port of that Solaris Machine. -
Originally posted by ajaxrandSo your MySQL Database i running under Solaris and your Apache Web Server is Running Under Windows.
If you Need to Call for Database from your API use the IP Address and MySQL Port of that Solaris Machine.Comment
-
Originally posted by ajaxrandThere are lots of sample scripts here for the beginners.
http://www.w3schools.com/php/php_mysql_intro.asp
The error message is:
Warning: mysql_connect() : Can't connect to MySQL server on 'Solaris IP add' (10054) in c:\program files\easyphp1-7\www\view-taxo-solaris.php on line 11
Problem connecting to DataBaseCan't connect to MySQL server on 'Solaris IP add' (10054)
Below is my php script:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SEA Fruit flies Database System<</title>
</head>
<body bgcolor=#ffffff >
<h2>Data from taxo</h2>
<?
$MyConn=mysql_c onnect("Solaris IP add: port","root","" );
if (!$MyConn) {
die ("Problem connecting to DataBase".mysql _error());
}
echo 'Connected successfully';
mysql_close($My Conn);
$query = "select * from taxo order by genus, species";
$result = mysql_db_query( "seaff_2007 ", $query);
if ($result) {
echo "Found these entries in the database:<br><p ></p>";
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#99CC00 >Subfamily</td>
<td align=center bgcolor=#99CC00 >Tribe</td>
<td align=center bgcolor=#99CC00 >Subgenus</td>
<td align=center bgcolor=#99CC00 >Genus</td>
<td align=center bgcolor=#99CC00 >Species</td>
<td align=center bgcolor=#99CC00 >Distribution </td>
</tr>";
while ($r = mysql_fetch_arr ay($result)) {
$subf = $r["subfamily"];
$tribe = $r["tribe"];
$subg = $r["subgenus"];
$genus = $r["genus"];
$spe = $r["species"];
$distri = $r["distributi on"];
echo "<tr>
<td>$subf</td>
<td>$tribe</td>
<td>$subg</td>
<td>$genus</td>
<td>$spe</td>
<td>$distri</td>
</tr>";
}
echo "</table>";
} else {
echo "No data.";
}
mysql_free_resu lt($result);
?>
</body>
</html>
Should i put all my php file in the Solaris machine as well? Or i need to change any configuration in the Windows or Solaris machine? Just to stress that i would like to call out the data from solaris through my windows machine.
Thanks.Comment
-
If didn't change the port number for my sql, the default is 3306.
first try to establish the connection then try to fetch the database values.
[PHP]<?php
$dbcnx = mysql_connect(" 127.0.0.1:3306" ,"root","dba ");
if ($dbcnx)
{
echo 'Success';
}
else
{
echo ' Unable' ;
}
?>[/PHP]
try like this also. with out the port.
[PHP]$dbcnx = mysql_connect(" 127.0.0.1","roo t","dba");[/PHP]
make sure to use the ip,username.pwd of your solaris node.Comment
-
Originally posted by yoyozI had found some php script regarding the connection, but it still can't work.
The error message is:
Warning: mysql_connect() : Can't connect to MySQL server on 'Solaris IP add' (10054) in c:\program files\easyphp1-7\www\view-taxo-solaris.php on line 11
Problem connecting to DataBaseCan't connect to MySQL server on 'Solaris IP add' (10054)
Below is my php script:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SEA Fruit flies Database System<</title>
</head>
<body bgcolor=#ffffff >
<h2>Data from taxo</h2>
<?
$MyConn=mysql_c onnect("Solaris IP add: port","root","" );
if (!$MyConn) {
die ("Problem connecting to DataBase".mysql _error());
}
echo 'Connected successfully';
mysql_close($My Conn);
$query = "select * from taxo order by genus, species";
$result = mysql_db_query( "seaff_2007 ", $query);
if ($result) {
echo "Found these entries in the database:<br><p ></p>";
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#99CC00 >Subfamily</td>
<td align=center bgcolor=#99CC00 >Tribe</td>
<td align=center bgcolor=#99CC00 >Subgenus</td>
<td align=center bgcolor=#99CC00 >Genus</td>
<td align=center bgcolor=#99CC00 >Species</td>
<td align=center bgcolor=#99CC00 >Distribution </td>
</tr>";
while ($r = mysql_fetch_arr ay($result)) {
$subf = $r["subfamily"];
$tribe = $r["tribe"];
$subg = $r["subgenus"];
$genus = $r["genus"];
$spe = $r["species"];
$distri = $r["distributi on"];
echo "<tr>
<td>$subf</td>
<td>$tribe</td>
<td>$subg</td>
<td>$genus</td>
<td>$spe</td>
<td>$distri</td>
</tr>";
}
echo "</table>";
} else {
echo "No data.";
}
mysql_free_resu lt($result);
?>
</body>
</html>
Should i put all my php file in the Solaris machine as well? Or i need to change any configuration in the Windows or Solaris machine? Just to stress that i would like to call out the data from solaris through my windows machine.
Thanks.Comment
-
Originally posted by ajaxrandPlease use [PHP] [ /PHP] Tags around your Scripts.Read the posting guidelines.
what if i have accidentally changed the port number in Solaris? or may be someone else did?
can i know where i can look for the setting? thanks you so much.Comment
Comment