1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

why it is not working

Discussion in 'PHP' started by anchitjindal07, Aug 29, 2009.

  1. anchitjindal07

    anchitjindal07 New Member

    Joined:
    Jul 13, 2009
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    0
    Please read the following code

    <?php
    $a=mysql_connect(localhost,root,"");
    if(!$a)
    echo "Could not connect";
    ?>

    When i run the above pgm it gives the following errors:

    Notice: Use of undefined constant localhost - assumed 'localhost' in C:\Program Files\EasyPHP 3.0\www\dbase.php on line 2

    Notice: Use of undefined constant root - assumed 'root' in C:\Program Files\EasyPHP 3.0\www\dbase.php on line 2

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\Program Files\EasyPHP 3.0\www\dbase.php on line 2
    Could not connect



    Please tell where is the problem. I am using easyphp 3.0
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    localhost / root should be within quotes or else they should be declared as variables.
     

Share This Page