Jump to content

deltahawk

Members
  • Posts

    9
  • Joined

  • Last visited

deltahawk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for letting me know. This is all internal facing, I'm using a dummy database server and right now my primary focus is to be able to make the PHP script work (which is what I am trying to learn).
  2. This is the entire code: <form action="example.php" method="POST"> <input type="text" name="name"> <input type="submit"> </form> <?php //connect $con=mysqli_connect("xxx","xxx","xxx!"); //check connection if (mysqli_connect_errno($con)) { echo "Connection Failed: " . mysqli_connect_error(); } else { echo "Connection Sucessful"; } // Create database $sql="CREATE DATABASE({$_POST['name']})"; if (mysqli_query($con,$sql)) { echo "Database my_db created successfully"; } else { echo "Error creating database: "; } ?>
  3. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in drxtech/connect.php on line 25
  4. I've tried both $sql="CREATE DATABASE ($_POST['name'])"; and $sql="CREATE DATABASE ($_GET['name'])";
  5. I'm stuck trying to figure out the correct method of calling the input from "name" <form action="example.php" method="POST"> <input type="text" name="name"> <input type="submit"> </form> into the create database query. // Create database $sql="CREATE DATABASE [input here]; if (mysqli_query($con,$sql)) { echo "Database [name] created successfully"; } else { echo "Error creating database: " . mysqli_error(); } ?> I've tried both $sql="CREATE DATABASE ($_POST['name'])"; and $sql="CREATE DATABASE ($_GET['name'])";
  6. I've spent about half an hour on google trying to figure it out, which is why I resorted to signing up on this forum and asking. It might be obvious to you, but being that I've only been involved for PHP for such short time, I'm obviously missing something. Sorry for bothering you! And yes, I've tried $_POST.
  7. I just started learning PHP, I'm sorry if the following questions sounds "dumb". I'm trying to create a PHP script that will allow me to create new databases, pulling the name of the database to be created from a text input box on the same page. In this case, let's assume a connection to the database has been established via another PHP script on the same page, so I am already authenticated. This is the code I have <form action="example.php" method="POST"> <input type="text" name="name"> <?php // Create database $sql="CREATE DATABASE [insert name from input here]; if (mysqli_query($con,$sql)) { echo "Database [name] created successfully"; } else { echo "Error creating database: " . mysqli_error(); } ?> So, to be short and to the point, how can I get the input from "name" to [insert name from input here]? Your time and help is appreciated!
×
×
  • 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.