Jump to content

Recommended Posts

Im getting an error with this can someone tell me the problem

The htm form

<form method="post" action="createdb.php"> 
User Name: <input type="text" name="user" /> 
Password: <input type="password" name="pass" /> 
Database Name: <input type="text" name="dbname" /> 
<input type="submit" /> 
</form>

This is the php

<?php
$con = mysql_connect("localhost",$_POST["user"],$_POST["pass"]);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

if (mysql_query("CREATE DATABASE".$_POST["dbname"],$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }

mysql_close($con);
?>

This is the error

Error creating database: 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 'DATABASEmydb' at line 1

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.