1.11M Members

How to connect to Workbench Server instance from php

 
0
 
I have got MySQL Workbench 5.244 installed. I have a server instance created (MySQL55). Everything works perfect inside the workbench.
The problem is when I try to connect to the server on my PHP (version 4.2.1) file.

(Pleasew find header.php and default.php below)

I get the message below:

Warning: Unknown MySQL Server Host 'MySQL55' (0) in c:\webroot\default.php on line 3

Warning: MySQL Connection Failed: Unknown MySQL Server Host 'MySQL55' (0) in c:\webroot\default.php on line 3
Could not connect: Unknown MySQL Server Host 'MySQL55' (0)

I am new to php but this code was working when I had it lodged on an external web server.

Can somenone help?

Thank you.

Mario van Grichen

    <?php 
    $server_name="MySQL55";
    $server_user="root";
    $server_password="************";
    $db_name="a4874781_Genix";
    ?>




    include 'header.php';
    $con = mysql_connect($server_name,$server_user,$server_password);
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db($db_name, $con);

    $event = mysql_query("SELECT * FROM event WHERE usageTP='M' ORDER BY eventDS");

    echo "<table border='0'>
    <tr>
    <th>Event Type</th>
    <th>Description</th>
    <th>Usage</th>
    </tr>";

    while($row = mysql_fetch_array($event))
      {
      echo "<tr>";
      echo "<td>" . $row['eventTP'] . "</td>";
      echo "<td>" . $row['eventDS'] . "</td>";
      echo "<td>" . $row['usageTP'] . "</td>";
      echo "</tr>";
      }
    echo "</table>";

    mysql_close($con);
    ?><?php
    include 'header.php';
    $con = mysql_connect($server_name,$server_user,$server_password);
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db($db_name, $con);

    $event = mysql_query("SELECT * FROM event WHERE usageTP='M' ORDER BY eventDS");

    echo "<table border='0'>
    <tr>
    <th>Event Type</th>
    <th>Description</th>
    <th>Usage</th>
    </tr>";

    while($row = mysql_fetch_array($event))
      {
      echo "<tr>";
      echo "<td>" . $row['eventTP'] . "</td>";
      echo "<td>" . $row['eventDS'] . "</td>";
      echo "<td>" . $row['usageTP'] . "</td>";
      echo "</tr>";
      }
    echo "</table>";

    mysql_close($con);
    ?>    <?php 
    $server_name="MySQL55";
    $server_user="root";
    $server_password="************";
    $db_name="a4874781_Genix";
    ?>
LastMitch
Deleted Member
 
0
 

@mgrichen

Warning: Unknown MySQL Server Host 'MySQL55' (0) in c:\webroot\default.php on line 3

Which line is line 3?

 
0
 

Hi
3rd line is
$con = mysql_connect($server_name,$server_user,$server_password);

 
0
 

can you try $server_name="localhost", if it does not work for you, read more about it here.

 
0
 

I changed to server name to "localhost" with no success.
I can check on my task bar that mysqld is running.
I am running these applications on XP SP3.
The web server is Apache 1.3.24.
I should be able to access the worknench instance.
Could it be a priveleges problem?

 
0
 

Yes, I will upgrade and try the plugin.
Let's see what it bring :-)
Thanks a a lot

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: