How to retrieve data from database in different machine?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yoyoz
    New Member
    • Apr 2007
    • 7

    How to retrieve data from database in different machine?

    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?
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Originally posted by yoyoz
    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?
    So 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

    • yoyoz
      New Member
      • Apr 2007
      • 7

      #3
      Originally posted by ajaxrand
      So 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.
      Yes. you are right. actually i am new to php, can you just guide me what script should i use? may be can you just give me a sample script? thanks a lot...

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        There are lots of sample scripts here for the beginners.
        W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

        Comment

        • yoyoz
          New Member
          • Apr 2007
          • 7

          #5
          Originally posted by ajaxrand
          There are lots of sample scripts here for the beginners.
          http://www.w3schools.com/php/php_mysql_intro.asp
          I 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

          • ak1dnar
            Recognized Expert Top Contributor
            • Jan 2007
            • 1584

            #6
            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

            • ak1dnar
              Recognized Expert Top Contributor
              • Jan 2007
              • 1584

              #7
              Originally posted by yoyoz
              I 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.
              Please use [PHP] [ /PHP] Tags around your Scripts.Read the posting guidelines.

              Comment

              • yoyoz
                New Member
                • Apr 2007
                • 7

                #8
                Originally posted by ajaxrand
                Please use [PHP] [ /PHP] Tags around your Scripts.Read the posting guidelines.
                i have tried to establish the connection with the IP add of the Solaris machine bt it still cannot work.
                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

                Working...