We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,329 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to connect to Workbench Server instance from php

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";
    ?>
3
Contributors
7
Replies
1 Day
Discussion Span
4 Months Ago
Last Updated
8
Views
mgrichen
Newbie Poster
4 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

@mgrichen

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

Which line is line 3?

LastMitch
Industrious Poster
4,191 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45

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

mgrichen
Newbie Poster
4 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

veedeoo
Master Poster
735 posts since Oct 2011
Reputation Points: 298
Solved Threads: 130
Skill Endorsements: 13

@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.

LastMitch
Industrious Poster
4,191 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45

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?

mgrichen
Newbie Poster
4 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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/

LastMitch
Industrious Poster
4,191 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45

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

mgrichen
Newbie Poster
4 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0822 seconds using 2.72MB