need help with this code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • T12
    Sergeant

    • Mar 2009
    • 35

    need help with this code

    hi, this is my first try at php and just need to know is this code right as im getting errors but dont know if its my code or the sever side


    <?php

    //CONNECT MYSQL and SELECT TABLE;

    $host = "localhost"; //host name;
    $username = "test"; //mysql server login name;
    $password = "test"; //mysql server login password;

    //database Name;

    $database = "test";

    //PREPARE sql statement;

    $sql1 = "CREATE DATABASE $database";

    //EXECUTE sql statement;

    $exq1 = mysql_query($sql1);

    //reply us the database is created or not;

    if($exq1) {

    echo "database created";

    } else {

    echo "error while create database";

    }

    ?>
    T12
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: need help with this code

    VH has Cpanel, which doe NOT allow creation of Databases through a query.

    You need to create your database through CPanel.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment

    • Watdaflip
      Major General

      • Sep 2005
      • 2116

      #3
      Re: need help with this code

      You should be able to create the database manually through a script, using your cpanel username/password in the script.

      Register/Login Script
      Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

      Comment

      • navaldesign
        General & Forum Moderator

        • Oct 2005
        • 12080

        #4
        Re: need help with this code

        Hm.... I can't be certain, but i believe not. Even phpMyAdmin which by default uses the cpanel usename / password, has privilleges to create a new database.
        Navaldesign
        Logger Lite: Low Cost, Customizable, multifeatured Login script
        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

        Comment

        Working...
        X