Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP create table error 1064
    primarykey
    data
    text
    <p>I am trying to create a table in mySQL. This is my php page below, when I run the page there are no errors but the table is not in mySQL and when I test the code in mySQL I'm getting the error </p> <blockquote> <p>#1064 - 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 '$user = "root"' at line 1.</p> </blockquote> <p>I've done a bit of research into what this error means but I'm getting no where. I don't really understand what it means. If I'm honest I don't really understand php I'm just adapting the code I've written in previous uni tutorials. Please help.</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $user="root"; $password=""; $database="test"; mysql_connect('localhost',$user,$password)or die( "Unable to connect to server"); mysql_select_db($database) or die( "Unable to select database"); $query="CREATE TABLE Bookings ( id int(6) NOT NULL auto_increment, name varchar(25), email varchar(35), number varchar(20), buffet varchar(3), ceilidh varchar(5), work1 varchar(3), beg1 varchar(3), int1 varchar(3), adv1 varchar(3), youth varchar(3), lunch varchar(3), beg2 varchar(3), int2 varchar(3), adv2 varchar(3), dinner varchar(3), dance varchar(5), work2 varchar(3), lunch2 varchar(3), price varchar(5), PRIMARY KEY (ID) )"; mysql_query($query); mysql_close(); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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