MYSQL Access problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • g

    MYSQL Access problem

    I have a php scripted that access a mysql database. I use the same
    access methods in other scripts and it access it the database fine:

    if (!($connection = @ mysql_pconnect( $hostName,
    $username,
    $password)))
    showerror();

    if (!mysql_select_ db($databaseNam e, $connection))
    showerror();


    but I have one script were I get the error message:

    Access denied for user: '@localhost' to database 'winestore' (# 256).

    So is there something else it could be expect the password or user
    name???
  • dariush

    #2
    Re: MYSQL Access problem

    You may try something like this

    <?php

    $lnk = mysql_connect(' localhost', 'mysql_user', 'mysql_password ')
    or die ('Not connected : ' . mysql_error());

    // make foo the current db
    mysql_select_db ('foo', $lnk) or die ('Can\'t use foo : ' . mysql_error());

    ?>Database Migration ExpertsSQLPorte r(Database migration
    toolkit)www.rea lsoftstudio.com "g" <the_game_is_ne ver_over@yahoo. co.uk> wrote
    in message news:2059e247.0 309230831.5c550 697@posting.goo gle.com...[color=blue]
    > I have a php scripted that access a mysql database. I use the same
    > access methods in other scripts and it access it the database fine:
    >
    > if (!($connection = @ mysql_pconnect( $hostName,
    > $username,
    > $password)))
    > showerror();
    >
    > if (!mysql_select_ db($databaseNam e, $connection))
    > showerror();
    >
    >
    > but I have one script were I get the error message:
    >
    > Access denied for user: '@localhost' to database 'winestore' (# 256).
    >
    > So is there something else it could be expect the password or user
    > name???[/color]


    Comment

    • Yves Brault

      #3
      Re: MYSQL Access problem

      It seems that your variable $username is not defined or is empty...


      "dariush" <dariush@realso ftstudio.com> wrote in message
      news:M0ncb.4371 $1H3.337846@new s20.bellglobal. com...[color=blue]
      > You may try something like this
      >
      > <?php
      >
      > $lnk = mysql_connect(' localhost', 'mysql_user', 'mysql_password ')
      > or die ('Not connected : ' . mysql_error());
      >
      > // make foo the current db
      > mysql_select_db ('foo', $lnk) or die ('Can\'t use foo : ' . mysql_error());
      >
      > ?>Database Migration ExpertsSQLPorte r(Database migration
      > toolkit)www.rea lsoftstudio.com "g" <the_game_is_ne ver_over@yahoo. co.uk>[/color]
      wrote[color=blue]
      > in message news:2059e247.0 309230831.5c550 697@posting.goo gle.com...[color=green]
      > > I have a php scripted that access a mysql database. I use the same
      > > access methods in other scripts and it access it the database fine:
      > >
      > > if (!($connection = @ mysql_pconnect( $hostName,
      > > $username,
      > > $password)))
      > > showerror();
      > >
      > > if (!mysql_select_ db($databaseNam e, $connection))
      > > showerror();
      > >
      > >
      > > but I have one script were I get the error message:
      > >
      > > Access denied for user: '@localhost' to database 'winestore' (# 256).
      > >
      > > So is there something else it could be expect the password or user
      > > name???[/color]
      >
      >[/color]


      Comment

      Working...