Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL error when creating multiple tables
    primarykey
    data
    text
    <p>I'm trying to create multiple tables with a query, but it doesn't seem to work. I'm using PHP code to execute the query. Below is my PHP code, my query and my error.</p> <p>My PHP code:</p> <pre><code>&lt;?php $conn=mysql_connect("localhost","secret","secret") or die("Kan geen verbinding maken met de DB server"); mysql_select_db("secret",$conn) or die("Kan database niet selecteren"); $query_file = 'tables.txt'; $fp = fopen($query_file, 'r'); $sql = fread($fp, filesize($query_file)); fclose($fp); mysql_select_db('test_db'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not create table: ' . mysql_error()); } mysql_close($conn); ?&gt; </code></pre> <p>My query:</p> <pre><code>CREATE TABLE pages( id INT NOT NULL AUTO_INCREMENT, pagid VARCHAR(32) NOT NULL, title VARCHAR(32) NOT NULL, content TEXT NOT NULL, image VARCHAR(65) NOT NULL, youtube VARCHAR(32) NOT NULL, primary key ( id )); CREATE TABLE members( id INT NOT NULL AUTO_INCREMENT, username VARCHAR(65) NOT NULL, password VARCHAR(65) NOT NULL, primary key ( id )); CREATE TABLE news( id INT NOT NULL AUTO_INCREMENT, pagid VARCHAR(32) NOT NULL, title VARCHAR(32) NOT NULL, content TEXT NOT NULL, image VARCHAR(150) NOT NULL, youtube VARCHAR(32) NOT NULL, date VARCHAR(32) NOT NULL, primary key ( id )); CREATE TABLE gallery( id INT NOT NULL AUTO_INCREMENT, image VARCHAR(65) NOT NULL, title VARCHAR(65) NOT NULL, description TEXT NOT NULL, url VARCHAR(200) NOT NULL, category VARCHAR(65) NOT NULL, primary key ( id )); </code></pre> <p>My error:</p> <pre><code>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 'CREATE TABLE members( id INT NOT NULL AUTO_INCREMENT, username VARCHA' at line 10 </code></pre> <p>Does anyone have any idea what I'm doing wrong here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload