Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts

    mysql error on localhost

    hi im tryin to run a tst database but get errors
    Code:
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\xampp\xampp\htdocs\createdb.php on line 3
    
    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\Program Files\xampp\xampp\htdocs\createdb.php on line 3
    errorsuccess
    this is in my createdb.php
    PHP Code:
    <?php 
    $query  
    "CREATE DATABASE phpcake";
    $result mysql_query($query);

    if (!
    $result)
    {
    echo 
    "error";
    }
    {
    echo 
    "success";
    }
     
    ?>

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    This is how you create a new database. the query that you are trying to do can only be done once a connection as been made to a specific database.

    PHP Code:
    <?php
    $link 
    mysql_connect('localhost''mysql_user''mysql_password');
    if (!
    $link) {
       die(
    'Could not connect: ' mysql_error());
    }

    $sql 'CREATE DATABASE my_db';
    if (
    mysql_query($sql$link)) {
       echo 
    "Database my_db created successfully\n";
    } else {
       echo 
    'Error creating database: ' mysql_error() . "\n";
    }
    ?>
    you should go and read up on this stuff at

    http://uk.php.net/manual/en/ref.mysql.php

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    thats it thanks i havent done anythng in php for sometime


  •  

    Posting Permissions

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