MYSQL and php

Help please. I am a novice, starting at square one with php.

I just want the simplest set up to connect.

So far, I’ve got a database going, called ‘DaveC42_weight_test’, and a php page in my root that has the following code:

$dbcnx = @mysql_connect( “new_sqlserver”,,)
mysql_select_db(“DaveC42_weight_test”,$dbcnx);
$result = mysql_query(“SELECT * FROM ‘weight_data’”);
printf(“Date: %s
\n”, mysql_result($result,0,“Date”));

Tech support is telling me I don’t need a path to the database, and has provided the first line of code (the $dbcnx). They are otherwise tightlipped with help.

I keep getting ‘parse error, unexpected T_STRING’ in the next line (mysql_select_db)

I could really use some help getting started here.

[QUOTE=DaveC426913]
Help please. I am a novice, starting at square one with php.

I just want the simplest set up to connect.

So far, I’ve got a database going, called ‘DaveC42_weight_test’, and a php page in my root that has the following code:

$dbcnx = @mysql_connect( “new_sqlserver”,,)
mysql_select_db(“DaveC42_weight_test”,$dbcnx);
$result = mysql_query(“SELECT * FROM ‘weight_data’”);
printf(“Date: %s
\n”, mysql_result($result,0,“Date”));

Tech support is telling me I don’t need a path to the database, and has provided the first line of code (the $dbcnx). They are otherwise tightlipped with help.

I keep getting ‘parse error, unexpected T_STRING’ in the next line (mysql_select_db)

I could really use some help getting started here.
[/QUOTE]

If I’m not mistaken, that should be:

[php]
$dbcnx = @mysql_connect( “mysql.jodoshared.com”,,) or die ('I cannot connect to the database because: ’ . mysql_error());

mysql_select_db(“DaveC42_weight_test”,$dbcnx);
$result = mysql_query(“SELECT * FROM weight_data”);
printf(“Date: %s
\n”, mysql_result($result,0,“Date”));
[/php]

[QUOTE=The Frog]
If I’m not mistaken, that should be:

[php]
$dbcnx = @mysql_connect( “mysql.jodoshared.com”,,) or die ('I cannot connect to the database because: ’ . mysql_error());

mysql_select_db(“DaveC42_weight_test”,$dbcnx);
$result = mysql_query(“SELECT * FROM weight_data”);
printf(“Date: %s
\n”, mysql_result($result,0,“Date”));
[/php]
[/QUOTE]

OK, tried that. Got this error:
[FONT=Courier New]“I cannot connect to the database because: Can’t connect to MySQL server on ‘mysql.jodoshared.com’ (10060)”[/FONT]

Deleted and recreated to ensure I had everything just so. This is what I’ve got now.

[FONT=Courier New]$dbcnx = @mysql_connect( “mysql.jodoshared.com”,“”,“”) or die ('I cannot connect to the database because: ’ . mysql_error());

mysql_select_db(“DaveC42_test”,$dbcnx);
$result = mysql_query(“SELECT * FROM tblChart”);
printf(“Date: %s
\n”, mysql_result($result,0,“Date”)); [/FONT]

Is it possible it’s a username/password thing? I’m using the user name and password I’ve added as a dba, with full privileges.

It may all be in the way hsphere adds databases, they are in the form of username_nameyougave and sometimes the username is shortened even. Also the database name is username_databasenameyougave.

You might want to check that out.

No, this is a networking issue. You cannot connect to mysql from win2. We’re looking into it

Oh ok, sorry. That might still be a good reference point for people needing mysql connections however. :slight_smile:

Fixed

[QUOTE=Yash]
Fixed
[/QUOTE]

Hi, can you tell me what you did to sort it out…?

It was a routing issue at that time, the servers were in different datacenters, they are in the same now.