Connecting to MySql Database

mysql , insert , database connection , echo , mysql_query Alexandria, United States
  • 11 years ago

    I have just went through and got the code to be able to create a database in mysql. I'm very very new at this, but how to you connect to a database and to view your data on a simple row and colum format. Thank you so much for your time!

    Don

  • 10 years ago

    Please try this steps thus we create the database connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysqlerror()); }

    if (mysqlquery("CREATE DATABASE mydb",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); }

    mysql_close($con); ?>

    connecting the database

    $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="databasename"; // Database name

    // Connect to server and select databse. mysqlconnect($host, $username, $password)or die("cannot connect"); mysqlselectdb($dbname)or die("cannot select DB")

    Regards, Karthick

    [URL="http:// www.module-node.com/"] Drupal Web Developers | | Drupal Theme Developers | Drupal Development [/URL]

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++: an octopus made by nailing extra legs onto a dog.” - Steve Taylor