Hi John:
Im trying to connect to a remote mysql database but it seems that this thing
is not working
This is the information that thw browser sent to me:
Warning: Access denied for user: '[EMAIL PROTECTED]' (Using password:
NO) in /usr/local/apache/htdocs/pruebamysql.php on line 5
Warning: MySQL Connection Failed: Access denied for user:
'[EMAIL PROTECTED]' (Using password: NO) in
/usr/local/apache/htdocs/pruebamysql.php on line 5
1045: Access denied for user: '[EMAIL PROTECTED]' (Using password: NO)
And here it is the php.. wher it says localhost, I should only type the remote
IP address?
HTMLHEADTITLEForm Results /TITLE
BODY
?php
$connection = mysql_connect('localhost,'root');
if ($connection == false){
echo mysql_errno().: .mysql_error().BR;
exit;
}
mysql_select_db ('bb50');
$query = select course_id,course_name from course_main;
$result = mysql_query ($query);
if ($result){
echo table border=1;
echo trtdbNumero/b/tdtdbNombre del curso/b/tdtdbClave
d
el curso/b/td/tr;
$numOfRows = mysql_num_rows ($result);
for ($i = 0; $i $numOfRows; $i++){
$coursename = mysql_result ($result, $i, 0);
$courseid = mysql_result ($result, $i, 0);
echo trtd$i/tdtd$coursename/tdtd$courseid/td/tr;
}
echo /table;
}
else{
echo mysql_errno().: .mysql_error().BR;
}
mysql_close ($connection);
?
/BODY
/HTML
John McKown wrote:
On Fri, 8 Sep 2000, Kevin Xin Lin wrote:
int mysql_connect ([string hostname [:port] [:/path/to/socket] [, string
username [, string password]]])
This is the syntax of mysql_connect, I don't see any db information.
What DB is in USE when I create a connection to MySQL? What have I
overlooked?
Well, I overlooked it too. The sequence is mysql_connect(),
mysql_select_db(), then mysql_query(). I overlooked the
mysql_select_db() as well. I guess that's because I always use the
default database which is the same as my username. Also, I tend to use
PostgreSQL more often than MySQL, so I forget some of the MySQL
steps. Sorry about that!
$connect=mysql_connect(...);
$database=mysql_select_db(foo,$connect);
$result=mysql_query($query,$connect);
All queries which use $connect will go against the last
mysql_select_db() which specified $connect (or the default db if it wasn't
called).
I hope I made more sense this time grin!
John
P.S. Does anybody know if doing this is more efficient that using the
mysql_db_query() call? I would think that it might since MySQL would be
in the correct database already. True?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]