Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create database in same location of code?

Tags:

php

mysql

This code generate database correctly. This code is in C:\inetpub\wwwroot\mini location but it generates the database in C:\ProgramData\MySQL\MySQL Server 5.6\data

How to create database in same place where the code is??

<?php

$conn=new mysqli("localhost","root","hiitisme");
$dept=$conn->escape_string($_POST['dept']);
$class=$conn->escape_string($_POST['class']);
$create=$conn->escape_string($_POST['new']);

if($create=="create")
{
    $sql="CREATE DATABASE $dept";
    $conn->query($sql);
    $sql="USE $dept";
    $conn->query($sql);
    $sql="CREATE TABLE $class(Rollno integer,name varchar(30),phone integer(10),email    varchar(20))";
    $conn->query($sql);
    echo "database createed suceefully";
}
?>
like image 945
Pranavadurai Avatar asked Nov 02 '22 05:11

Pranavadurai


1 Answers

  • As MasterAM say it is insecure, if i know that , i could download your DB and exploit your's later.
  • If you absolutely want to do that, just change the "datadir" param in my.ini
like image 56
Taz Avatar answered Nov 09 '22 11:11

Taz