1,105,391 Community Members

How to connect to Workbench Server instance from php

Member Avatar
mgrichen
Newbie Poster
4 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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?

Member Avatar
mgrichen
Newbie Poster
4 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
veedeoo
Veteran Poster
1,016 posts since Oct 2011
Reputation Points: 314 [?]
Q&As Helped to Solve: 166 [?]
Skill Endorsements: 17 [?]
 
0
 

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

LastMitch
Deleted Member
 
0
 

@mgrichen

$con = mysql_connect($server_name,$server_user,$server_password);

Read this and follow the instruction on the images:

http://wiki.ocssolutions.com/Connecting_to_MySQL_via_MySQL_Workbench

also try this to see either it's the connection or not:

http://blog.mclaughlinsoftware.com/2012/09/02/hostname-change-error/

And also read the link that veedeoo provided.

Member Avatar
mgrichen
Newbie Poster
4 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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?

LastMitch
Deleted Member
 
0
 

@mgrichen

I should be able to access the worknench instance.

Since you have installed MySQL Workbench 5.2.44 or you can update to MySQL Workbench 5.245:

http://dev.mysql.com/downloads/workbench/5.2.html

I changed to server name to "localhost" with no success.

Read this and try the plugin MySQL Workbench 5.2.35:

http://mysqlworkbench.org/2011/09/mysql-workbench-php-development-helper-plugins/

Member Avatar
mgrichen
Newbie Poster
4 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: