0

it's showing an syntax error message in line 18 help me out to solve it and i really want a table name by client so what i have to do if this piece of code don't work and first of all is it possible to take name of the table from the user or the client?

<?php
if(isset($_POST['table']))
{
    $server="localhost";
    $username="root";
    $password="";
    $database="major";
    
    $con=mysqli_connect($server,$username,$password,$database);
    
    if (!$con)
    {
        die("failed". mysqli_connect_erre());
    }
    
    $table=$_POST['table'];
    $sql="create table '$table'(id int,name varchar(5))";
    $result=mysqli_query($con,$sql);
    
    if($result==true)
    {
        echo"sucess";
    }
    else
    {
        echo"error";
    }
}
?>
<html>
<body>
    <form action="new.php" method="post">
        <input type="text" name=table id=table>
        <button>submit</button>
    </form>
</body>
</html>

0 Answers0