php - create database with no cpanel access -


i have installation script, works fine on localhost on share hosting "access denied", below installation script mysql code. weird how works locally on localhost.

if(isset($_post['install'])) { $adminusername = htmlspecialchars(strip_tags($_post['admin_username'])); $adminpassword = htmlspecialchars(strip_tags($_post['admin_password'])); $dbhost = strip_tags($_post['dbhost']); $dbuser = strip_tags($_post['dbuser']); $dbpass = $_post['dbpass']; $sitename = strip_tags($_post['sitename']); $sql = "create table tickets ( id int not null auto_increment primary key, name varchar(32), email varchar(40), subject varchar(40), message text(500), open varchar(10), timecreated varchar(40), timeupdated varchar(40), hash varchar(100) )"; $sql2 = "create table config  ( adminusername varchar(32), adminpassword varchar(32) )"; $sql3 = "insert config (adminusername,adminpassword) values ('$adminusername','$adminpassword')";  if(empty($dbhost)) { echo "<div style='color:red;'>mysql database host should not empty!</div><br /><br />"; } elseif(empty($dbuser)) { echo "<div style='color:red;'>mysql database user should not empty!</div><br /><br />"; } elseif(empty($dbpass)) { echo "<div style='color:red;'>mysql database password should not empty!</div><br /><br />";  } elseif(empty($sitename)) { echo "<div style='color:red;'>please enter name new installation (it can whatever want)</div><br /><br />"; } elseif(empty($adminusername)) { echo "<div style='color:red;'>admin username should not empty!</div><br /><br />"; } elseif (empty($adminpassword)) { echo "<div style='color:red;'>admin password should not empty!</div><br /><br />"; } else { $file = fopen('../configuration/config.php','r+'); fwrite($file, '<?php $dbhost = "'. $dbhost.'"; $dbuser = "'. $dbuser.'"; $dbpass = "'. $dbpass.'";  $sitename = "'. $sitename.'"; $temp = new mysqli ($dbhost, $dbuser, $dbpass);'); include('../configuration/config.php'); $temp->query("create database tests"); $file2 = fopen('../configuration/config.php','r+'); fwrite($file2, '<?php $dbhost = "'. $dbhost.'"; $dbuser = "'. $dbuser.'"; $dbpass = "'. $dbpass.'";  $sitename = "'. $sitename.'"; $dbname = "tests"; $con = new mysqli ($dbhost, $dbuser, $dbpass,$dbname);'); include('../configuration/config.php'); fopen('install.lock','w'); header('location: ../index.php'); } } } } else { echo "installation locked"; } 

how can make works on shared hostings? please , appreciate! in advance couldnt find answer on stackoverflow decided post new question

you don't have permissions that.

you can't create databases if user doesn't have permissions so. either have set permission specific user. doubt shared host let if prevented in first place.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -