I’ve been asked to create a table in a DB, its been about 15 years since I’ve had to touch SQL so I’m a little lost.
This code below is what I was given, I modified it because I already have the DB.
'CREATE DATABASE ' . $dbname . ';'); 'USE ' . $dbname .';'); 'CREATE TABLE ' . $tblname . ' (seccred TEXT, id VARCHAR(128) NOT NULL PRIMARY KEY, ctime DATETIME, xtime DATETIME, views INT, xviews INT);'; 'CREATE EVENT ' . $tblname . '_tidy ON SCHEDULE EVERY 1 MINUTE DO DELETE FROM ' . $dbname . '.' . $tblname . ' WHERE xtime<UTC_TIMESTAMP() OR views>=xviews;'); 'SET GLOBAL event_scheduler = 1;'); 'GRANT ALL PRIVILEGES ON ' . $dbname . '.* TO '' . $dbuser . ''@'localhost' IDENTIFIED BY '' . $dbpass . '';') ;
It gives me an error, I have already created the DB and I simply want to create the table and the event so I tried to use
CREATE TABLE nat_pp (seccred TEXT, id VARCHAR(128) NOT NULL PRIMARY KEY, ctime DATETIME, xtime DATETIME, views INT, xviews INT); CREATE EVENT nat_pp _tidy ON SCHEDULE EVERY 1 MINUTE DO DELETE FROM nat_pp.natit_pwp WHERE xtime<UTC_TIMESTAMP() OR views>=xviews;); SET GLOBAL event_scheduler = 1;);
But PHPMyadmin says “You have an error in your SQL syntax;”
I tried to reformat it and remove the additional marks on the query