Jump to content

prathameshkakade

Members
  • Posts

    37
  • Joined

  • Last visited

About prathameshkakade

  • Birthday 09/18/1994

Profile Information

  • Gender
    Male
  • Location
    Hyderabad,India

prathameshkakade's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello Everyone,I was learning connecting MySQLi with PHP.I wanted to display the names of all the databases on my server.I used the following code. <?php $server = 'localhost'; $user = 'root'; $pass = 'pass'; $mysqli = new mysqli($server,$user,$pass); if($mysqli->connect_error) die("Could not connect to server.<br/>"); $query = "SHOW DATABASES"; if($result = $mysqli->query($query)) { while($row = $result->fetch_row()) { printf("%s<br/>",$row[0]); } } ?> I am getting the desired result,but I didi not understand the functions fetch_row() and fetch_assoc properly. and why are we using the indice '0' in the line printf("%s<br/>",$row[0]); I tried using 1,but it gave me errors.I did not understand what was given on php.net manual. Someone please explain me in detail. Thank you.
  2. Hello everyone.I am using joomla for about 6 months.Till now I installed it on WAMP and it worked fine.But now I manually installed and configured apcahe,PHP5.5,Mysql on windows.Now when I start installing installing joomla,I get the main installation page to select the language.After selecting the language and clicking next,the loading circle appears and the installation does not proceed forward.Please help.I have attached my PHP info file. phpinfo().pdf
  3. Hello everyone.I was trying to display all the databases available on a server in a dropdown list.But I could not get it.Here is my code. <html> <head> <title> List Databases </title> </head> <body> <?php $connection = mysqli_connect('localhost','root','123456789'); if(!$connection)die(mysqli_connect($connection));else echo "Step 1:<br/>Successfully connected to MySQLi server<br/><hr/>"; $query = mysqli_query($connection,"SHOW DATABASES"); echo "Step 2:<br/>The databases available on this server are :<br/>"; while(($result = mysqli_fetch_assoc($query)) != NULL) { echo $result['Database']."<br/>"; } echo "<hr/>"; echo "<form method = 'POST' action = 'list-db.php'>"; echo "<select name = 'db[]'>"; $a = 0; while($result[$a]!= NULL) { echo "<option>$result[$a]</option>"; $a++; } ?> Please help.
  4. I tried that.Now it is showing the following error. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATABASE hello' at line 1
  5. I tried the other way to create tables. <html> <head> <title> Database </title> </head> <body> <?php require("./db-config.php"); //$a = mysqli_query($mysql,"CREATE DATABASE $database"); //if(!$a)die(mysqli_error($mysql)); //else echo "Successfully created database"; $table = "user"; $function = "CREATE TABLE $table ( 'userid' MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT, 'username' VARCHAR(20) BINARY NOT NULL, 'password' VARCHAR(20) BINARY NOT NULL, 'name' VARCHAR(20) BINARY NOT NULL) CHARACTER SET utf8 COLLATE utf8_general_ci"; $test = mysqli_query($mysql,"SELECT DATABASE $database"); if(!$test)die(mysqli_error($mysql)); else { $ct = mysqli_query($mysql,$function); if(!$ct)die(mysqli_error($mysql)); else { echo "Successfully created tables $table ($td)<br/>"; } } ?> Now it shows the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'hello' at line 1. What is the error here?
  6. Yes it is working.I put wrong username and it showed error.
  7. Mysql user which I am using here is root.So I don't understand why the user does not have permission?
  8. It successfully connects to the mysql server as I don not receive the error from db-config.php file.
  9. I am trying to create MySQL database using PHP. Here is my code. db-config.php <html> <head> <title> Database Configuration </title> </head> <body> <?php $host = "localhost"; $user = "root"; $pass = "123456789"; $database = "hello"; $mysql = new mysqli($host,$user,$pass); if($mysql->connect_error) { die ("Could not connect to database"); } ?> createdb.php <html> <head> <title> Create tables </title> </head> <body> <?php include("\db-config.php"); if(!$a = ($mysql->query("CREATE DATABASE $database")))die("Could not create database"); echo "Successfully created database"; $table = "user"; $td = "userid MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT,"; $td .= "username VARCHAR(20) BINARY NOT NULL,"; $td .= "password VARCHAR(20) BINARY NOT NULL,"; $td .= "name VARCHAR(20) BINARY NOT NULL"; $test = $mysql->query("SELECT DATABASE $database"); if(!(mysqli_select_db($mysql,$database)))die("Could not connect to database"); if(!(mysqli_query("CREATE TABLE $table ($td)")))die("Could not create tables"); echo "Successfully created tables"; ?> </body> </html> It always results in die message. Please help.
  10. Please show me the PHP code. Thanks for the reply.
  11. Hello everyone. I am new to PHP/SQL. I tried to display tables from a database using PHP and MySQli functions(not MySQL). But I failed. Can anyone tell me how to do it.Also please explain me the code, Thank You.
  12. Hello.I installed apache.php,mysql on fedora 19.Then I created phpinfo.php file in web directory and opened it in browser.Everything worked fine.Then I copied wordpress installation files into the web folder and opened it in browser,but it says access denied.(403 forbidden). Please help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.