mysql_connect() problem

Discussion in 'PHP' started by srinath49, Nov 27, 2008.

  1. #1
    guys guys guys!!! help needed..
    i newly setup php apache mysql and in windows xp
    i did everything right as far as i can see and normal php works fine.
    but when i try to connect to mysql only a blank page is displayed....
    this is the code i used:

    <?php

    $con = mysql_connect("localhost","mysqluser","mypasswd");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    else
    {
    echo 'Successfully Connected!';
    }
    mysql_close($con);
    ?>


    what is the problem???
     
    srinath49, Nov 27, 2008 IP
  2. srinath49

    srinath49 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i wont even get error message
     
    srinath49, Nov 27, 2008 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Most likely mysql support is not installed and error reporting is disabled. Use the following line on the top of the page and then try again.
    error_reporting(E_ALL);
     
    mwasif, Nov 27, 2008 IP
  4. srinath49

    srinath49 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for the reply mate but nothing changed when i included that line............
    and what did you mean by "Most likely mysql support is not installed"?? How to install it?
     
    srinath49, Nov 27, 2008 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
  6. xenous

    xenous Peon

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try this you ll see whats wrong.

    $con = mysql_connect("localhost","mysqluser","mypasswd") or die (mysql_error());
     
    xenous, Nov 27, 2008 IP
  7. srinath49

    srinath49 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    mwasif, i did that already..... but no use
     
    srinath49, Nov 27, 2008 IP
  8. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #8
    Hm that's strange. You don't see the error or the success message.
    Try this.

    
    <?php
    $con = mysql_connect("localhost","mysqluser","mypasswd");
    
    echo '<p>This is the $con ';
    var_dump($con);
    echo '</p>';
    
    echo '<p>starting if</p>';
    
    if ($con) {
       echo 'Successfully Connected!';
    } else {
       echo('Could not connect: ' . mysql_error());
    }
    
    echo '<p>ending if</p>';
    mysql_close($con);
    ?>
    
    PHP:
     
    xrvel, Nov 27, 2008 IP
  9. xenous

    xenous Peon

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    is mysql included in your php configuration? if not i suggest you uninstall php apache and mysql then install a ready pack such as xampp
     
    xenous, Nov 28, 2008 IP
  10. Z33M@N

    Z33M@N Peon

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I had a similar problem, what you are going to have to do is, uninstall everything, Download the latest Mysql and xamp installation. then install your Mysql first, then install the xamp. from there you things should work, just remember to create a new database :D Hope it helps you.
     
    Z33M@N, Nov 28, 2008 IP
  11. adamhk

    adamhk Member

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #11
    Maybe you need first enable showing php errors at all.
     
    adamhk, Nov 29, 2008 IP