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",<myuserID>,<mypwd>)
mysql_select_db("DaveC42_weight_test",$dbcnx);
$result = mysql_query("SELECT * FROM 'weight_data'");
printf("Date: %s<br>\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.
 
DaveC426913 said:
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",<myuserID>,<mypwd>)
mysql_select_db("DaveC42_weight_test",$dbcnx);
$result = mysql_query("SELECT * FROM 'weight_data'");
printf("Date: %s<br>\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.


If I'm not mistaken, that should be:

PHP:
$dbcnx = @mysql_connect( "mysql.jodoshared.com",<myuserID>,<mypwd>) 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<br>\n", mysql_result($result,0,"Date"));
 
The Frog said:
If I'm not mistaken, that should be:

PHP:
$dbcnx = @mysql_connect( "mysql.jodoshared.com",<myuserID>,<mypwd>) 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<br>\n", mysql_result($result,0,"Date"));

OK, tried that. Got this error:
"I cannot connect to the database because: Can't connect to MySQL server on 'mysql.jodoshared.com' (10060)"


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

$dbcnx = @mysql_connect( "mysql.jodoshared.com","<uname>","<pwd>") 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<br>\n", mysql_result($result,0,"Date"));



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.
 
Oh ok, sorry. That might still be a good reference point for people needing mysql connections however. :)
 
It was a routing issue at that time, the servers were in different datacenters, they are in the same now.
 
Back
Top