mysql_connect not working ?

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default mysql_connect not working ?

    I'm using apache 1.3.28 php 4.3.9 mysql 4.1 on my machine which runs
    win2000.
    I can connect to the apache server from a browser, and run a script with
    phpinfo included which tells me mysql support is installed.
    I can run mysql from the command console, and create databases/tables etc.
    However when I try to connect to mysql from a php script, mysql_connect
    cannot connect to mysql.
    The function returns false.
    Any ideas how I can see what is happening, or what might be wrong ?
    Regards
    Tony



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004


    Tony Benham Guest

  2. Similar Questions and Discussions

    1. problem with mysql_connect
      hi, can you give me the exact error message? And is it right to put the @ there? It works great with this syntax: @...
    2. [PHP] mysql_connect error
      on 25/08/2003 12:11 PM, John W. Holmes at holmes072000@charter.net wrote: Error line 43 (or 42 if 43 commented out and 42 uncommented) 38: ...
    3. mysql_connect error
      Hi, again this line is causing problems: $h = mysql_connect('localhost',constant("mysql_user"),constant("mysql_password")) ; Aparantly a...
    4. parse error with mysql_connect
      Hi, The prototype for mysql_connect is: resource mysql_connect ( ]]]] ) As you can see you get parse error because the fourth argument...
    5. mysql_connect() fails randomly
      i've got a library file that i require() in all my scripts. it starts with this line: $dbh=mysql_connect() or die("mysql connect failed: " ....
  3. #2

    Default Re: mysql_connect not working ?

    Tony Benham wrote:
    > I'm using apache 1.3.28 php 4.3.9 mysql 4.1 on my machine which runs
    > win2000.
    > I can connect to the apache server from a browser, and run a script with
    > phpinfo included which tells me mysql support is installed.
    > I can run mysql from the command console, and create databases/tables etc.
    > However when I try to connect to mysql from a php script, mysql_connect
    > cannot connect to mysql.
    > The function returns false.
    > Any ideas how I can see what is happening, or what might be wrong ?
    > Regards
    > Tony
    >
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    > Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004
    can you post the code that return the error?!

    --
    [url]www.iuz-lab.info[/url]
    iuz Guest

  4. #3

    Default Re: mysql_connect not working ?

    Hi,
    The code is very simple
    @ $db = mysql_connect('localhost', 'username', 'password');

    if (!$db)

    {

    echo 'Error: Could not connect to database, Please try again later.';

    exit;

    }

    Tony

    "iuz" <user@host.network> wrote in message
    news:oFV8d.73615$35.3739320@news4.tin.it...
    > Tony Benham wrote:
    >
    > > I'm using apache 1.3.28 php 4.3.9 mysql 4.1 on my machine which runs
    > > win2000.
    > > I can connect to the apache server from a browser, and run a script with
    > > phpinfo included which tells me mysql support is installed.
    > > I can run mysql from the command console, and create databases/tables
    etc.
    > > However when I try to connect to mysql from a php script, mysql_connect
    > > cannot connect to mysql.
    > > The function returns false.
    > > Any ideas how I can see what is happening, or what might be wrong ?
    > > Regards
    > > Tony
    > >
    > >
    > >
    > > ---
    > > Outgoing mail is certified Virus Free.
    > > Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    > > Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004
    >
    > can you post the code that return the error?!
    >
    > --
    > [url]www.iuz-lab.info[/url]

    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004


    Tony Benham Guest

  5. #4

    Default Re: mysql_connect not working ?

    "Tony Benham" <tonyb@kerrisway.freeserve.co.uk> wrote in message
    news:2sio28F1limqaU1@uni-berlin.de...
    > Hi,
    > The code is very simple
    > @ $db = mysql_connect('localhost', 'username', 'password');
    After this, put:
    if (mysql_errno()) echo mysql_errno() . ':' . mysql_error() . '<br>';

    and see if that tells you what is wrong.
    > if (!$db)
    >
    > {
    >
    > echo 'Error: Could not connect to database, Please try again later.';
    >
    > exit;
    >
    > }
    >
    > Tony


    Virgil Green Guest

  6. #5

    Default Re: mysql_connect not working ?

    Hi,
    I switched error reporting on ,and got the following error.
    Warning: mysql_connect(): Client does not support authentication protocol
    requested by server; consider upgrading MySQL client in results.php on line
    23
    I can connect from the mysql monitor wiithout any problem.
    Any ideas what this is ?
    Tony


    "Tony Benham" <tonyb@kerrisway.freeserve.co.uk> wrote in message
    news:2sio28F1limqaU1@uni-berlin.de...
    > Hi,
    > The code is very simple
    > @ $db = mysql_connect('localhost', 'username', 'password');
    >
    > if (!$db)
    >
    > {
    >
    > echo 'Error: Could not connect to database, Please try again later.';
    >
    > exit;
    >
    > }
    >
    > Tony
    >
    > "iuz" <user@host.network> wrote in message
    > news:oFV8d.73615$35.3739320@news4.tin.it...
    > > Tony Benham wrote:
    > >
    > > > I'm using apache 1.3.28 php 4.3.9 mysql 4.1 on my machine which runs
    > > > win2000.
    > > > I can connect to the apache server from a browser, and run a script
    with
    > > > phpinfo included which tells me mysql support is installed.
    > > > I can run mysql from the command console, and create databases/tables
    > etc.
    > > > However when I try to connect to mysql from a php script,
    mysql_connect
    > > > cannot connect to mysql.
    > > > The function returns false.
    > > > Any ideas how I can see what is happening, or what might be wrong ?
    > > > Regards
    > > > Tony
    > > >
    > > >
    > > >
    > > > ---
    > > > Outgoing mail is certified Virus Free.
    > > > Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    > > > Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004
    > >
    > > can you post the code that return the error?!
    > >
    > > --
    > > [url]www.iuz-lab.info[/url]
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    > Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004
    >
    >

    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004


    Tony Benham Guest

  7. #6

    Default Re: mysql_connect not working ?

    Hi,
    I found the error was the new password hashing algorithm in MySQL4.1 up.
    PHP4.3.9 I guess uses the old algorithm. Anyway I set 4.1 to use the old
    style passwords and it's now fine.
    Thanks for the help.
    Tony

    "Virgil Green" <vjg@DESPAMobsydian.com> wrote in message
    news:SxW8d.1575$Lk3.597@newssvr12.news.prodigy.com ...
    > "Tony Benham" <tonyb@kerrisway.freeserve.co.uk> wrote in message
    > news:2sio28F1limqaU1@uni-berlin.de...
    > > Hi,
    > > The code is very simple
    > > @ $db = mysql_connect('localhost', 'username', 'password');
    >
    > After this, put:
    > if (mysql_errno()) echo mysql_errno() . ':' . mysql_error() . '<br>';
    >
    > and see if that tells you what is wrong.
    >
    > > if (!$db)
    > >
    > > {
    > >
    > > echo 'Error: Could not connect to database, Please try again later.';
    > >
    > > exit;
    > >
    > > }
    > >
    > > Tony
    >
    >
    >

    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004


    Tony Benham Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139