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?

<HTML><HEAD><TITLE>Form Results </TITLE>

$connection = mysql_connect('localhost,'root');
if ($connection == false){
  echo mysql_errno().": ".mysql_error()."<BR>";
mysql_select_db ('bb50');

$query = "select course_id,course_name from course_main";
$result = mysql_query ($query);

if ($result){
  echo "<table border=1>";
  echo "<tr><td><b>Numero</b></td><td><b>Nombre del curso</b></td><td><b>Clave
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 "<tr><td>$i</td><td>$coursename</td><td>$courseid</td></tr>";

  echo "</table>";
  echo mysql_errno().": ".mysql_error()."<BR>";

mysql_close ($connection);



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]

Reply via email to