Page 1 of 1

cannot connect... something basic wrong?

Posted: Thu Sep 14, 2006 11:28 am
by jmilane
I am on a network that has a beta.mycompany.com - a machine aliased so I can do development work. The beta machine is running PHP and Apache and MySQL.

I am trying to write code that will run on a machine outside of the beta server but still pull data from the beta server.

Can I do this without a public IP? It seems like it should work, since I can type beta.mycompany.com into the address bar and it will work. But, it doesnt seem to. I get a 404 error from the following code:

Code: Select all

<html>
<head><title> MySQL Data </title></head>
<body bgcolor="#FFFFFF">

<?
$DBhost = "beta.myco.org";
$DBuser = "user";
$DBpass = "pass";
$DBName = "db_test";
$table = "testtable";

mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName"); 
$sqlquery = "SELECT * FROM $table";
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);

$i = 0;

if ($number < 1) {
print "<CENTER><P>There Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$thename = mysql_result($result,$i,"firstname");
$theemail = mysql_result($result,$i,"lastname");
print "<p><b>Name:</b> $thename<br><b>E-Mail:</b>
$theemail</p>";
$i++;
}
}
?>
</BODY></HTML>
I am confused.

Thank you.

J

Posted: Thu Sep 14, 2006 11:46 am
by jmilane
I cant get THIS to work, but I can connect to the db with this:

Code: Select all

<?php

mysql_connect("beta.myco.org", "test", "tester") or die(mysql_error());
mysql_select_db("db_test") or die(mysql_error());

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM test") 
or die(mysql_error());  

echo $result;

echo "<table border='1'>";
echo "<tr> <th>Name</th> <th>Age</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
	// Print out the contents of each row into a table
	echo "<tr><td>"; 
	echo $row['firstcol'];
	echo "</td><td>"; 
	echo $row['seccol'];
	echo "</td></tr>"; 
} 

echo "</table>";
?>

Posted: Thu Sep 14, 2006 11:56 am
by ok
I think that you need to configure MySQL to accept connections outside localhost or maybe only for "beta.mycompany.com".

Posted: Thu Sep 14, 2006 11:57 am
by jmilane
ok wrote:I think that you need to configure MySQL to accept connections outside localhost or maybe only for "beta.mycompany.com".
I did, and it does. Just for some reason the first method works and the second method doesnt.

No need to respond to this thread. I dont want to take up anyone's time and I have figured out a workaround.

Thanks.

Posted: Thu Sep 14, 2006 8:17 pm
by feyd
This thread is now in three different places. Pick one and stick to it, please.